diff mbox

[v2] add tests for queue

Message ID 201411010944276763629@linaro.org
State New
Headers show

Commit Message

yan.songming Nov. 1, 2014, 1:44 a.m. UTC
Fix spelling problem. Add term_local and term_global. Move cunit queue test to test_odp_queue_base for none syn queue.
 
Signed-off-by: Yan Songming <yan.songming@linaro.org>

---
test/cunit/Makefile.am      |   4 +-
test/cunit/odp_queue_test.c | 168 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 171 insertions(+), 1 deletion(-)
create mode 100644 test/cunit/odp_queue_test.c
 
-- 
1.8.3.1

Comments

Maxim Uvarov Nov. 1, 2014, 10:15 a.m. UTC | #1
Hello Yan,

few notes about sending patches.
1. pelase use 'git send-email' command.
2.  If you have any changes from previouse patch. Just open generated 
patch and add you comments after "--".
In that case when I do git am that lines will be skipped.
3. git commits usually look like:
short subject
<empty line>
long description
sign-off.

Thanks,
Maxim.

On 11/01/2014 04:44 AM, yan.songming@linaro.org wrote:
>
>         Fix spelling problem. Add term_local and term_global. Move
>         cunit queue test to test_odp_queue_base for none syn queue.
>         Signed-off-by: Yan Songming <yan.songming@linaro.org>
>         ---
>         test/cunit/Makefile.am      |   4 +-
>         test/cunit/odp_queue_test.c | 168
>         ++++++++++++++++++++++++++++++++++++++++++++
>         2 files changed, 171 insertions(+), 1 deletion(-)
>         create mode 100644 test/cunit/odp_queue_test.c
>         diff --git a/test/cunit/Makefile.am b/test/cunit/Makefile.am
>         index 927a5a5..46f46c9 100644
>         --- a/test/cunit/Makefile.am
>         +++ b/test/cunit/Makefile.am
>         @@ -6,8 +6,10 @@ AM_LDFLAGS += -L$(CUNIT_PATH)/lib
>         if ODP_CUNIT_ENABLED
>         TESTS = ${bin_PROGRAMS}
>         check_PROGRAMS = ${bin_PROGRAMS}
>         -bin_PROGRAMS = odp_init
>         +bin_PROGRAMS = odp_init odp_queue
>         odp_init_LDFLAGS = $(AM_LDFLAGS) -static -lcunit
>         +odp_queue_LDFLAGS = $(AM_LDFLAGS) -static -lcunit
>         endif
>         +dist_odp_queue_SOURCES = odp_queue_test.c
>         dist_odp_init_SOURCES = odp_init_test.c
>         diff --git a/test/cunit/odp_queue_test.c
>         b/test/cunit/odp_queue_test.c
>         new file mode 100644
>         index 0000000..04342a6
>         --- /dev/null
>         +++ b/test/cunit/odp_queue_test.c
>         @@ -0,0 +1,168 @@
>         +/* Copyright (c) 2014, Linaro Limited
>         + * All rights reserved.
>         + *
>         + * SPDX-License-Identifier:     BSD-3-Clause
>         + */
>         +
>         +#include "odp.h"
>         +#include "CUnit/Basic.h"
>         +
>         +#define MAX_BUFFER_QUEUE        (8) /**< Max enqueue buf num */
>         +#define MSG_POOL_SIZE           (4*1024*1024) /**< Message
>         pool size */
>         +
>         +static int Queue_Contest = 0xff;
>         +
>         +static int test_odp_buffer_pool_init(void)
>         +{
>         +    odp_buffer_pool_t pool;
>         +    void *pool_base;
>         +    odp_shm_t shm;
>         +
>         +    shm = odp_shm_reserve("msg_pool",
>         +                          MSG_POOL_SIZE, ODP_CACHE_LINE_SIZE, 0);
>         +
>         +    pool_base = odp_shm_addr(shm);
>         +
>         +    if (pool_base == NULL) {
>         +        printf("Shared memory reserve failed.\n");
>         +        return -1;
>         +    }
>         +
>         +    pool = odp_buffer_pool_create("msg_pool", pool_base,
>         MSG_POOL_SIZE,
>         +                                  0,
>         + ODP_CACHE_LINE_SIZE, ODP_BUFFER_TYPE_RAW);
>         +
>         +    if (pool == ODP_BUFFER_POOL_INVALID) {
>         +        printf("Pool create failed.\n");
>         +        return -1;
>         +    }
>         +    return 0;
>         +}
>         +
>         +static void test_odp_queue_base(void)
>         +{
>         +    odp_queue_t       queue_creat_id;
>         +    odp_queue_t       queue_id;
>         +    odp_buffer_t      Enbuf[MAX_BUFFER_QUEUE];
>         +    odp_buffer_t      Debuf[MAX_BUFFER_QUEUE];
>         +    odp_buffer_pool_t msg_pool;
>         +    odp_queue_param_t param;
>         +
>         +    int          i;
>         +    odp_buffer_t buf;
>         +    void         *pRtn = NULL;
>         +
>         +    /* test odp_queue_create */
>         +    memset(&param, 0, sizeof(param));
>         +    param.sched.sync  = ODP_SCHED_SYNC_NONE;
>         +
>         +    queue_creat_id = odp_queue_create("test_queue",
>         ODP_QUEUE_TYPE_POLL, &param);
>         +    CU_ASSERT(ODP_QUEUE_INVALID != queue_creat_id);
>         +
>         +    /* test odp_queue_type */
>         +    CU_ASSERT_EQUAL(ODP_QUEUE_TYPE_POLL,
>         odp_queue_type(queue_creat_id));
>         +
>         +    /* test odp_queue_type */
>         +    CU_ASSERT_EQUAL(ODP_SCHED_SYNC_NONE,
>         odp_queue_sched_type(queue_creat_id));
>         +
>         +    /* test odp_queue_lookup */
>         +    queue_id = odp_queue_lookup("test_queue");
>         +    CU_ASSERT_EQUAL(queue_creat_id, queue_id);
>         +
>         +    /* test odp_queue_set_context */
>         +    CU_ASSERT(0 == odp_queue_set_context(queue_id,
>         &Queue_Contest));
>         +
>         +    /* test  odp_queue_get_context*/
>         +    pRtn = odp_queue_get_context(queue_id);
>         +    CU_ASSERT(&Queue_Contest == (int *)pRtn);
>         +
>         +    /* apply for buffer */
>         +    msg_pool = odp_buffer_pool_lookup("msg_pool");
>         +    buf = odp_buffer_alloc(msg_pool);
>         +
>         +    /* test  odp_queue_enq and odp_queue_deq */
>         +    odp_queue_enq(queue_id, buf);
>         +    CU_ASSERT_EQUAL(buf, odp_queue_deq(queue_id));
>         +    odp_buffer_free(buf);
>         +
>         +    /* apply for mutili buffer */
>         +    for(i=0; i<MAX_BUFFER_QUEUE; i++) {
>         +        Enbuf[i] = odp_buffer_alloc(msg_pool);
>         +    }
>         +
>         +    /* test odp_queue_enq_multi  and odp_queue_enq_multi */
>         +    odp_queue_enq_multi(queue_id, Enbuf, MAX_BUFFER_QUEUE);
>         +    odp_queue_deq_multi(queue_id, Debuf, MAX_BUFFER_QUEUE);
>         +
>         +    for(i=0; i<MAX_BUFFER_QUEUE; i++) {
>         +        /* test odp_queue_deq_multi */
>         +        CU_ASSERT_EQUAL(Enbuf[i], Debuf[i]);
>         +        /*  buffer free */
>         +        odp_buffer_free(Enbuf[i]);
>         +    }
>         +    return;
>         +
>         +}
>         +
>         +static void test_odp_queue(void)
>         +{
>         +
>         +    int status;
>         +    status = odp_init_global(NULL, NULL);
>         +    CU_ASSERT_FATAL(0 == status);
>         +
>         +    CU_ASSERT(0 == odp_init_local())
>         +
>         +    /* initialize  buffer pool */
>         +    CU_ASSERT_FATAL(0 == test_odp_buffer_pool_init());
>         +
>         +    /* test odp none syne queue   */
>         +    test_odp_queue_base();
>         +
>         +    status = odp_term_local();
>         +    CU_ASSERT(0 == status);
>         +
>         +    status = odp_term_global();
>         +    CU_ASSERT(0 == status);
>         +    return;
>         +}
>         +
>         +
>         +
>         +static int init(void)
>         +{
>         +    printf("\tODP version: %s\n", odp_version_api_str());
>         +    return 0;
>         +}
>         +
>         +static int finalize(void)
>         +{
>         +    return 0;
>         +}
>         +
>         +int main(void)
>         +{
>         +    CU_pSuite ptr_suite = NULL;
>         +    /* initialize the CUnit test registry */
>         +    if (CUE_SUCCESS != CU_initialize_registry())
>         +        return CU_get_error();
>         +
>         +    ptr_suite = CU_add_suite("odp queue", init, finalize);
>         +    if (NULL == ptr_suite) {
>         +        CU_cleanup_registry();
>         +        return CU_get_error();
>         +    }
>         +
>         +    /* add the tests to the queue suite */
>         +    if (NULL == CU_ADD_TEST(ptr_suite, test_odp_queue)) {
>         +        CU_cleanup_registry();
>         +        return CU_get_error();
>         +    }
>         +
>         +    /* Run all tests using the CUnit Basic interface */
>         +    CU_basic_set_mode(CU_BRM_VERBOSE);
>         +    CU_basic_run_tests();
>         +    CU_cleanup_registry();
>         +    return CU_get_error();
>         +}
>         +
>         -- 
>         1.8.3.1
>
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
yan.songming Nov. 3, 2014, 9:15 a.m. UTC | #2
Hi Maxim,

