Skip to content

Commit

Permalink
Merge pull request #4827 from gebart/pr/xtimer-tests-usleep-until-stats
Browse files Browse the repository at this point in the history
tests/xtimer_usleep_until: Print statistics at the end
  • Loading branch information
Andreas "Paul" Pauli committed Feb 23, 2016
2 parents e0732a5 + 4b47c3e commit 19c48d7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 0 additions & 2 deletions tests/xtimer_usleep_until/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@ BOARD_INSUFFICIENT_MEMORY := chronos
FEATURES_REQUIRED += periph_timer
USEMODULE += xtimer

CFLAGS += -DNUMOF=200

include $(RIOTBASE)/Makefile.include
18 changes: 14 additions & 4 deletions tests/xtimer_usleep_until/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ int main(void)
puts("xtimer_usleep_until test application.\n");

uint32_t interval = NUMOF;
int32_t max_diff = INT32_MIN;
int32_t min_diff = INT32_MAX;

for (int i = 0; i < NUMOF; i++) {
printf("Testing interval %u... (now=%"PRIu32")\n", (unsigned)interval, xtimer_now());
Expand All @@ -46,11 +48,19 @@ int main(void)
for (int i = 0; i < NUMOF; i++) {
printf("%4d diff=%"PRIi32"\n", NUMOF-i, res[i]);

if (res[i] < -1000 || res[i] > 1000) {
puts("too large difference.\n");
puts("Test Failed.\n");
return 1;
if (res[i] > max_diff) {
max_diff = res[i];
}
if (res[i] < min_diff) {
min_diff = res[i];
}
}
printf("\nMin/max error: %" PRId32 "/%" PRId32 "\n", min_diff, max_diff);

if (min_diff < -1000 || max_diff > 1000) {
puts("too large difference.\n");
puts("Test Failed.\n");
return 1;
}

printf("\nTest complete.\n");
Expand Down

0 comments on commit 19c48d7

Please sign in to comment.