From f6560df848ef196040e7ba3a1d041f03093e4e53 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Sat, 4 Nov 2017 16:51:03 +0100 Subject: [PATCH] tests/thread_flags: minor improvements in test application --- tests/thread_flags/main.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/thread_flags/main.c b/tests/thread_flags/main.c index 757377344e..7c3e9c65c9 100644 --- a/tests/thread_flags/main.c +++ b/tests/thread_flags/main.c @@ -19,6 +19,7 @@ */ #include +#include #include "thread.h" #include "xtimer.h" @@ -26,6 +27,8 @@ static char stack[THREAD_STACKSIZE_MAIN]; volatile unsigned done; +#define TIMEOUT (100UL * US_PER_MS) + static void *_thread(void *arg) { (void) arg; @@ -66,7 +69,7 @@ static void _set(thread_t *thread, thread_flags_t flags) int main(void) { - puts("main starting"); + puts("START"); kernel_pid_t pid = thread_create(stack, sizeof(stack), @@ -89,12 +92,17 @@ int main(void) puts("main: setting 100ms timeout..."); xtimer_t t; uint32_t before = xtimer_now_usec(); - xtimer_set_timeout_flag(&t, 100000); + xtimer_set_timeout_flag(&t, TIMEOUT); thread_flags_wait_any(THREAD_FLAG_TIMEOUT); uint32_t diff = xtimer_now_usec() - before; printf("main: timeout triggered. time passed: %uus\n", (unsigned)diff); - puts("test finished."); + if (abs(diff - TIMEOUT) < 500) { + puts("SUCCESS"); + } + else { + puts("FAILURE"); + } return 0; }