diff --git a/tests/xtimer_now64_continuity/Makefile b/tests/xtimer_now64_continuity/Makefile index e531799bd..c57bf139e 100644 --- a/tests/xtimer_now64_continuity/Makefile +++ b/tests/xtimer_now64_continuity/Makefile @@ -1,6 +1,7 @@ APPLICATION = xtimer_now64_continuity include ../Makefile.tests_common +USEMODULE += fmt USEMODULE += xtimer include $(RIOTBASE)/Makefile.include diff --git a/tests/xtimer_now64_continuity/README.md b/tests/xtimer_now64_continuity/README.md index bc72736d9..0aa581f5d 100644 --- a/tests/xtimer_now64_continuity/README.md +++ b/tests/xtimer_now64_continuity/README.md @@ -1,5 +1,6 @@ Description =========== -This test measures the difference of two consecutive calls to xtimer_now64() 10k times. -Should the difference be larger then 1000us, the test fails, otherwise it succeeds. +This test measures the difference of two consecutive calls to xtimer_now64() +100k times. If the max or average difference is larger than 1000us the test +fails, otherwise it succeeds. diff --git a/tests/xtimer_now64_continuity/main.c b/tests/xtimer_now64_continuity/main.c index 3642e82a0..79f2cdefc 100644 --- a/tests/xtimer_now64_continuity/main.c +++ b/tests/xtimer_now64_continuity/main.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2015 Kaspar Schleiser + * 2017 HAW Hamburg * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level @@ -14,35 +15,50 @@ * @brief xtimer_now64 continuity test application * * @author Kaspar Schleiser + * @author Sebastian Meiling * * @} */ -#include #include #include "xtimer.h" +#include "fmt.h" -#define ITERATIONS (100000LU) -#define MAXDIFF 1000 +#define ITERATIONS (100000LU) +#define MAXDIFF (1000U) int main(void) { uint32_t n = ITERATIONS; - uint64_t before = _xtimer_now64(); - + uint64_t diff_min = UINT64_MAX; + uint64_t diff_max = 0; + uint64_t diff_sum = 0; + xtimer_ticks64_t before = xtimer_now64(); + print_str("[START]\n"); while(--n) { - uint64_t now = _xtimer_now64(); - if ((now-before) > MAXDIFF) { - puts("TEST FAILED."); - break; + xtimer_ticks64_t now = xtimer_now64(); + xtimer_ticks64_t diff = xtimer_diff64(now, before); + if (diff.ticks64 > diff_max) { + diff_max = diff.ticks64; + } + if (diff.ticks64 < diff_min) { + diff_min = diff.ticks64; } + diff_sum += diff.ticks64; before = now; } - - if (!n) { - puts("TEST SUCCESSFUL."); + print_str("[RESULTS] min="); + print_u64_dec(diff_min); + print_str(", avg="); + print_u64_dec(diff_sum/ITERATIONS); + print_str(", max="); + print_u64_dec(diff_max); + print_str("\n"); + if ((diff_max > MAXDIFF) || (diff_sum/ITERATIONS > MAXDIFF)) { + print_str("[FAILURE]\n"); + return 1; } - + print_str("[SUCCESS]\n"); return 0; }