From 77794c041e425a2bd02409df8093608e825a7cc1 Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Thu, 28 Aug 2014 12:39:58 +0200 Subject: [PATCH] tests: print expected duration in hwtimer_wait --- tests/hwtimer_wait/main.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/hwtimer_wait/main.c b/tests/hwtimer_wait/main.c index e5f7d03f58..3cefdcfbe3 100644 --- a/tests/hwtimer_wait/main.c +++ b/tests/hwtimer_wait/main.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "board_uart0.h" #include "posix_io.h" @@ -30,13 +31,24 @@ int main(void) { puts("This is a regression test for a race condition in hwtimer_wait."); - puts("When the race condition is hit, the timer will wait for a very very long time..."); + puts("When the race condition is hit, the timer will wait for a very very long time."); - for (unsigned long r = 10000; r > 0; r--) { - for (unsigned long i = 256; i; i = i >> 1) { + int iterations = 10000; + int start_duration = 256; + + long duration = iterations * ( + /* geometric series */ + (1 - pow(2,(log2(start_duration) + 1))) + / (1 - 2) + ); + printf("The test should take about %li sec.\n", (HWTIMER_TICKS_TO_US(duration)/1000000)); + + for (unsigned long r = iterations; r > 0; r--) { + for (unsigned long i = start_duration; i; i = i >> 1) { hwtimer_wait(i); } } puts("success"); + return 0; }