Skip to content

Commit 3f2d2f1

Browse files
Andrew Boienashif
authored andcommitted
tests: cmsis_rtos_v2: fix thread checks
It's really not possible to design a test where we can enforce expectations on real vs. expected stack size: - Some platforms may increase stack size over what is expected due to rounding up the stack buffer area to the next power of two. - Some configuration options like CONFIG_STACK_RANDOM carve out space in the stack buffer, resulting in a stack size less than what is expected. Best we can do is just assert that the amount of space available should be less than the total size reported. Fixes: #14640 Signed-off-by: Andrew Boie <[email protected]>
1 parent 0734b4f commit 3f2d2f1

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

tests/cmsis_rtos_v2/src/thread_apis.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,11 @@ static void thread2(void *argument)
8383
"Incorrect number of cmsis rtos v2 threads");
8484

8585
for (i = 0U; i < num_threads; i++) {
86-
zassert_true(
87-
osThreadGetStackSize(thread_array[i]) <= STACKSZ,
88-
"stack size allocated is not what is expected");
86+
u32_t size = osThreadGetStackSize(thread_array[i]);
87+
u32_t space = osThreadGetStackSpace(thread_array[i]);
8988

90-
zassert_true(
91-
osThreadGetStackSpace(thread_array[i]) <= STACKSZ - 4,
92-
"stack size remaining is not what is expected");
89+
zassert_true(space < size,
90+
"stack size remaining is not what is expected");
9391
}
9492

9593
zassert_equal(osThreadGetState(thread_array[1]), osThreadReady,

0 commit comments

Comments
 (0)