Thanks for you advice.

2.  If you have any changes from previouse patch. Just open generated
patch and add you comments after "--".

 like this ?
>         

>         cunit queue test to test_odp_queue_base for none syn queue.   <-- this comments should be the same as the previouse patch ?

>         Signed-off-by: Yan Songming <yan.songming@linaro.org>

>         ---

>           Fix spelling problem. Add term_local and term_global. Move     <--add comments here when i have any  changes from previouse patch ?

>           cunit queue test to test_odp_queue_base for none syn queue.

>         test/cunit/Makefile.am      |   4 +-

>         test/cunit/odp_queue_test.c | 168



yan.songming@linaro.org
 
From: Maxim Uvarov

Date: 2014-11-01 18:15
To: lng-odp
Subject: Re: [lng-odp] [PATCH v2] add tests for queue
Hello Yan,
 
few notes about sending patches.
1. pelase use 'git send-email' command.
2.  If you have any changes from previouse patch. Just open generated 
patch and add you comments after "--".
In that case when I do git am that lines will be skipped.
3. git commits usually look like:
short subject
<empty line>
long description
sign-off.
 
Thanks,
Maxim.
 
On 11/01/2014 04:44 AM, yan.songming@linaro.org wrote:
>

>         Fix spelling problem. Add term_local and term_global. Move

>         cunit queue test to test_odp_queue_base for none syn queue.

>         Signed-off-by: Yan Songming <yan.songming@linaro.org>

>         ---

>         test/cunit/Makefile.am      |   4 +-

>         test/cunit/odp_queue_test.c | 168

>         ++++++++++++++++++++++++++++++++++++++++++++

>         2 files changed, 171 insertions(+), 1 deletion(-)

>         create mode 100644 test/cunit/odp_queue_test.c

>         diff --git a/test/cunit/Makefile.am b/test/cunit/Makefile.am

>         index 927a5a5..46f46c9 100644

>         --- a/test/cunit/Makefile.am

>         +++ b/test/cunit/Makefile.am

>         @@ -6,8 +6,10 @@ AM_LDFLAGS += -L$(CUNIT_PATH)/lib

>         if ODP_CUNIT_ENABLED

>         TESTS = ${bin_PROGRAMS}

>         check_PROGRAMS = ${bin_PROGRAMS}

>         -bin_PROGRAMS = odp_init

>         +bin_PROGRAMS = odp_init odp_queue

>         odp_init_LDFLAGS = $(AM_LDFLAGS) -static -lcunit

>         +odp_queue_LDFLAGS = $(AM_LDFLAGS) -static -lcunit

>         endif

>         +dist_odp_queue_SOURCES = odp_queue_test.c

>         dist_odp_init_SOURCES = odp_init_test.c

>         diff --git a/test/cunit/odp_queue_test.c

>         b/test/cunit/odp_queue_test.c

>         new file mode 100644

>         index 0000000..04342a6

>         --- /dev/null

>         +++ b/test/cunit/odp_queue_test.c

>         @@ -0,0 +1,168 @@

>         +/* Copyright (c) 2014, Linaro Limited

>         + * All rights reserved.

>         + *

>         + * SPDX-License-Identifier:     BSD-3-Clause

>         + */

>         +

>         +#include "odp.h"

>         +#include "CUnit/Basic.h"

>         +

>         +#define MAX_BUFFER_QUEUE        (8) /**< Max enqueue buf num */

>         +#define MSG_POOL_SIZE           (4*1024*1024) /**< Message

>         pool size */

>         +

>         +static int Queue_Contest = 0xff;

>         +

>         +static int test_odp_buffer_pool_init(void)

>         +{

>         +    odp_buffer_pool_t pool;

>         +    void *pool_base;

>         +    odp_shm_t shm;

>         +

>         +    shm = odp_shm_reserve("msg_pool",

>         +                          MSG_POOL_SIZE, ODP_CACHE_LINE_SIZE, 0);

>         +

>         +    pool_base = odp_shm_addr(shm);

>         +

>         +    if (pool_base == NULL) {

>         +        printf("Shared memory reserve failed.\n");

>         +        return -1;

>         +    }

>         +

>         +    pool = odp_buffer_pool_create("msg_pool", pool_base,

>         MSG_POOL_SIZE,

>         +                                  0,

>         + ODP_CACHE_LINE_SIZE, ODP_BUFFER_TYPE_RAW);

>         +

>         +    if (pool == ODP_BUFFER_POOL_INVALID) {

>         +        printf("Pool create failed.\n");

>         +        return -1;

>         +    }

>         +    return 0;

>         +}

>         +

>         +static void test_odp_queue_base(void)

