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 <kumar.gala@intel.com>
This commit is contained in:
Kumar Gala 2022-11-07 08:42:57 -06:00 committed by Anas Nashif
commit 6401682dd3
2 changed files with 8 additions and 8 deletions

View file

@ -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;

View file

@ -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;