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 <andrew.j.ross@intel.com>
This commit is contained in:
Andy Ross 2019-10-03 10:03:58 -07:00 committed by Anas Nashif
commit d042a3dac7
4 changed files with 15 additions and 3 deletions

View file

@ -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()

View file

@ -1 +1,2 @@
CONFIG_ZTEST=y
CONFIG_SMP=n

View file

@ -9,6 +9,12 @@
#include <ztest.h>
#include <kernel.h>
#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;

View file

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