>         +{

>         +    odp_queue_t       queue_creat_id;

>         +    odp_queue_t       queue_id;

>         +    odp_buffer_t      Enbuf[MAX_BUFFER_QUEUE];

>         +    odp_buffer_t      Debuf[MAX_BUFFER_QUEUE];

>         +    odp_buffer_pool_t msg_pool;

>         +    odp_queue_param_t param;

>         +

>         +    int          i;

>         +    odp_buffer_t buf;

>         +    void         *pRtn = NULL;

>         +

>         +    /* test odp_queue_create */

>         +    memset(&param, 0, sizeof(param));

>         +    param.sched.sync  = ODP_SCHED_SYNC_NONE;

>         +

>         +    queue_creat_id = odp_queue_create("test_queue",

>         ODP_QUEUE_TYPE_POLL, &param);

>         +    CU_ASSERT(ODP_QUEUE_INVALID != queue_creat_id);

>         +

>         +    /* test odp_queue_type */

>         +    CU_ASSERT_EQUAL(ODP_QUEUE_TYPE_POLL,

>         odp_queue_type(queue_creat_id));

>         +

>         +    /* test odp_queue_type */

>         +    CU_ASSERT_EQUAL(ODP_SCHED_SYNC_NONE,

>         odp_queue_sched_type(queue_creat_id));

>         +

>         +    /* test odp_queue_lookup */

>         +    queue_id = odp_queue_lookup("test_queue");

>         +    CU_ASSERT_EQUAL(queue_creat_id, queue_id);

>         +

>         +    /* test odp_queue_set_context */

>         +    CU_ASSERT(0 == odp_queue_set_context(queue_id,

>         &Queue_Contest));

>         +

>         +    /* test  odp_queue_get_context*/

>         +    pRtn = odp_queue_get_context(queue_id);

>         +    CU_ASSERT(&Queue_Contest == (int *)pRtn);

>         +

>         +    /* apply for buffer */

>         +    msg_pool = odp_buffer_pool_lookup("msg_pool");

>         +    buf = odp_buffer_alloc(msg_pool);

>         +

>         +    /* test  odp_queue_enq and odp_queue_deq */

>         +    odp_queue_enq(queue_id, buf);

>         +    CU_ASSERT_EQUAL(buf, odp_queue_deq(queue_id));

>         +    odp_buffer_free(buf);

>         +

>         +    /* apply for mutili buffer */

>         +    for(i=0; i<MAX_BUFFER_QUEUE; i++) {

>         +        Enbuf[i] = odp_buffer_alloc(msg_pool);

>         +    }

>         +

>         +    /* test odp_queue_enq_multi  and odp_queue_enq_multi */

>         +    odp_queue_enq_multi(queue_id, Enbuf, MAX_BUFFER_QUEUE);

>         +    odp_queue_deq_multi(queue_id, Debuf, MAX_BUFFER_QUEUE);

>         +

>         +    for(i=0; i<MAX_BUFFER_QUEUE; i++) {

>         +        /* test odp_queue_deq_multi */

>         +        CU_ASSERT_EQUAL(Enbuf[i], Debuf[i]);

>         +        /*  buffer free */

>         +        odp_buffer_free(Enbuf[i]);

>         +    }

>         +    return;

>         +

>         +}

>         +

>         +static void test_odp_queue(void)

>         +{

>         +

>         +    int status;

>         +    status = odp_init_global(NULL, NULL);

>         +    CU_ASSERT_FATAL(0 == status);

>         +

>         +    CU_ASSERT(0 == odp_init_local())

>         +

>         +    /* initialize  buffer pool */

>         +    CU_ASSERT_FATAL(0 == test_odp_buffer_pool_init());

>         +

>         +    /* test odp none syne queue   */

>         +    test_odp_queue_base();

>         +

>         +    status = odp_term_local();

>         +    CU_ASSERT(0 == status);

>         +

>         +    status = odp_term_global();

>         +    CU_ASSERT(0 == status);

>         +    return;

>         +}

>         +

>         +

>         +

>         +static int init(void)

>         +{

>         +    printf("\tODP version: %s\n", odp_version_api_str());

>         +    return 0;

>         +}

>         +

>         +static int finalize(void)

>         +{

>         +    return 0;

>         +}

>         +

>         +int main(void)

>         +{

>         +    CU_pSuite ptr_suite = NULL;

>         +    /* initialize the CUnit test registry */

>         +    if (CUE_SUCCESS != CU_initialize_registry())

>         +        return CU_get_error();

>         +

>         +    ptr_suite = CU_add_suite("odp queue", init, finalize);

>         +    if (NULL == ptr_suite) {

>         +        CU_cleanup_registry();

>         +        return CU_get_error();

>         +    }

>         +

>         +    /* add the tests to the queue suite */

>         +    if (NULL == CU_ADD_TEST(ptr_suite, test_odp_queue)) {

>         +        CU_cleanup_registry();

>         +        return CU_get_error();

>         +    }

>         +

>         +    /* Run all tests using the CUnit Basic interface */

>         +    CU_basic_set_mode(CU_BRM_VERBOSE);

>         +    CU_basic_run_tests();

>         +    CU_cleanup_registry();

>         +    return CU_get_error();

>         +}

>         +

>         -- 

>         1.8.3.1

>

>

>

> _______________________________________________

> lng-odp mailing list

> lng-odp@lists.linaro.org

> http://lists.linaro.org/mailman/listinfo/lng-odp

 
 
_______________________________________________
lng-odp mailing list
lng-odp@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/lng-odp
Hongbo Zhang Nov. 3, 2014, 9:39 a.m. UTC | #3
Yan, for discussing patches, it is better to set your mail client to plain
text only mode.

On 3 November 2014 17:15, yan.songming@linaro.org <yan.songming@linaro.org>
wrote:

> Hi Maxim,
>
> Thanks for you advice.
>
> 2.  If you have any changes from previouse patch. Just open generated
> patch and add you comments after "--".
>
>  like this ?
> >
> >       *  cunit queue test to test_odp_queue_base for none syn queue.
> <-- this **comments **should be the same as the **previouse patch** ?*
>

It is up to you, you can describe what you want.



> >         Signed-off-by: Yan Songming <yan.songming@linaro.org>
> >         ---
> >           *Fix spelling problem. Add term_local and term_global. Move
>   <--add comments here when i have any * *changes from previouse patch ?*
> >          * cunit queue test to test_odp_queue_base for none syn queue.*
>

Another "---" is needed here I think.
Then anything between these two "---" won't be merged into git tree.
(hope I remember correct, I used cover letter for history description)

