Skip to content
Permalink
Browse files

tests/kernel/fatal: Fix wait-for-interrupt delay in stack check test

Contrary to the comment in code, this test is NOT, in fact, compiled
with a traditional ticked kernel.  Spinning won't work reliably
because interrupts won't necessarily be delivered when you expect.
This test case would fail spuriously as I moved things around when
debugging.

Doing it right (using a k_timer in this case) is actually less code
anyway.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
  • Loading branch information...
andyross authored and andrewboie committed May 31, 2019
1 parent 8447363 commit ed5185ba1222f8a23c1d37995cc87788e6172f3d
Showing with 8 additions and 15 deletions.
  1. +8 −15 tests/kernel/fatal/src/main.c
@@ -140,24 +140,17 @@ void blow_up_stack(void)

void stack_sentinel_timer(void)
{
u32_t cur_tick;

/* Test that stack overflow check due to timer interrupt works */
blow_up_stack();
TC_PRINT("waiting for tick advance...\n");

/* This test has tickless kernel disabled, z_tick_get_32() returns
* the current tick count without trying to offset it by checking
* time elapsed in the driver since last update
/* We need to guarantee that we receive an interrupt, so set a
* k_timer and spin until we die. Spinning alone won't work
* on a tickless kernel.
*/
cur_tick = z_tick_get_32();
struct k_timer timer;

while (cur_tick == z_tick_get_32()) {
/* spin */
blow_up_stack();
k_timer_init(&timer, NULL, NULL);
k_timer_start(&timer, 1, 0);
while (true) {
}

TC_ERROR("should never see this\n");
rv = TC_FAIL;
}

void stack_sentinel_swap(void)

0 comments on commit ed5185b

Please sign in to comment.
You can’t perform that action at this time.