1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

Merge pull request #6691 from smlng/pr/tests/xtimer_hang/fix_32bit_timers

tests, xtimer_hang: fix 32Bit timers, 16MHz
This commit is contained in:
Andreas "Paul" Pauli 2017-10-05 17:15:43 +02:00 committed by GitHub
commit f4a44ce303
2 changed files with 19 additions and 14 deletions

View File

@ -1,5 +1,11 @@
# xTimer hang test
This test prints `Testing... (<percentage>)` every `TEST_INTERVAL` ms for
`TEST_SECONDS` seconds. Prints `[SUCCESS]` on completion, if it stops or
hangs before, the test failed.
This is a runtime test for the RIOT xtimer implementation it prints text
`Testing... (<percentage>)` (approximately) every `TEST_INTERVAL_MS` ms
(milliseconds) for an overall test duration of `TEST_TIME_S` seconds.
The test will print `[SUCCESS]` on completion, if it stops or hangs before,
the test has failed.
Please note (again), this is a runtime test to check if xtimer runs into a
deadlock, it is not about clock stability nor accuracy of timing intervals.

View File

@ -29,9 +29,8 @@
#include "thread.h"
#include "log.h"
#define TEST_SECONDS (10LU)
#define TEST_TIME (TEST_SECONDS * US_PER_SEC)
#define TEST_INTERVAL (100LU)
#define TEST_TIME_S (10LU)
#define TEST_INTERVAL_MS (100LU)
#define TEST_TIMER_STACKSIZE (THREAD_STACKSIZE_DEFAULT)
char stack_timer1[TEST_TIMER_STACKSIZE];
@ -58,16 +57,16 @@ int main(void)
3, THREAD_CREATE_STACKTEST,
timer_func, &sleep_timer2, "timer2");
uint32_t ticks_now = 0;
uint32_t ticks_start = _xtimer_now();
uint32_t ticks_until = ticks_start + _xtimer_ticks_from_usec(TEST_TIME);
uint32_t now = 0;
uint32_t start = xtimer_now_usec();
uint32_t until = start + (TEST_TIME_S * US_PER_SEC);
puts("[START]");
while((ticks_now = _xtimer_now()) < ticks_until) {
uint8_t percent = 100*(ticks_now - ticks_start)/(ticks_until - ticks_start);
xtimer_usleep(TEST_INTERVAL * US_PER_MS);
printf("Testing... (%u%%)\n", percent);
while((now = xtimer_now_usec()) < until) {
unsigned percent = (100 * (now - start)) / (until - start);
xtimer_usleep(TEST_INTERVAL_MS * US_PER_MS);
printf("Testing (%3u%%)\n", percent);
}
puts("Testing (100%)");
puts("[SUCCESS]");
return 0;
}