>         test/cunit/Makefile.am      |   4 +-
> >         test/cunit/odp_queue_test.c | 168
> ------------------------------
> yan.songming@linaro.org
>
>
> *From:* Maxim Uvarov <maxim.uvarov@linaro.org>
> *Date:* 2014-11-01 18:15
> *To:* lng-odp <lng-odp@lists.linaro.org>
> *Subject:* Re: [lng-odp] [PATCH v2] add tests for queue
> Hello Yan,
>
> few notes about sending patches.
> 1. pelase use 'git send-email' command.
> 2.  If you have any changes from previouse patch. Just open generated
> patch and add you comments after "--".
> In that case when I do git am that lines will be skipped.
> 3. git commits usually look like:
> short subject
> <empty line>
> long description
> sign-off.
>
> Thanks,
> Maxim.
>
> On 11/01/2014 04:44 AM, yan.songming@linaro.org wrote:
> >
> >         Fix spelling problem. Add term_local and term_global. Move
> >         cunit queue test to test_odp_queue_base for none syn queue.
> >         Signed-off-by: Yan Songming <yan.songming@linaro.org>
> >         ---
> >         test/cunit/Makefile.am      |   4 +-
> >         test/cunit/odp_queue_test.c | 168
> >         ++++++++++++++++++++++++++++++++++++++++++++
> >         2 files changed, 171 insertions(+), 1 deletion(-)
> >         create mode 100644 test/cunit/odp_queue_test.c
> >         diff --git a/test/cunit/Makefile.am b/test/cunit/Makefile.am
> >         index 927a5a5..46f46c9 100644
> >         --- a/test/cunit/Makefile.am
> >         +++ b/test/cunit/Makefile.am
> >         @@ -6,8 +6,10 @@ AM_LDFLAGS += -L$(CUNIT_PATH)/lib
> >         if ODP_CUNIT_ENABLED
> >         TESTS = ${bin_PROGRAMS}
> >         check_PROGRAMS = ${bin_PROGRAMS}
> >         -bin_PROGRAMS = odp_init
> >         +bin_PROGRAMS = odp_init odp_queue
> >         odp_init_LDFLAGS = $(AM_LDFLAGS) -static -lcunit
> >         +odp_queue_LDFLAGS = $(AM_LDFLAGS) -static -lcunit
> >         endif
> >         +dist_odp_queue_SOURCES = odp_queue_test.c
> >         dist_odp_init_SOURCES = odp_init_test.c
> >         diff --git a/test/cunit/odp_queue_test.c
> >         b/test/cunit/odp_queue_test.c
> >         new file mode 100644
> >         index 0000000..04342a6
> >         --- /dev/null
> >         +++ b/test/cunit/odp_queue_test.c
> >         @@ -0,0 +1,168 @@
> >         +/* Copyright (c) 2014, Linaro Limited
> >         + * All rights reserved.
> >         + *
> >         + * SPDX-License-Identifier:     BSD-3-Clause
> >         + */
> >         +
> >         +#include "odp.h"
> >         +#include "CUnit/Basic.h"
> >         +
> >         +#define MAX_BUFFER_QUEUE        (8) /**< Max enqueue buf num */
> >         +#define MSG_POOL_SIZE           (4*1024*1024) /**< Message
> >         pool size */
> >         +
> >         +static int Queue_Contest = 0xff;
> >         +
> >         +static int test_odp_buffer_pool_init(void)
> >         +{
> >         +    odp_buffer_pool_t pool;
> >         +    void *pool_base;
> >         +    odp_shm_t shm;
> >         +
> >         +    shm = odp_shm_reserve("msg_pool",
> >         +                          MSG_POOL_SIZE, ODP_CACHE_LINE_SIZE,
> 0);
> >         +
> >         +    pool_base = odp_shm_addr(shm);
> >         +
> >         +    if (pool_base == NULL) {
> >         +        printf("Shared memory reserve failed.\n");
> >         +        return -1;
> >         +    }
> >         +
> >         +    pool = odp_buffer_pool_create("msg_pool", pool_base,
> >         MSG_POOL_SIZE,
> >         +                                  0,
> >         + ODP_CACHE_LINE_SIZE, ODP_BUFFER_TYPE_RAW);
> >         +
> >         +    if (pool == ODP_BUFFER_POOL_INVALID) {
> >         +        printf("Pool create failed.\n");
> >         +        return -1;
> >         +    }
> >         +    return 0;
> >         +}
> >         +
> >         +static void test_odp_queue_base(void)
> >         +{
> >         +    odp_queue_t       queue_creat_id;
> >         +    odp_queue_t       queue_id;
> >         +    odp_buffer_t      Enbuf[MAX_BUFFER_QUEUE];
> >         +    odp_buffer_t      Debuf[MAX_BUFFER_QUEUE];
> >         +    odp_buffer_pool_t msg_pool;
> >         +    odp_queue_param_t param;
> >         +
> >         +    int          i;
> >         +    odp_buffer_t buf;
> >         +    void         *pRtn = NULL;
> >         +
> >         +    /* test odp_queue_create */
> >         +    memset(&param, 0, sizeof(param));
> >         +    param.sched.sync  = ODP_SCHED_SYNC_NONE;
> >         +
> >         +    queue_creat_id = odp_queue_create("test_queue",
> >         ODP_QUEUE_TYPE_POLL, &param);
> >         +    CU_ASSERT(ODP_QUEUE_INVALID != queue_creat_id);
> >         +
> >         +    /* test odp_queue_type */
> >         +    CU_ASSERT_EQUAL(ODP_QUEUE_TYPE_POLL,
> >         odp_queue_type(queue_creat_id));
> >         +
> >         +    /* test odp_queue_type */
> >         +    CU_ASSERT_EQUAL(ODP_SCHED_SYNC_NONE,
> >         odp_queue_sched_type(queue_creat_id));
> >         +
> >         +    /* test odp_queue_lookup */
> >         +    queue_id = odp_queue_lookup("test_queue");
> >         +    CU_ASSERT_EQUAL(queue_creat_id, queue_id);
> >         +
> >         +    /* test odp_queue_set_context */
> >         +    CU_ASSERT(0 == odp_queue_set_context(queue_id,
> >         &Queue_Contest));
> >         +
> >         +    /* test  odp_queue_get_context*/
> >         +    pRtn = odp_queue_get_context(queue_id);
> >         +    CU_ASSERT(&Queue_Contest == (int *)pRtn);
> >         +
> >         +    /* apply for buffer */
> >         +    msg_pool = odp_buffer_pool_lookup("msg_pool");
> >         +    buf = odp_buffer_alloc(msg_pool);
> >         +
> >         +    /* test  odp_queue_enq and odp_queue_deq */
> >         +    odp_queue_enq(queue_id, buf);
> >         +    CU_ASSERT_EQUAL(buf, odp_queue_deq(queue_id));
> >         +    odp_buffer_free(buf);
> >         +
> >         +    /* apply for mutili buffer */
> >         +    for(i=0; i<MAX_BUFFER_QUEUE; i++) {
> >         +        Enbuf[i] = odp_buffer_alloc(msg_pool);
> >         +    }
> >         +
> >         +    /* test odp_queue_enq_multi  and odp_queue_enq_multi */
> >         +    odp_queue_enq_multi(queue_id, Enbuf, MAX_BUFFER_QUEUE);
> >         +    odp_queue_deq_multi(queue_id, Debuf, MAX_BUFFER_QUEUE);
> >         +
> >         +    for(i=0; i<MAX_BUFFER_QUEUE; i++) {
> >         +        /* test odp_queue_deq_multi */
> >         +        CU_ASSERT_EQUAL(Enbuf[i], Debuf[i]);
> >         +        /*  buffer free */
> >         +        odp_buffer_free(Enbuf[i]);
> >         +    }
> >         +    return;
> >         +
> >         +}
> >         +
> >         +static void test_odp_queue(void)
> >         +{
> >         +
> >         +    int status;
> >         +    status = odp_init_global(NULL, NULL);
> >         +    CU_ASSERT_FATAL(0 == status);
> >         +
> >         +    CU_ASSERT(0 == odp_init_local())
> >         +
> >         +    /* initialize  buffer pool */
> >         +    CU_ASSERT_FATAL(0 == test_odp_buffer_pool_init());
> >         +
> >         +    /* test odp none syne queue   */
> >         +    test_odp_queue_base();
> >         +
> >         +    status = odp_term_local();
> >         +    CU_ASSERT(0 == status);
> >         +
> >         +    status = odp_term_global();
> >         +    CU_ASSERT(0 == status);
> >         +    return;
> >         +}
> >         +
> >         +
> >         +
> >         +static int init(void)
> >         +{
> >         +    printf("\tODP version: %s\n", odp_version_api_str());
> >         +    return 0;
> >         +}
> >         +
> >         +static int finalize(void)
> >         +{
> >         +    return 0;
> >         +}
> >         +
> >         +int main(void)
> >         +{
> >         +    CU_pSuite ptr_suite = NULL;
> >         +    /* initialize the CUnit test registry */
> >         +    if (CUE_SUCCESS != CU_initialize_registry())
> >         +        return CU_get_error();
> >         +
> >         +    ptr_suite = CU_add_suite("odp queue", init, finalize);
> >         +    if (NULL == ptr_suite) {
> >         +        CU_cleanup_registry();
> >         +        return CU_get_error();
> >         +    }
> >         +
> >         +    /* add the tests to the queue suite */
> >         +    if (NULL == CU_ADD_TEST(ptr_suite, test_odp_queue)) {
> >         +        CU_cleanup_registry();
> >         +        return CU_get_error();
> >         +    }
> >         +
> >         +    /* Run all tests using the CUnit Basic interface */
> >         +    CU_basic_set_mode(CU_BRM_VERBOSE);
> >         +    CU_basic_run_tests();
> >         +    CU_cleanup_registry();
> >         +    return CU_get_error();
> >         +}
> >         +
> >         --
> >         1.8.3.1
> >
> >
> >
> > _______________________________________________
> > lng-odp mailing list
> > lng-odp@lists.linaro.org
> > http://lists.linaro.org/mailman/listinfo/lng-odp
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
>
Hongbo Zhang Nov. 3, 2014, 9:46 a.m. UTC | #4
Yan,
Search this patch in you mail for example:
[PATCH] Scheduler atomic and ordered definitions

