From 83d1ca06dcd66bd96df42d41c2df47572c0ee107 Mon Sep 17 00:00:00 2001 From: Andy Ross Date: Thu, 23 Jan 2020 13:00:29 -0800 Subject: [PATCH] tests/mem_protect/stackprot: Need a delay under SMP The "alternate thread" test would spawn a thread and then exit the test, but on SMP that other thread runs asynchronously and it was possible for the main thread to exit the test entirely before the test thread had a chance to run (and overflow its stack), leading to spurious test case failures. Obviously we can't exactly synchronize to an async crash, so put a short delay in after spawning the thread. Signed-off-by: Andy Ross --- tests/kernel/mem_protect/stackprot/src/main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/kernel/mem_protect/stackprot/src/main.c b/tests/kernel/mem_protect/stackprot/src/main.c index 7958c152cc6..c027b3cb0c6 100644 --- a/tests/kernel/mem_protect/stackprot/src/main.c +++ b/tests/kernel/mem_protect/stackprot/src/main.c @@ -126,6 +126,11 @@ void test_create_alt_thread(void) k_thread_create(&alt_thread_data, alt_thread_stack_area, STACKSIZE, (k_thread_entry_t)alternate_thread, NULL, NULL, NULL, K_PRIO_COOP(1), K_USER, K_NO_WAIT); + + /* Note that this sleep is required on SMP platforms where + * that thread will execute asynchronously! + */ + k_sleep(K_MSEC(100)); } void test_main(void)