Skip to content

Commit 8363eeb

Browse files
author
Andrew Boie
committed
kernel: enforce usage of CONFIG_TEST_USERSPACE
If a test tries to create a user thread, and the platform suppors user mode, and CONFIG_TEST_USERSPACE has not been enabled, fail an assertion. Signed-off-by: Andrew Boie <[email protected]>
1 parent 71689d2 commit 8363eeb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

kernel/thread.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,12 @@ k_tid_t z_impl_k_thread_create(struct k_thread *new_thread,
433433
{
434434
__ASSERT(!z_is_in_isr(), "Threads may not be created in ISRs");
435435

436+
/* Special case, only for unit tests */
437+
#if defined(CONFIG_TEST) && defined(CONFIG_ARCH_HAS_USERSPACE) && !defined(CONFIG_USERSPACE)
438+
__ASSERT((options & K_USER) == 0,
439+
"Platform is capable of user mode, and test thread created with K_USER option, but CONFIG_TEST_USERSPACE or CONFIG_USERSPACE is not set\n");
440+
#endif
441+
436442
z_setup_new_thread(new_thread, stack, stack_size, entry, p1, p2, p3,
437443
prio, options, NULL);
438444

0 commit comments

Comments
 (0)