On 3 November 2014 17:15, yan.songming@linaro.org <yan.songming@linaro.org>
wrote:

> Hi Maxim,
>
> Thanks for you advice.
>
> 2.  If you have any changes from previouse patch. Just open generated
> patch and add you comments after "--".
>
>  like this ?
> >
> >       *  cunit queue test to test_odp_queue_base for none syn queue.
> <-- this **comments **should be the same as the **previouse patch** ?*
> >         Signed-off-by: Yan Songming <yan.songming@linaro.org>
> >         ---
> >           *Fix spelling problem. Add term_local and term_global. Move
>   <--add comments here when i have any * *changes from previouse patch ?*
> >          * cunit queue test to test_odp_queue_base for none syn queue.*
> >         test/cunit/Makefile.am      |   4 +-
> >         test/cunit/odp_queue_test.c | 168
> ------------------------------
> yan.songming@linaro.org
>
>
> *From:* Maxim Uvarov <maxim.uvarov@linaro.org>
> *Date:* 2014-11-01 18:15
> *To:* lng-odp <lng-odp@lists.linaro.org>
> *Subject:* Re: [lng-odp] [PATCH v2] add tests for queue
> Hello Yan,
>
> few notes about sending patches.
> 1. pelase use 'git send-email' command.
> 2.  If you have any changes from previouse patch. Just open generated
> patch and add you comments after "--".
> In that case when I do git am that lines will be skipped.
> 3. git commits usually look like:
> short subject
> <empty line>
> long description
> sign-off.
>
> Thanks,
> Maxim.
>
> On 11/01/2014 04:44 AM, yan.songming@linaro.org wrote:
> >
> >         Fix spelling problem. Add term_local and term_global. Move
> >         cunit queue test to test_odp_queue_base for none syn queue.
> >         Signed-off-by: Yan Songming <yan.songming@linaro.org>
> >         ---
> >         test/cunit/Makefile.am      |   4 +-
> >         test/cunit/odp_queue_test.c | 168
> >         ++++++++++++++++++++++++++++++++++++++++++++
> >         2 files changed, 171 insertions(+), 1 deletion(-)
> >         create mode 100644 test/cunit/odp_queue_test.c
> >         diff --git a/test/cunit/Makefile.am b/test/cunit/Makefile.am
> >         index 927a5a5..46f46c9 100644
> >         --- a/test/cunit/Makefile.am
> >         +++ b/test/cunit/Makefile.am
> >         @@ -6,8 +6,10 @@ AM_LDFLAGS += -L$(CUNIT_PATH)/lib
> >         if ODP_CUNIT_ENABLED
> >         TESTS = ${bin_PROGRAMS}
> >         check_PROGRAMS = ${bin_PROGRAMS}
> >         -bin_PROGRAMS = odp_init
> >         +bin_PROGRAMS = odp_init odp_queue
> >         odp_init_LDFLAGS = $(AM_LDFLAGS) -static -lcunit
> >         +odp_queue_LDFLAGS = $(AM_LDFLAGS) -static -lcunit
> >         endif
> >         +dist_odp_queue_SOURCES = odp_queue_test.c
> >         dist_odp_init_SOURCES = odp_init_test.c
> >         diff --git a/test/cunit/odp_queue_test.c
> >         b/test/cunit/odp_queue_test.c
> >         new file mode 100644
> >         index 0000000..04342a6
> >         --- /dev/null
> >         +++ b/test/cunit/odp_queue_test.c
> >         @@ -0,0 +1,168 @@
> >         +/* Copyright (c) 2014, Linaro Limited
> >         + * All rights reserved.
> >         + *
> >         + * SPDX-License-Identifier:     BSD-3-Clause
> >         + */
> >         +
> >         +#include "odp.h"
> >         +#include "CUnit/Basic.h"
> >         +
> >         +#define MAX_BUFFER_QUEUE        (8) /**< Max enqueue buf num */
> >         +#define MSG_POOL_SIZE           (4*1024*1024) /**< Message
> >         pool size */
> >         +
> >         +static int Queue_Contest = 0xff;
> >         +
> >         +static int test_odp_buffer_pool_init(void)
> >         +{
> >         +    odp_buffer_pool_t pool;
> >         +    void *pool_base;
> >         +    odp_shm_t shm;
> >         +
> >         +    shm = odp_shm_reserve("msg_pool",
> >         +                          MSG_POOL_SIZE, ODP_CACHE_LINE_SIZE,
> 0);
> >         +
> >         +    pool_base = odp_shm_addr(shm);
> >         +
> >         +    if (pool_base == NULL) {
> >         +        printf("Shared memory reserve failed.\n");
> >         +        return -1;
> >         +    }
> >         +
> >         +    pool = odp_buffer_pool_create("msg_pool", pool_base,
> >         MSG_POOL_SIZE,
> >         +                                  0,
> >         + ODP_CACHE_LINE_SIZE, ODP_BUFFER_TYPE_RAW);
> >         +
> >         +    if (pool == ODP_BUFFER_POOL_INVALID) {
> >         +        printf("Pool create failed.\n");
> >         +        return -1;
> >         +    }
> >         +    return 0;
> >         +}
> >         +
> >         +static void test_odp_queue_base(void)
> >         +{
> >         +    odp_queue_t       queue_creat_id;
> >         +    odp_queue_t       queue_id;
> >         +    odp_buffer_t      Enbuf[MAX_BUFFER_QUEUE];
> >         +    odp_buffer_t      Debuf[MAX_BUFFER_QUEUE];
> >         +    odp_buffer_pool_t msg_pool;
> >         +    odp_queue_param_t param;
> >         +
> >         +    int          i;
> >         +    odp_buffer_t buf;
> >         +    void         *pRtn = NULL;
> >         +
> >         +    /* test odp_queue_create */
> >         +    memset(&param, 0, sizeof(param));
> >         +    param.sched.sync  = ODP_SCHED_SYNC_NONE;
> >         +
> >         +    queue_creat_id = odp_queue_create("test_queue",
> >         ODP_QUEUE_TYPE_POLL, &param);
> >         +    CU_ASSERT(ODP_QUEUE_INVALID != queue_creat_id);
> >         +
> >         +    /* test odp_queue_type */
> >         +    CU_ASSERT_EQUAL(ODP_QUEUE_TYPE_POLL,
> >         odp_queue_type(queue_creat_id));
> >         +
> >         +    /* test odp_queue_type */
> >         +    CU_ASSERT_EQUAL(ODP_SCHED_SYNC_NONE,
> >         odp_queue_sched_type(queue_creat_id));
> >         +
> >         +    /* test odp_queue_lookup */
> >         +    queue_id = odp_queue_lookup("test_queue");
> >         +    CU_ASSERT_EQUAL(queue_creat_id, queue_id);
> >         +
> >         +    /* test odp_queue_set_context */
> >         +    CU_ASSERT(0 == odp_queue_set_context(queue_id,
> >         &Queue_Contest));
> >         +
> >         +    /* test  odp_queue_get_context*/
> >         +    pRtn = odp_queue_get_context(queue_id);
> >         +    CU_ASSERT(&Queue_Contest == (int *)pRtn);
> >         +
> >         +    /* apply for buffer */
> >         +    msg_pool = odp_buffer_pool_lookup("msg_pool");
> >         +    buf = odp_buffer_alloc(msg_pool);
> >         +
> >         +    /* test  odp_queue_enq and odp_queue_deq */
> >         +    odp_queue_enq(queue_id, buf);
> >         +    CU_ASSERT_EQUAL(buf, odp_queue_deq(queue_id));
> >         +    odp_buffer_free(buf);
> >         +
> >         +    /* apply for mutili buffer */
> >         +    for(i=0; i<MAX_BUFFER_QUEUE; i++) {
> >         +        Enbuf[i] = odp_buffer_alloc(msg_pool);
> >         +    }
> >         +
> >         +    /* test odp_queue_enq_multi  and odp_queue_enq_multi */
> >         +    odp_queue_enq_multi(queue_id, Enbuf, MAX_BUFFER_QUEUE);
> >         +    odp_queue_deq_multi(queue_id, Debuf, MAX_BUFFER_QUEUE);
> >         +
> >         +    for(i=0; i<MAX_BUFFER_QUEUE; i++) {
> >         +        /* test odp_queue_deq_multi */
> >         +        CU_ASSERT_EQUAL(Enbuf[i], Debuf[i]);
> >         +        /*  buffer free */
> >         +        odp_buffer_free(Enbuf[i]);
> >         +    }
> >         +    return;
> >         +
> >         +}
> >         +
> >         +static void test_odp_queue(void)
> >         +{
> >         +
> >         +    int status;
> >         +    status = odp_init_global(NULL, NULL);
> >         +    CU_ASSERT_FATAL(0 == status);
> >         +
> >         +    CU_ASSERT(0 == odp_init_local())
> >         +
> >         +    /* initialize  buffer pool */
> >         +    CU_ASSERT_FATAL(0 == test_odp_buffer_pool_init());
> >         +
> >         +    /* test odp none syne queue   */
> >         +    test_odp_queue_base();
> >         +
> >         +    status = odp_term_local();
> >         +    CU_ASSERT(0 == status);
> >         +
> >         +    status = odp_term_global();
> >         +    CU_ASSERT(0 == status);
> >         +    return;
> >         +}
> >         +
> >         +
> >         +
> >         +static int init(void)
> >         +{
> >         +    printf("\tODP version: %s\n", odp_version_api_str());
> >         +    return 0;
> >         +}
> >         +
> >         +static int finalize(void)
> >         +{
> >         +    return 0;
> >         +}
> >         +
> >         +int main(void)
> >         +{
> >         +    CU_pSuite ptr_suite = NULL;
> >         +    /* initialize the CUnit test registry */
> >         +    if (CUE_SUCCESS != CU_initialize_registry())
> >         +        return CU_get_error();
> >         +
> >         +    ptr_suite = CU_add_suite("odp queue", init, finalize);
> >         +    if (NULL == ptr_suite) {
> >         +        CU_cleanup_registry();
> >         +        return CU_get_error();
> >         +    }
> >         +
> >         +    /* add the tests to the queue suite */
> >         +    if (NULL == CU_ADD_TEST(ptr_suite, test_odp_queue)) {
> >         +        CU_cleanup_registry();
> >         +        return CU_get_error();
> >         +    }
> >         +
> >         +    /* Run all tests using the CUnit Basic interface */
> >         +    CU_basic_set_mode(CU_BRM_VERBOSE);
> >         +    CU_basic_run_tests();
> >         +    CU_cleanup_registry();
> >         +    return CU_get_error();
> >         +}
> >         +
> >         --
> >         1.8.3.1
> >
> >
> >
> > _______________________________________________
> > lng-odp mailing list
> > lng-odp@lists.linaro.org
> > http://lists.linaro.org/mailman/listinfo/lng-odp
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
>
yan.songming Nov. 3, 2014, 2:40 p.m. UTC | #5
Hongbo,
I find it . And It do help me know how to add the commends. 
Thanks.


