Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH v3] improve validation testing with 1 or 2 CPUs #2001

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions test/validation/api/scheduler/scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -2481,16 +2481,6 @@ static void scheduler_test_order_wait_2_threads(void)
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;
Expand Down Expand Up @@ -3689,7 +3679,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),
Expand Down
15 changes: 12 additions & 3 deletions test/validation/api/time/time.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Copyright (c) 2015-2018, Linaro Limited
* Copyright (c) 2019-2023, Nokia
* Copyright (c) 2019-2024, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
Expand All @@ -24,6 +24,7 @@
#define TIME_SAMPLES 2
#define TIME_TOLERANCE_NS 1000000
#define TIME_TOLERANCE_CI_NS 40000000
#define TIME_TOLERANCE_1CPU_NS 40000000
#define GLOBAL_SHM_NAME "GlobalTimeTest"
#define YEAR_IN_NS (365 * 24 * ODP_TIME_HOUR_IN_NS)

Expand Down Expand Up @@ -858,8 +859,7 @@ static void time_test_global_sync(const int ctrl)
odph_thread_common_param_t thr_common;
odph_thread_param_t thr_param;
odph_thread_t thread_tbl[MAX_WORKERS];
const uint64_t tolerance =
odp_cunit_ci() ? TIME_TOLERANCE_CI_NS : TIME_TOLERANCE_NS;
uint64_t tolerance = odp_cunit_ci() ? TIME_TOLERANCE_CI_NS : TIME_TOLERANCE_NS;
const int num = ctrl ? 2 : global_mem->num_threads;

if (num < 2) {
Expand All @@ -879,14 +879,23 @@ static void time_test_global_sync(const int ctrl)

if (ctrl) {
/* Test sync between one control and one worker thread. */
int control_cpu;
int worker_cpu;

odp_cpumask_default_control(&cpumask, 1);
thr_common.cpumask = &cpumask;
thr_param.thr_type = ODP_THREAD_CONTROL;
control_cpu = odp_cpumask_first(&cpumask);

int r = odph_thread_create(&thread_tbl[thr++],
&thr_common, &thr_param, 1);
CU_ASSERT_FATAL(r == 1);
odp_cpumask_default_worker(&cpumask, 1);
worker_cpu = odp_cpumask_first(&cpumask);
if (control_cpu == worker_cpu) {
printf(" single CPU, relaxing tolerance. ");
tolerance = TIME_TOLERANCE_1CPU_NS;
}
} else {
/* Test sync between num worker threads. */
odp_cpumask_default_worker(&cpumask, num);
Expand Down