From 358355a23db67ca856561c19ecb51fd013d3a97f Mon Sep 17 00:00:00 2001 From: Andy Ross Date: Tue, 13 Sep 2022 10:17:11 -0700 Subject: [PATCH] tests/kernel/smp: Fix cases for !SCHED_IPI_SUPPORTED Obviously the test of the feature won't work if we don't have an IPI. And there were two threads that spawned threads that enter busy loops, expecting to be able to abort them from another CPU. That doesn't work[1] without an IPI. Just skip these cases rather than trying to kludge up some kind of abort signal. [1] Rather, it does work, it just takes infinite time for these particular test cases. Eventually the CPU would be expected to receive some other interrupt like a timeout, which would work to abort the running thread. But no such timer was registered. Signed-off-by: Andy Ross --- tests/kernel/smp/src/main.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/kernel/smp/src/main.c b/tests/kernel/smp/src/main.c index 2b8222b52f5..ca8b20db0c5 100644 --- a/tests/kernel/smp/src/main.c +++ b/tests/kernel/smp/src/main.c @@ -119,6 +119,14 @@ ZTEST(smp, test_smp_coop_threads) { int i, ok = 1; + if (!IS_ENABLED(CONFIG_SCHED_IPI_SUPPORTED)) { + /* The spawned thread enters an infinite loop, so it can't be + * successfully aborted via an IPI. Just skip in that + * configuration. + */ + ztest_test_skip(); + } + k_tid_t tid = k_thread_create(&t2, t2_stack, T2_STACK_SIZE, t2_fn, NULL, NULL, NULL, K_PRIO_COOP(2), 0, K_NO_WAIT); @@ -546,6 +554,14 @@ ZTEST(smp, test_get_cpu) { k_tid_t thread_id; + if (!IS_ENABLED(CONFIG_SCHED_IPI_SUPPORTED)) { + /* The spawned thread enters an infinite loop, so it can't be + * successfully aborted via an IPI. Just skip in that + * configuration. + */ + ztest_test_skip(); + } + /* get current cpu number */ _cpu_id = arch_curr_cpu()->id; @@ -615,6 +631,7 @@ void z_trace_sched_ipi(void) * * @see arch_sched_ipi() */ +#ifdef CONFIG_SCHED_IPI_SUPPORTED ZTEST(smp, test_smp_ipi) { #ifndef CONFIG_TRACE_SCHED_IPI @@ -640,6 +657,7 @@ ZTEST(smp, test_smp_ipi) sched_ipi_has_called); } } +#endif void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *pEsf) {