yan.songming@linaro.org
 
From: Hongbo Zhang

Date: 2014-11-03 17:46
To: yan.songming@linaro.org
CC: maxim.uvarov; lng-odp
Subject: Re: Re: [lng-odp] [PATCH v2] add tests for queue
Yan,
Search this patch in you mail for example:
[PATCH] Scheduler atomic and ordered definitions

On 3 November 2014 17:15, yan.songming@linaro.org <yan.songming@linaro.org> wrote:
Hi Maxim,

Thanks for you advice.

2.  If you have any changes from previouse patch. Just open generated
patch and add you comments after "--".

 like this ?
>         

>         cunit queue test to test_odp_queue_base for none syn queue.   <-- this comments should be the same as the previouse patch ?

>         Signed-off-by: Yan Songming <yan.songming@linaro.org>

>         ---

>           Fix spelling problem. Add term_local and term_global. Move     <--add comments here when i have any  changes from previouse patch ?

>           cunit queue test to test_odp_queue_base for none syn queue.

>         test/cunit/Makefile.am      |   4 +-

>         test/cunit/odp_queue_test.c | 168



yan.songming@linaro.org
 
From: Maxim Uvarov

Date: 2014-11-01 18:15
To: lng-odp
Subject: Re: [lng-odp] [PATCH v2] add tests for queue
Hello Yan,
 
few notes about sending patches.
1. pelase use 'git send-email' command.
2.  If you have any changes from previouse patch. Just open generated 
patch and add you comments after "--".
In that case when I do git am that lines will be skipped.
3. git commits usually look like:
short subject
<empty line>
long description
sign-off.
 
Thanks,
Maxim.
 
On 11/01/2014 04:44 AM, yan.songming@linaro.org wrote:
>

>         Fix spelling problem. Add term_local and term_global. Move

>         cunit queue test to test_odp_queue_base for none syn queue.

>         Signed-off-by: Yan Songming <yan.songming@linaro.org>

>         ---

>         test/cunit/Makefile.am      |   4 +-

>         test/cunit/odp_queue_test.c | 168

>         ++++++++++++++++++++++++++++++++++++++++++++

>         2 files changed, 171 insertions(+), 1 deletion(-)

>         create mode 100644 test/cunit/odp_queue_test.c

>         diff --git a/test/cunit/Makefile.am b/test/cunit/Makefile.am

>         index 927a5a5..46f46c9 100644

>         --- a/test/cunit/Makefile.am

>         +++ b/test/cunit/Makefile.am

