From 8136a12d247960b075a0d52bbf930c8bba2c9da3 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Tue, 8 Nov 2016 16:38:04 +0100 Subject: [PATCH] tests: fix posix_semaphore output and for timer error --- tests/posix_semaphore/Makefile | 1 + tests/posix_semaphore/main.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/posix_semaphore/Makefile b/tests/posix_semaphore/Makefile index 55ae1c76da..704108e9b8 100644 --- a/tests/posix_semaphore/Makefile +++ b/tests/posix_semaphore/Makefile @@ -5,6 +5,7 @@ BOARD_INSUFFICIENT_MEMORY := msb-430 msb-430h mbed_lpc1768 chronos stm32f0discov pca10000 pca10005 weio yunjia-nrf51822 nrf6310 spark-core \ nucleo-f334 nucleo-f030 +USEMODULE += fmt USEMODULE += posix_semaphore DISABLE_MODULE += auto_init diff --git a/tests/posix_semaphore/main.c b/tests/posix_semaphore/main.c index 7330f2654b..06af8777b6 100644 --- a/tests/posix_semaphore/main.c +++ b/tests/posix_semaphore/main.c @@ -26,6 +26,7 @@ #include #include +#include "fmt.h" #include "msg.h" #include "timex.h" #include "thread.h" @@ -237,6 +238,7 @@ void test3(void) void test4(void) { + char uint64_str[20]; struct timespec abs; uint64_t now, start, stop; const uint64_t exp = 1000000; @@ -259,10 +261,14 @@ void test4(void) } } stop = xtimer_now64() - start; - if (stop < exp) { - printf("first: waited only %" PRIu64 " usec => FAILED\n", stop); + if ((stop < (exp - 100)) || (stop > (exp + 100))) { + fmt_u64_dec(uint64_str, stop); + printf("first: waited only %s usec => FAILED\n", uint64_str); + } + else { + fmt_u64_dec(uint64_str, stop); + printf("first: waited %s usec\n", uint64_str); } - printf("first: waited %" PRIu64 " usec\n", stop); } int main(void)