On 2014-11-26 19:51, Ciprian Barbu wrote:
> Signed-off-by: Ciprian Barbu <[email protected]>
> ---
> I started from scratch this time trying to follow the list Taras proposed. 
> This
> patch covers the first 4 bullets on his lists.
> 
> One thing I need to mention is that the schedule_mq_mt_prio_atomic would not
> work (at least on linux-generic) without using odp_schedule_release_atomic.
> This might make bullet 6 on Taras' list not needed, I need some clarification
> on this.
> 
>  test/validation/.gitignore                         |   1 +
>  test/validation/Makefile.am                        |   4 +-
>  test/validation/schedule/odp_schedule.c            |  36 ++
>  test/validation/schedule/odp_schedule_test.c       | 450 
> +++++++++++++++++++++
>  test/validation/schedule/odp_schedule_testsuites.h |  21 +
>  5 files changed, 511 insertions(+), 1 deletion(-)
>  create mode 100644 test/validation/schedule/odp_schedule.c
>  create mode 100644 test/validation/schedule/odp_schedule_test.c
>  create mode 100644 test/validation/schedule/odp_schedule_testsuites.h
> 
> diff --git a/test/validation/.gitignore b/test/validation/.gitignore
> index 696cf0a..c0556e6 100644
> --- a/test/validation/.gitignore
> +++ b/test/validation/.gitignore
> @@ -3,3 +3,4 @@
>  odp_init
>  odp_queue
>  odp_crypto
> +odp_schedule
> diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
> index 0b831d0..9e9f84f 100644
> --- a/test/validation/Makefile.am
> +++ b/test/validation/Makefile.am
> @@ -6,7 +6,7 @@ AM_LDFLAGS += -L$(CUNIT_PATH)/lib -static -lcunit
>  if ODP_CUNIT_ENABLED
>  TESTS = ${bin_PROGRAMS}
>  check_PROGRAMS = ${bin_PROGRAMS}
> -bin_PROGRAMS = odp_init odp_queue odp_crypto
> +bin_PROGRAMS = odp_init odp_queue odp_crypto odp_schedule
>  odp_init_LDFLAGS = $(AM_LDFLAGS)
>  odp_queue_LDFLAGS = $(AM_LDFLAGS)
>  odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
> @@ -18,3 +18,5 @@ dist_odp_queue_SOURCES = odp_queue.c
>  dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \
>                         crypto/odp_crypto_test_sync_inp.c \
>                         odp_crypto.c
> +dist_odp_schedule_SOURCES = schedule/odp_schedule_test.c \
> +                         schedule/odp_schedule.c
> diff --git a/test/validation/schedule/odp_schedule.c 
> b/test/validation/schedule/odp_schedule.c
> new file mode 100644
> index 0000000..9ce1281
> --- /dev/null
> +++ b/test/validation/schedule/odp_schedule.c
> @@ -0,0 +1,36 @@
> +/* Copyright (c) 2014, Linaro Limited
> + * All rights reserved.
> + *
> + * SPDX-License-Identifier:     BSD-3-Clause
> + */
> +
> +#include "odp_schedule_testsuites.h"
> +
> +static CU_SuiteInfo suites[] = {

suites = odp_testsuites

Synchronize this with Taras patches [1]

> +     {
> +             "Scheduler tests" ,
> +             schedule_test_init,
> +             schedule_test_finalize,
> +             NULL,
> +             NULL,
> +             schedule_tests
> +     },
> +     CU_SUITE_INFO_NULL,
> +};
> +
> +int main(void)
> +{
> +     CU_set_error_action(CUEA_ABORT);
> +     /* initialize the CUnit test registry */
> +     if (CUE_SUCCESS != CU_initialize_registry())
> +             return CU_get_error();
> +
> +     /* register suites */
> +     CU_register_suites(suites);
> +     /* 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();
> +}
> diff --git a/test/validation/schedule/odp_schedule_test.c 
> b/test/validation/schedule/odp_schedule_test.c
> new file mode 100644
> index 0000000..5a469a6
> --- /dev/null
> +++ b/test/validation/schedule/odp_schedule_test.c
> @@ -0,0 +1,450 @@
> +/* Copyright (c) 2014, Linaro Limited
> + * All rights reserved.
> + *
> + * SPDX-License-Identifier:     BSD-3-Clause
> + */
> +
> +#include "odp_schedule_testsuites.h"
> +#include <odph_linux.h>
> +
> +#define MAX_WORKERS          32            /**< Max worker threads */
> +#define MSG_POOL_SIZE           (4*1024*1024)
> +#define QUEUES_PER_PRIO              16            /**< Queue per priority */
> +#define BUF_SIZE             64
> +#define TEST_NUM_BUFS                10
> +
> +#define GLOBALS_SHM_NAME     "test_globals"
> +#define MSG_POOL_NAME                "msg_pool"
> +#define SHM_MSG_POOL_NAME    "shm_msg_pool"
> +#define SHM_THR_ARGS_NAME    "shm_thr_args"
> +
> +
> +/** Test global variables */
> +typedef struct {
> +     int core_count; /**< Core count */
> +     int proc_mode;  /**< Process mode */
> +     odp_barrier_t barrier;/**< @private Barrier for test synchronisation */
> +     odp_schedule_prio_t prio;
> +     int prio_buf_count; /**< Number of bufs received at current prio */
> +     odp_spinlock_t count_lock; /**< Used for accessing prio counters */
> +} test_globals_t;
> +
> +typedef struct {
> +     odp_schedule_sync_t sync;
> +     int num_queues;
> +     int num_prio;
> +     int use_barrier;
> +} thread_args_t;
> +
> +odp_buffer_pool_t pool;
> +
> +/**
> + * @internal CUnit test case for verifying functionality of
> + *           schedule_wait_time
> + */

Inconsistent use of doxygen comments, we do not have any plan to use
doxygen on the validation test suite for now.

> +static void schedule_wait_time(void)
> +{
> +     uint64_t wait_time;
> +
> +     wait_time = odp_schedule_wait_time(0);
> +     CU_ASSERT(wait_time > 0);
> +
> +     wait_time = odp_schedule_wait_time(1);
> +     CU_ASSERT(wait_time > 0);
> +
> +     wait_time = odp_schedule_wait_time((uint64_t)-1LL);
> +     CU_ASSERT(wait_time > 0);
> +}
> +
> +/* Get next priority in the direction from highest to lowest */
> +static int get_next_prio(int prio) {

Why is this function needed?
If ODP does not define ODP_SCHED_PRIO_HIGHEST to "0" than application
will be forced to write code like this and that's *not* portable.

> +     CU_ASSERT(ODP_SCHED_PRIO_LOWEST != ODP_SCHED_PRIO_HIGHEST);
> +
> +     if (prio == ODP_SCHED_PRIO_LOWEST)
> +             return prio;
> +
> +     if (ODP_SCHED_PRIO_HIGHEST < ODP_SCHED_PRIO_LOWEST)
> +             return prio -1;
> +
> +     if (ODP_SCHED_PRIO_HIGHEST > ODP_SCHED_PRIO_LOWEST)
> +             return prio +1;
> +}
> +
> +static void *schedule_common_(void *arg)
> +{
> +     thread_args_t *args = (thread_args_t*)arg;
> +     odp_schedule_sync_t sync;
> +     int num_queues, num_prio, use_barrier;
> +     int i, j, k;
> +     odp_buffer_pool_t pool;
> +     char name[] = "sched_XX_YY_Z";
> +     odp_shm_t shm;
> +     test_globals_t *globals;
> +
> +     sync = args->sync;
> +     num_queues = args->num_queues;
> +     num_prio = args->num_prio;
> +     use_barrier = args->use_barrier;
> +
> +     pool = odp_buffer_pool_lookup(MSG_POOL_NAME);
> +     CU_ASSERT_FATAL(pool != ODP_BUFFER_POOL_INVALID);
> +
> +     shm = odp_shm_lookup(GLOBALS_SHM_NAME);
> +     CU_ASSERT_FATAL(shm != ODP_SHM_INVALID);
> +     globals = odp_shm_addr(shm);
> +     CU_ASSERT_FATAL(globals != NULL);
> +
> +     switch (sync) {
> +     case ODP_SCHED_SYNC_NONE:
> +             name[12] = 'n';
> +             break;
> +     case ODP_SCHED_SYNC_ATOMIC:
> +             name[12] = 'a';
> +             break;
> +     case ODP_SCHED_SYNC_ORDERED:
> +             name[12] = 'o';
> +             break;
> +     default:
> +             CU_ASSERT(0);
> +             break;
> +     }
> +
> +     for (i = 0; i < num_prio; i++) {
> +             name[6] = '0' + i/10;
> +             name[7] = '0' + i - 10*(i/10);

Use sprintf instead.
What will happen if num_prio are more than 2 digits?

> +
> +             for (j = 0; j < num_queues; j++) {
> +                     odp_queue_t queue;
> +
> +                     name[9]  = '0' + j/10;
> +                     name[10]  = '0' + j - 10*(j/10);

The same applies here.

> +                     queue = odp_queue_lookup(name);
> +                     CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID);
> +
> +                     for (k = 0; k < TEST_NUM_BUFS; k++) {
> +                             odp_buffer_t buf;
> +                             buf = odp_buffer_alloc(pool);
> +                             CU_ASSERT(buf != ODP_BUFFER_INVALID);
> +                             CU_ASSERT(odp_queue_enq(queue, buf) == 0);
> +                     }
> +             }
> +     }

[...]

> +     CU_ASSERT(num_prio > 0);
> +     /* Just common sense but why not */
> +     CU_ASSERT(num_prio == odp_schedule_num_prio());
> +}
> +
> +int schedule_test_finalize(void)
> +{
> +     odp_term_local();
> +     odp_term_global();
> +     return 0;
> +}
> +
> +struct CU_TestInfo schedule_tests[] = {

test_odp_schedule

Synchronize this with Taras patches [1].

Cheers,
Anders

[1] http://lists.linaro.org/pipermail/lng-odp/2014-December/005710.html



_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to