>         @@ -6,8 +6,10 @@ AM_LDFLAGS += -L$(CUNIT_PATH)/lib

>         if ODP_CUNIT_ENABLED

>         TESTS = ${bin_PROGRAMS}

>         check_PROGRAMS = ${bin_PROGRAMS}

>         -bin_PROGRAMS = odp_init

>         +bin_PROGRAMS = odp_init odp_queue

>         odp_init_LDFLAGS = $(AM_LDFLAGS) -static -lcunit

>         +odp_queue_LDFLAGS = $(AM_LDFLAGS) -static -lcunit

>         endif

>         +dist_odp_queue_SOURCES = odp_queue_test.c

>         dist_odp_init_SOURCES = odp_init_test.c

>         diff --git a/test/cunit/odp_queue_test.c

>         b/test/cunit/odp_queue_test.c

>         new file mode 100644

>         index 0000000..04342a6

>         --- /dev/null

>         +++ b/test/cunit/odp_queue_test.c

>         @@ -0,0 +1,168 @@

>         +/* Copyright (c) 2014, Linaro Limited

>         + * All rights reserved.

>         + *

>         + * SPDX-License-Identifier:     BSD-3-Clause

>         + */

>         +

>         +#include "odp.h"

>         +#include "CUnit/Basic.h"

>         +

>         +#define MAX_BUFFER_QUEUE        (8) /**< Max enqueue buf num */

>         +#define MSG_POOL_SIZE           (4*1024*1024) /**< Message

>         pool size */

>         +

>         +static int Queue_Contest = 0xff;

>         +

>         +static int test_odp_buffer_pool_init(void)

>         +{

>         +    odp_buffer_pool_t pool;

>         +    void *pool_base;

>         +    odp_shm_t shm;

>         +

>         +    shm = odp_shm_reserve("msg_pool",

>         +                          MSG_POOL_SIZE, ODP_CACHE_LINE_SIZE, 0);

>         +

>         +    pool_base = odp_shm_addr(shm);

>         +

>         +    if (pool_base == NULL) {

>         +        printf("Shared memory reserve failed.\n");

>         +        return -1;

>         +    }

>         +

>         +    pool = odp_buffer_pool_create("msg_pool", pool_base,

>         MSG_POOL_SIZE,

>         +                                  0,

>         + ODP_CACHE_LINE_SIZE, ODP_BUFFER_TYPE_RAW);

>         +

>         +    if (pool == ODP_BUFFER_POOL_INVALID) {

>         +        printf("Pool create failed.\n");

>         +        return -1;

>         +    }

>         +    return 0;

>         +}

>         +

>         +static void test_odp_queue_base(void)

>         +{

>         +    odp_queue_t       queue_creat_id;

>         +    odp_queue_t       queue_id;

>         +    odp_buffer_t      Enbuf[MAX_BUFFER_QUEUE];

>         +    odp_buffer_t      Debuf[MAX_BUFFER_QUEUE];

>         +    odp_buffer_pool_t msg_pool;

>         +    odp_queue_param_t param;

>         +

>         +    int          i;

>         +    odp_buffer_t buf;

>         +    void         *pRtn = NULL;

>         +

>         +    /* test odp_queue_create */

>         +    memset(&param, 0, sizeof(param));

>         +    param.sched.sync  = ODP_SCHED_SYNC_NONE;

>         +

>         +    queue_creat_id = odp_queue_create("test_queue",

>         ODP_QUEUE_TYPE_POLL, &param);

>         +    CU_ASSERT(ODP_QUEUE_INVALID != queue_creat_id);

>         +

>         +    /* test odp_queue_type */

>         +    CU_ASSERT_EQUAL(ODP_QUEUE_TYPE_POLL,

>         odp_queue_type(queue_creat_id));

>         +

>         +    /* test odp_queue_type */

>         +    CU_ASSERT_EQUAL(ODP_SCHED_SYNC_NONE,

>         odp_queue_sched_type(queue_creat_id));

>         +

>         +    /* test odp_queue_lookup */

>         +    queue_id = odp_queue_lookup("test_queue");

>         +    CU_ASSERT_EQUAL(queue_creat_id, queue_id);

>         +

>         +    /* test odp_queue_set_context */

>         +    CU_ASSERT(0 == odp_queue_set_context(queue_id,

>         &Queue_Contest));

>         +

>         +    /* test  odp_queue_get_context*/

>         +    pRtn = odp_queue_get_context(queue_id);

>         +    CU_ASSERT(&Queue_Contest == (int *)pRtn);

>         +

>         +    /* apply for buffer */

>         +    msg_pool = odp_buffer_pool_lookup("msg_pool");

>         +    buf = odp_buffer_alloc(msg_pool);

>         +

>         +    /* test  odp_queue_enq and odp_queue_deq */

>         +    odp_queue_enq(queue_id, buf);

>         +    CU_ASSERT_EQUAL(buf, odp_queue_deq(queue_id));

>         +    odp_buffer_free(buf);

>         +

>         +    /* apply for mutili buffer */

>         +    for(i=0; i<MAX_BUFFER_QUEUE; i++) {

>         +        Enbuf[i] = odp_buffer_alloc(msg_pool);

>         +    }

>         +

>         +    /* test odp_queue_enq_multi  and odp_queue_enq_multi */

>         +    odp_queue_enq_multi(queue_id, Enbuf, MAX_BUFFER_QUEUE);

>         +    odp_queue_deq_multi(queue_id, Debuf, MAX_BUFFER_QUEUE);

>         +

>         +    for(i=0; i<MAX_BUFFER_QUEUE; i++) {

>         +        /* test odp_queue_deq_multi */

>         +        CU_ASSERT_EQUAL(Enbuf[i], Debuf[i]);

>         +        /*  buffer free */

>         +        odp_buffer_free(Enbuf[i]);

>         +    }

>         +    return;

>         +

>         +}

>         +

>         +static void test_odp_queue(void)

>         +{

>         +

>         +    int status;

>         +    status = odp_init_global(NULL, NULL);

>         +    CU_ASSERT_FATAL(0 == status);

>         +

>         +    CU_ASSERT(0 == odp_init_local())

>         +

>         +    /* initialize  buffer pool */

>         +    CU_ASSERT_FATAL(0 == test_odp_buffer_pool_init());

>         +

>         +    /* test odp none syne queue   */

>         +    test_odp_queue_base();

>         +

>         +    status = odp_term_local();

>         +    CU_ASSERT(0 == status);

>         +

>         +    status = odp_term_global();

>         +    CU_ASSERT(0 == status);

>         +    return;

>         +}

>         +

>         +

>         +

>         +static int init(void)

>         +{

>         +    printf("\tODP version: %s\n", odp_version_api_str());

>         +    return 0;

>         +}

>         +

>         +static int finalize(void)

>         +{

>         +    return 0;

>         +}

>         +

>         +int main(void)

>         +{

>         +    CU_pSuite ptr_suite = NULL;

>         +    /* initialize the CUnit test registry */

>         +    if (CUE_SUCCESS != CU_initialize_registry())

>         +        return CU_get_error();

>         +

>         +    ptr_suite = CU_add_suite("odp queue", init, finalize);

>         +    if (NULL == ptr_suite) {

>         +        CU_cleanup_registry();

>         +        return CU_get_error();

>         +    }

>         +

>         +    /* add the tests to the queue suite */

>         +    if (NULL == CU_ADD_TEST(ptr_suite, test_odp_queue)) {

>         +        CU_cleanup_registry();

>         +        return CU_get_error();

>         +    }

>         +

>         +    /* Run all tests using the CUnit Basic interface */

>         +    CU_basic_set_mode(CU_BRM_VERBOSE);

>         +    CU_basic_run_tests();

>         +    CU_cleanup_registry();

>         +    return CU_get_error();

>         +}

