From 0d91e61dbbfb0c377a6b2b00178b3cffe6eff1bf Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Mon, 14 Oct 2019 17:34:03 +0200 Subject: [PATCH] tests/isr_yield_higher: adapt TEST_TIME to start-up time --- tests/isr_yield_higher/main.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/tests/isr_yield_higher/main.c b/tests/isr_yield_higher/main.c index fff50947ef..2b7bb314a1 100644 --- a/tests/isr_yield_higher/main.c +++ b/tests/isr_yield_higher/main.c @@ -27,11 +27,12 @@ #define TEST_TIME (200000U) static char t2_stack[THREAD_STACKSIZE_MAIN]; +static uint32_t start_time; static void *second_thread(void *arg) { - (void) arg; - if (xtimer_now_usec() < TEST_TIME) { + (void)arg; + if (xtimer_now_usec() < (TEST_TIME + start_time)) { puts("TEST FAILED"); } else { @@ -49,19 +50,21 @@ static void _cb(void *arg) int main(void) { - (void) thread_create( - t2_stack, sizeof(t2_stack), - THREAD_PRIORITY_MAIN, - THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST, - second_thread, NULL, "nr2"); - puts("first thread started"); + start_time = xtimer_now_usec(); + xtimer_t timer; timer.callback = _cb; - xtimer_set(&timer, TEST_TIME/2); + xtimer_set(&timer, TEST_TIME / 2); - while(xtimer_now_usec() < TEST_TIME) {} + (void)thread_create( + t2_stack, sizeof(t2_stack), + THREAD_PRIORITY_MAIN, + THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST, + second_thread, NULL, "nr2"); + + while (xtimer_now_usec() < (TEST_TIME + start_time)) {} puts("first thread done");