1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/tests/hwtimer_wait/main.c
Ludwig Ortmann ac8f51cb52 tests/hwtimer_wait: test smallest value possible
By selecting the start value as a multiple of HWTIMER_SPIN_BARRIER+1, the
test now includes the smallest non-spinning value.
2014-11-28 13:48:25 +01:00

47 lines
1.1 KiB
C

/*
* Copyright (C) 2014 Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
*
* 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
* directory for more details.
*/
/**
* @ingroup tests
* @{
*
* @file
* @brief Hwtimer test application
*
* @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
*
* @}
*/
#include <stdio.h>
#include <math.h>
#include "hwtimer.h"
#include "board.h"
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.");
long iterations = 10000;
long start_duration = (HWTIMER_SPIN_BARRIER + 1) << 5;
long duration = iterations * start_duration * 2L;
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 > HWTIMER_SPIN_BARRIER; i = i >> 1) {
hwtimer_wait(i);
}
}
puts("success");
return 0;
}