>         +

>         -- 

>         1.8.3.1

>

>

>

> _______________________________________________

> lng-odp mailing list

> lng-odp@lists.linaro.org

> http://lists.linaro.org/mailman/listinfo/lng-odp

 
 
_______________________________________________
lng-odp mailing list
lng-odp@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/lng-odp
diff mbox

Patch

diff --git a/test/cunit/Makefile.am b/test/cunit/Makefile.am
index 927a5a5..46f46c9 100644
--- a/test/cunit/Makefile.am
+++ b/test/cunit/Makefile.am
@@ -6,8 +6,10 @@  AM_LDFLAGS += -L$(CUNIT_PATH)/lib
if ODP_CUNIT_ENABLED
TESTS = ${bin_PROGRAMS}
check_PROGRAMS = ${bin_PROGRAMS}
-bin_PROGRAMS = odp_init
+bin_PROGRAMS = odp_init odp_queue
odp_init_LDFLAGS = $(AM_LDFLAGS) -static -lcunit
+odp_queue_LDFLAGS = $(AM_LDFLAGS) -static -lcunit
endif
+dist_odp_queue_SOURCES = odp_queue_test.c
dist_odp_init_SOURCES = odp_init_test.c
diff --git a/test/cunit/odp_queue_test.c b/test/cunit/odp_queue_test.c
new file mode 100644
index 0000000..04342a6
--- /dev/null
+++ b/test/cunit/odp_queue_test.c
@@ -0,0 +1,168 @@ 
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+#include "odp.h"
+#include "CUnit/Basic.h"
+
+#define MAX_BUFFER_QUEUE        (8)             /**< Max enqueue buf num */
+#define MSG_POOL_SIZE           (4*1024*1024)   /**< Message pool size */
+
+static int Queue_Contest = 0xff;
+
+static int test_odp_buffer_pool_init(void)
+{
+    odp_buffer_pool_t pool;
+    void *pool_base;
+    odp_shm_t shm;
+
+    shm = odp_shm_reserve("msg_pool",
+                          MSG_POOL_SIZE, ODP_CACHE_LINE_SIZE, 0);
+
+    pool_base = odp_shm_addr(shm);
+
+    if (pool_base == NULL) {
+        printf("Shared memory reserve failed.\n");
+        return -1;
+    }
+
+    pool = odp_buffer_pool_create("msg_pool", pool_base, MSG_POOL_SIZE,
+                                  0,
+                                  ODP_CACHE_LINE_SIZE, ODP_BUFFER_TYPE_RAW);
+
+    if (pool == ODP_BUFFER_POOL_INVALID) {
+        printf("Pool create failed.\n");
+        return -1;
+    }
+    return 0;
+}
+
+static void test_odp_queue_base(void)
+{
+    odp_queue_t       queue_creat_id;
+    odp_queue_t       queue_id;
+    odp_buffer_t      Enbuf[MAX_BUFFER_QUEUE];
+    odp_buffer_t      Debuf[MAX_BUFFER_QUEUE];
+    odp_buffer_pool_t msg_pool;
+    odp_queue_param_t param;
+    
+    int          i;
+    odp_buffer_t buf;
+    void         *pRtn = NULL;
+    
+    /* test odp_queue_create */
+    memset(&param, 0, sizeof(param));
+    param.sched.sync  = ODP_SCHED_SYNC_NONE;
+
+    queue_creat_id = odp_queue_create("test_queue", ODP_QUEUE_TYPE_POLL, &param);
+    CU_ASSERT(ODP_QUEUE_INVALID != queue_creat_id);
+
+    /* test odp_queue_type */
+    CU_ASSERT_EQUAL(ODP_QUEUE_TYPE_POLL, odp_queue_type(queue_creat_id));
+
+    /* test odp_queue_type */
+    CU_ASSERT_EQUAL(ODP_SCHED_SYNC_NONE, odp_queue_sched_type(queue_creat_id));
+
+    /* test odp_queue_lookup */
+    queue_id = odp_queue_lookup("test_queue");
+    CU_ASSERT_EQUAL(queue_creat_id, queue_id); 
+
+    /* test odp_queue_set_context */
+    CU_ASSERT(0 == odp_queue_set_context(queue_id, &Queue_Contest));
+
+    /* test  odp_queue_get_context*/
+    pRtn = odp_queue_get_context(queue_id);
+    CU_ASSERT(&Queue_Contest == (int *)pRtn);
+
+    /* apply for buffer */
+    msg_pool = odp_buffer_pool_lookup("msg_pool");
+    buf = odp_buffer_alloc(msg_pool);
+
+    /* test  odp_queue_enq and odp_queue_deq */
+    odp_queue_enq(queue_id, buf);
+    CU_ASSERT_EQUAL(buf, odp_queue_deq(queue_id));
+    odp_buffer_free(buf);
+
+    /* apply for mutili buffer */
+    for(i=0; i<MAX_BUFFER_QUEUE; i++) {
+        Enbuf[i] = odp_buffer_alloc(msg_pool);
+    }
+
+    /* test odp_queue_enq_multi  and odp_queue_enq_multi */
+    odp_queue_enq_multi(queue_id, Enbuf, MAX_BUFFER_QUEUE);
+    odp_queue_deq_multi(queue_id, Debuf, MAX_BUFFER_QUEUE);
+
+    for(i=0; i<MAX_BUFFER_QUEUE; i++) {
+        /* test odp_queue_deq_multi */
+        CU_ASSERT_EQUAL(Enbuf[i], Debuf[i]);
+        /*  buffer free */
+        odp_buffer_free(Enbuf[i]);
+    }
+    return;
+
+}
+
+static void test_odp_queue(void)
+{
+
+    int status;
+    status = odp_init_global(NULL, NULL);
+    CU_ASSERT_FATAL(0 == status);
+
+    CU_ASSERT(0 == odp_init_local())
+
+    /* initialize  buffer pool */
+    CU_ASSERT_FATAL(0 == test_odp_buffer_pool_init());
+
+    /* test odp none syne queue   */
+    test_odp_queue_base();
+    
+    status = odp_term_local();
+    CU_ASSERT(0 == status);
+    
+    status = odp_term_global();
+    CU_ASSERT(0 == status);
+    return;
+}
+
+
+
+static int init(void)
+{
+    printf("\tODP version: %s\n", odp_version_api_str());
+    return 0;
+}
+
+static int finalize(void)
+{
+    return 0;
+}
+
+int main(void)
+{
+    CU_pSuite ptr_suite = NULL;
+    /* initialize the CUnit test registry */
+    if (CUE_SUCCESS != CU_initialize_registry())
+        return CU_get_error();
+
+    ptr_suite = CU_add_suite("odp queue", init, finalize);
+    if (NULL == ptr_suite) {
+        CU_cleanup_registry();
+        return CU_get_error();
+    }
+
+    /* add the tests to the queue suite */
+    if (NULL == CU_ADD_TEST(ptr_suite, test_odp_queue)) {
+        CU_cleanup_registry();
+        return CU_get_error();
+    }
+
+    /* Run all tests using the CUnit Basic interface */
+    CU_basic_set_mode(CU_BRM_VERBOSE);
+    CU_basic_run_tests();
+    CU_cleanup_registry();
+    return CU_get_error();
+}
+