From 6401682dd3092027e7c19039f3d46c893a9d413f Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Mon, 7 Nov 2022 08:42:57 -0600 Subject: [PATCH] ztest: Fix building when CONFIG_MP_NUM_CPUS=1 We get compiler warnings on testcases that set CONFIG_MP_NUM_CPUS=1 and platforms that have CONFIG_SMP=y. Qualify the code so its only built if CONFIG_SMP && (CONFIG_MP_NUM_CPUS > 1). Signed-off-by: Kumar Gala --- subsys/testsuite/ztest/src/ztest.c | 8 ++++---- subsys/testsuite/ztest/src/ztest_new.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/subsys/testsuite/ztest/src/ztest.c b/subsys/testsuite/ztest/src/ztest.c index 180008af02d..ce5bcb86530 100644 --- a/subsys/testsuite/ztest/src/ztest.c +++ b/subsys/testsuite/ztest/src/ztest.c @@ -84,7 +84,7 @@ static int cleanup_test(struct unit_test *test) #ifdef KERNEL -#ifdef CONFIG_SMP +#if defined(CONFIG_SMP) && (CONFIG_MP_MAX_NUM_CPUS > 1) #define MAX_NUM_CPUHOLD (CONFIG_MP_MAX_NUM_CPUS - 1) #define CPUHOLD_STACK_SZ (512 + CONFIG_TEST_EXTRA_STACK_SIZE) static struct k_thread cpuhold_threads[MAX_NUM_CPUHOLD]; @@ -132,11 +132,11 @@ static void cpu_hold(void *arg1, void *arg2, void *arg3) "1cpu test took too long (%d ms)", dt); arch_irq_unlock(key); } -#endif /* CONFIG_SMP */ +#endif /* CONFIG_SMP && (CONFIG_MP_MAX_NUM_CPUS > 1) */ void z_impl_z_test_1cpu_start(void) { -#ifdef CONFIG_SMP +#if defined(CONFIG_SMP) && (CONFIG_MP_MAX_NUM_CPUS > 1) unsigned int num_cpus = arch_num_cpus(); cpuhold_active = 1; @@ -164,7 +164,7 @@ void z_impl_z_test_1cpu_start(void) void z_impl_z_test_1cpu_stop(void) { -#ifdef CONFIG_SMP +#if defined(CONFIG_SMP) && (CONFIG_MP_MAX_NUM_CPUS > 1) unsigned int num_cpus = arch_num_cpus(); cpuhold_active = 0; diff --git a/subsys/testsuite/ztest/src/ztest_new.c b/subsys/testsuite/ztest/src/ztest_new.c index ca586d0667f..4d082111193 100644 --- a/subsys/testsuite/ztest/src/ztest_new.c +++ b/subsys/testsuite/ztest/src/ztest_new.c @@ -105,7 +105,7 @@ static int cleanup_test(struct ztest_unit_test *test) #ifdef KERNEL -#ifdef CONFIG_SMP +#if defined(CONFIG_SMP) && (CONFIG_MP_MAX_NUM_CPUS > 1) #define MAX_NUM_CPUHOLD (CONFIG_MP_MAX_NUM_CPUS - 1) #define CPUHOLD_STACK_SZ (512 + CONFIG_TEST_EXTRA_STACK_SIZE) static struct k_thread cpuhold_threads[MAX_NUM_CPUHOLD]; @@ -154,11 +154,11 @@ static void cpu_hold(void *arg1, void *arg2, void *arg3) "1cpu test took too long (%d ms)", dt); arch_irq_unlock(key); } -#endif /* CONFIG_SMP */ +#endif /* CONFIG_SMP && (CONFIG_MP_MAX_NUM_CPUS > 1) */ void z_impl_z_test_1cpu_start(void) { -#ifdef CONFIG_SMP +#if defined(CONFIG_SMP) && (CONFIG_MP_MAX_NUM_CPUS > 1) unsigned int num_cpus = arch_num_cpus(); cpuhold_active = 1; @@ -184,7 +184,7 @@ void z_impl_z_test_1cpu_start(void) void z_impl_z_test_1cpu_stop(void) { -#ifdef CONFIG_SMP +#if defined(CONFIG_SMP) && (CONFIG_MP_MAX_NUM_CPUS > 1) unsigned int num_cpus = arch_num_cpus(); cpuhold_active = 0;