1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-30 00:41:17 +01:00

tests/thread_flags: minor improvements in test application

This commit is contained in:
Alexandre Abadie 2017-11-04 16:51:03 +01:00
parent 95bb6d48d8
commit f6560df848

View File

@ -19,6 +19,7 @@
*/
#include <stdio.h>
#include <stdlib.h>
#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;
}