Skip to content

Commit

Permalink
tests/kernel/smp: Fix cases for !SCHED_IPI_SUPPORTED
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
andyross authored and carlescufi committed Sep 19, 2022
1 parent 0ca7150 commit 358355a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/kernel/smp/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand All @@ -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)
{
Expand Down

0 comments on commit 358355a

Please sign in to comment.