2014-04-22 18:12:58 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
|
|
|
|
*
|
2014-07-31 19:45:27 +02:00
|
|
|
* 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.
|
2014-04-22 18:12:58 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup tests
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @brief Hwtimer test application
|
|
|
|
*
|
|
|
|
* @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
|
|
|
|
*
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <stdlib.h>
|
2014-08-28 12:39:58 +02:00
|
|
|
#include <math.h>
|
2014-04-22 18:12:58 +02:00
|
|
|
|
|
|
|
#include "board_uart0.h"
|
|
|
|
#include "posix_io.h"
|
|
|
|
#include "hwtimer.h"
|
|
|
|
#include "thread.h"
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
puts("This is a regression test for a race condition in hwtimer_wait.");
|
2014-08-28 12:39:58 +02:00
|
|
|
puts("When the race condition is hit, the timer will wait for a very very long time.");
|
2014-04-22 18:12:58 +02:00
|
|
|
|
2014-08-29 18:45:55 +02:00
|
|
|
long iterations = 10000;
|
|
|
|
long start_duration = 256;
|
|
|
|
long duration = iterations * start_duration * 2L;
|
|
|
|
|
2014-08-28 12:39:58 +02:00
|
|
|
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) {
|
2014-04-22 18:12:58 +02:00
|
|
|
hwtimer_wait(i);
|
|
|
|
}
|
|
|
|
}
|
2014-05-12 13:03:47 +02:00
|
|
|
puts("success");
|
2014-08-28 12:39:58 +02:00
|
|
|
|
2014-05-12 13:03:47 +02:00
|
|
|
return 0;
|
2014-04-22 18:12:58 +02:00
|
|
|
}
|