Skip to content

Commit f8be489

Browse files
Andrew Boienashif
authored andcommitted
tests: stackprot: don't set main stack size
This test uses ztest anyway, the default should be fine just like any other test running under ztest. k_thread_create() uses a lot of stack, and the main stack size is very small if ztest is enabled. Do it in another ztest task instead. We don't need to mess with the main thread's priority, just have the alt thread run cooperatively. Signed-off-by: Andrew Boie <[email protected]>
1 parent 8812c7f commit f8be489

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

tests/kernel/mem_protect/stackprot/prj.conf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@ CONFIG_ZTEST=y
22
CONFIG_STACK_CANARIES=y
33
CONFIG_ENTROPY_GENERATOR=y
44
CONFIG_TEST_RANDOM_GENERATOR=y
5-
CONFIG_MAIN_THREAD_PRIORITY=7
6-
CONFIG_MAIN_STACK_SIZE=640
75
CONFIG_TEST_USERSPACE=y

tests/kernel/mem_protect/stackprot/src/main.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212

1313
#define STACKSIZE (2048 + CONFIG_TEST_EXTRA_STACKSIZE)
14-
#define PRIORITY 5
1514

1615
ZTEST_BMEM static int count;
1716
ZTEST_BMEM static int ret = TC_PASS;
@@ -113,14 +112,18 @@ void test_stackprot(void)
113112
print_loop(__func__);
114113
}
115114

116-
void test_main(void)
115+
void test_create_alt_thread(void)
117116
{
118117
/* Start thread */
119118
k_thread_create(&alt_thread_data, alt_thread_stack_area, STACKSIZE,
120119
(k_thread_entry_t)alternate_thread, NULL, NULL, NULL,
121-
K_PRIO_PREEMPT(PRIORITY), K_USER, K_NO_WAIT);
120+
K_PRIO_COOP(1), K_USER, K_NO_WAIT);
121+
}
122122

123+
void test_main(void)
124+
{
123125
ztest_test_suite(stackprot,
126+
ztest_unit_test(test_create_alt_thread),
124127
ztest_user_unit_test(test_stackprot));
125128
ztest_run_test_suite(stackprot);
126129
}

0 commit comments

Comments
 (0)