diff options
Diffstat (limited to 'test/validation/api/scheduler/scheduler.c')
-rw-r--r-- | test/validation/api/scheduler/scheduler.c | 84 |
1 files changed, 22 insertions, 62 deletions
diff --git a/test/validation/api/scheduler/scheduler.c b/test/validation/api/scheduler/scheduler.c index 8f450a057..8dddd8d8f 100644 --- a/test/validation/api/scheduler/scheduler.c +++ b/test/validation/api/scheduler/scheduler.c @@ -1,5 +1,5 @@ /* Copyright (c) 2014-2018, Linaro Limited - * Copyright (c) 2019-2022, Nokia + * Copyright (c) 2019-2024, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -54,9 +54,9 @@ #define CHAOS_PTR_TO_NDX(p) ((uint64_t)(uint32_t)(uintptr_t)p) #define CHAOS_NDX_TO_PTR(n) ((void *)(uintptr_t)n) -#define WAIT_TIMEOUT (1000 * ODP_TIME_MSEC_IN_NS) +#define WAIT_TIMEOUT (100 * ODP_TIME_MSEC_IN_NS) #define WAIT_ROUNDS 5 -#define WAIT_TOLERANCE (150 * ODP_TIME_MSEC_IN_NS) +#define WAIT_TOLERANCE (15 * ODP_TIME_MSEC_IN_NS) #define WAIT_1MS_RETRIES 1000 #define SCHED_AND_PLAIN_ROUNDS 10000 @@ -1355,7 +1355,7 @@ static void chaos_run(unsigned int qtype) test_globals_t *globals; thread_args_t *args; odp_shm_t shm; - int i, rc, num_thr; + int i, rc; void *arg_ptr; odp_schedule_sync_t sync[] = {ODP_SCHED_SYNC_PARALLEL, ODP_SCHED_SYNC_ATOMIC, @@ -1418,16 +1418,10 @@ static void chaos_run(unsigned int qtype) CU_ASSERT_FATAL(rc == 0); } - /* Test runs also on the main thread */ - num_thr = globals->num_workers - 1; arg_ptr = args; - if (num_thr > 0) - odp_cunit_thread_create(num_thr, chaos_thread, &arg_ptr, 0, 0); + odp_cunit_thread_create(globals->num_workers, chaos_thread, &arg_ptr, 0, 0); - chaos_thread(args); - - if (num_thr > 0) - odp_cunit_thread_join(num_thr); + odp_cunit_thread_join(globals->num_workers); if (CHAOS_DEBUG) printf("Thread %d returning from chaos threads..cleaning up\n", @@ -1475,8 +1469,7 @@ static int schedule_common_(void *arg) odp_pool_t pool; int locked; int num; - odp_event_t ev; - odp_buffer_t buf, buf_cpy; + odp_buffer_t buf; odp_queue_t from; globals = args->globals; @@ -1559,7 +1552,8 @@ static int schedule_common_(void *arg) odp_event_free(events[j]); } } else { - ev = odp_schedule(&from, ODP_SCHED_NO_WAIT); + odp_event_t ev = odp_schedule(&from, ODP_SCHED_NO_WAIT); + if (ev == ODP_EVENT_INVALID) continue; @@ -1570,6 +1564,7 @@ static int schedule_common_(void *arg) uint32_t ndx; uint32_t ndx_max; int rc; + odp_buffer_t buf_cpy; ndx_max = odp_queue_lock_count(from); CU_ASSERT_FATAL(ndx_max > 0); @@ -1830,7 +1825,6 @@ static void parallel_execute(odp_schedule_sync_t sync, int num_queues, test_globals_t *globals; thread_args_t *args; void *arg_ptr; - int num; shm = odp_shm_lookup(GLOBALS_SHM_NAME); CU_ASSERT_FATAL(shm != ODP_SHM_INVALID); @@ -1860,18 +1854,11 @@ static void parallel_execute(odp_schedule_sync_t sync, int num_queues, odp_schedule_print(); /* Create and launch worker threads */ - - /* Test runs also on the main thread */ - num = globals->num_workers - 1; arg_ptr = args; - if (num > 0) - odp_cunit_thread_create(num, schedule_common_, &arg_ptr, 0, 0); - - schedule_common_(args); + odp_cunit_thread_create(globals->num_workers, schedule_common_, &arg_ptr, 0, 0); /* Wait for worker threads to terminate */ - if (num > 0) - odp_cunit_thread_join(num); + odp_cunit_thread_join(globals->num_workers); /* Cleanup ordered queues for next pass */ if (sync == ODP_SCHED_SYNC_ORDERED) @@ -2495,16 +2482,6 @@ out: CU_ASSERT(odp_queue_destroy(queue) == 0); } -static int check_2_workers(void) -{ - if (globals->num_workers < 2) { - printf("\nTest: scheduler_test_order_wait_2_threads: SKIPPED\n"); - return ODP_TEST_INACTIVE; - } - - return ODP_TEST_ACTIVE; -} - static int sched_and_plain_thread(void *arg) { odp_event_t ev1, ev2; @@ -2590,7 +2567,7 @@ static void scheduler_test_sched_and_plain(odp_schedule_sync_t sync) uint64_t wait = odp_schedule_wait_time(100 * ODP_TIME_MSEC_IN_NS); uint32_t events_per_queue = BUFS_PER_QUEUE / 2; uint32_t prev_seq; - int first, num; + int first; void *arg_ptr; CU_ASSERT_FATAL(!odp_schedule_capability(&sched_capa)); @@ -2673,16 +2650,10 @@ static void scheduler_test_sched_and_plain(odp_schedule_sync_t sync) } CU_ASSERT_FATAL(seq > 2); - /* Test runs also on the main thread */ - num = globals->num_workers - 1; arg_ptr = args; - if (num > 0) - odp_cunit_thread_create(num, sched_and_plain_thread, &arg_ptr, 0, 0); - - sched_and_plain_thread(args); + odp_cunit_thread_create(globals->num_workers, sched_and_plain_thread, &arg_ptr, 0, 0); - if (num > 0) - odp_cunit_thread_join(num); + odp_cunit_thread_join(globals->num_workers); /* Check plain queue sequence numbers and free events */ first = 1; @@ -2979,15 +2950,10 @@ static void scheduler_fifo_mt(odp_schedule_sync_t sync, int multi) for (i = 0; i < num_thr; i++) arg[i] = i; - if (num_thr > 1) - odp_cunit_thread_create(num_thr - 1, scheduler_fifo_test, (void **)&arg[1], 1, 0); - - /* Main thread runs as thread 0 */ - scheduler_fifo_test(0); + odp_cunit_thread_create(num_thr, scheduler_fifo_test, (void **)&arg[0], 1, 0); /* Wait for worker threads to terminate */ - if (num_thr > 1) - odp_cunit_thread_join(num_thr - 1); + odp_cunit_thread_join(num_thr); } static void scheduler_fifo_mt_parallel_single(void) @@ -3083,7 +3049,7 @@ static void scheduler_test_atomicity(void) odp_pool_t pool; odp_queue_t queue; odp_queue_param_t queue_param; - int i, num; + int i; void *arg_ptr; shm = odp_shm_lookup(GLOBALS_SHM_NAME); @@ -3121,18 +3087,12 @@ static void scheduler_test_atomicity(void) odp_atomic_init_u32(&globals->atomicity_q.state, 0); /* Create and launch worker threads */ - /* Test runs also on the main thread */ args->num_workers = globals->num_workers; - num = globals->num_workers - 1; arg_ptr = args; - if (num > 0) - odp_cunit_thread_create(num, atomicity_test_run, &arg_ptr, 0, 0); - - atomicity_test_run(args); + odp_cunit_thread_create(globals->num_workers, atomicity_test_run, &arg_ptr, 0, 0); /* Wait for worker threads to terminate */ - if (num > 0) - odp_cunit_thread_join(num); + odp_cunit_thread_join(globals->num_workers); odp_queue_destroy(globals->atomicity_q.handle); } @@ -3720,7 +3680,7 @@ odp_testinfo_t scheduler_basic_suite[] = { ODP_TEST_INFO(scheduler_test_pause_enqueue), ODP_TEST_INFO(scheduler_test_ordered_lock), ODP_TEST_INFO(scheduler_test_order_wait_1_thread), - ODP_TEST_INFO_CONDITIONAL(scheduler_test_order_wait_2_threads, check_2_workers), + ODP_TEST_INFO(scheduler_test_order_wait_2_threads), ODP_TEST_INFO_CONDITIONAL(scheduler_test_flow_aware, check_flow_aware_support), ODP_TEST_INFO(scheduler_test_parallel), @@ -3795,7 +3755,7 @@ int main(int argc, char *argv[]) int ret; /* parse common options: */ - if (odp_cunit_parse_options(argc, argv)) + if (odp_cunit_parse_options(&argc, argv)) return -1; odp_cunit_register_global_init(global_init); |