From d042a3dac7d780f4a3a276be3d9e4672bc099d06 Mon Sep 17 00:00:00 2001 From: Andy Ross Date: Thu, 3 Oct 2019 10:03:58 -0700 Subject: [PATCH] tests/kernel/mp: Update the MP test to run on emulated platforms This was a very early test and got bitrotten inside a esp32-only whitelist. Make it run generically. SMP must be forced off by the test (it's commonly a platform default). Add a build-time failure when the configuration is single-CPU, for clarity. Filter the test likewise so it runs on all supported systems. Also, the key argument to the CPU startup function is vestigial and the test was being too strict by requiring it to be non-zero. Finally, the qemu command line needs to predicate the "-smp" argument on CONFIG_MP_NUM_CPUS and not just CONFIG_SMP so we have an extra CPU to test against. Signed-off-by: Andy Ross --- cmake/emu/qemu.cmake | 5 ++++- tests/kernel/mp/prj.conf | 1 + tests/kernel/mp/src/main.c | 9 ++++++++- tests/kernel/mp/testcase.yaml | 3 ++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/cmake/emu/qemu.cmake b/cmake/emu/qemu.cmake index 2b8ee3d8db3..b576a288fe4 100644 --- a/cmake/emu/qemu.cmake +++ b/cmake/emu/qemu.cmake @@ -252,7 +252,10 @@ if(NOT QEMU_PIPE) set(QEMU_PIPE_COMMENT "\nTo exit from QEMU enter: 'CTRL+a, x'\n") endif() -if(CONFIG_SMP) +# Don't just test CONFIG_SMP, there is at least one test of the lower +# level multiprocessor API that wants an auxiliary CPU but doesn't +# want SMP using it. +if(NOT CONFIG_MP_NUM_CPUS MATCHES "1") list(APPEND QEMU_SMP_FLAGS -smp cpus=${CONFIG_MP_NUM_CPUS}) endif() diff --git a/tests/kernel/mp/prj.conf b/tests/kernel/mp/prj.conf index 9467c292689..5b0d7a6bdea 100644 --- a/tests/kernel/mp/prj.conf +++ b/tests/kernel/mp/prj.conf @@ -1 +1,2 @@ CONFIG_ZTEST=y +CONFIG_SMP=n diff --git a/tests/kernel/mp/src/main.c b/tests/kernel/mp/src/main.c index d95cec9907d..e6886b8de9a 100644 --- a/tests/kernel/mp/src/main.c +++ b/tests/kernel/mp/src/main.c @@ -9,6 +9,12 @@ #include #include +#ifdef CONFIG_SMP +#error Cannot test MP API if SMP is using the CPUs +#endif + +BUILD_ASSERT(CONFIG_MP_NUM_CPUS > 1); + #define CPU1_STACK_SIZE 1024 K_THREAD_STACK_DEFINE(cpu1_stack, CPU1_STACK_SIZE); @@ -29,7 +35,8 @@ volatile int cpu_running; */ void cpu1_fn(int key, void *arg) { - zassert_true(key, "bad irq key"); + ARG_UNUSED(key); + zassert_true(arg == &cpu_arg && *(int *)arg == 12345, "wrong arg"); cpu_running = 1; diff --git a/tests/kernel/mp/testcase.yaml b/tests/kernel/mp/testcase.yaml index 09c24b2220a..c465c3d89ed 100644 --- a/tests/kernel/mp/testcase.yaml +++ b/tests/kernel/mp/testcase.yaml @@ -1,3 +1,4 @@ tests: kernel.multiprocessing: - platform_whitelist: esp32 + # Doesn't currently work on ARC, see #19599 + filter: (CONFIG_MP_NUM_CPUS > 1) and not CONFIG_ARC