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:
commit
f4a44ce303
@ -1,5 +1,11 @@
|
|||||||
# xTimer hang test
|
# xTimer hang test
|
||||||
|
|
||||||
This test prints `Testing... (<percentage>)` every `TEST_INTERVAL` ms for
|
This is a runtime test for the RIOT xtimer implementation it prints text
|
||||||
`TEST_SECONDS` seconds. Prints `[SUCCESS]` on completion, if it stops or
|
`Testing... (<percentage>)` (approximately) every `TEST_INTERVAL_MS` ms
|
||||||
hangs before, the test failed.
|
(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.
|
||||||
|
@ -29,9 +29,8 @@
|
|||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
#define TEST_SECONDS (10LU)
|
#define TEST_TIME_S (10LU)
|
||||||
#define TEST_TIME (TEST_SECONDS * US_PER_SEC)
|
#define TEST_INTERVAL_MS (100LU)
|
||||||
#define TEST_INTERVAL (100LU)
|
|
||||||
#define TEST_TIMER_STACKSIZE (THREAD_STACKSIZE_DEFAULT)
|
#define TEST_TIMER_STACKSIZE (THREAD_STACKSIZE_DEFAULT)
|
||||||
|
|
||||||
char stack_timer1[TEST_TIMER_STACKSIZE];
|
char stack_timer1[TEST_TIMER_STACKSIZE];
|
||||||
@ -58,16 +57,16 @@ int main(void)
|
|||||||
3, THREAD_CREATE_STACKTEST,
|
3, THREAD_CREATE_STACKTEST,
|
||||||
timer_func, &sleep_timer2, "timer2");
|
timer_func, &sleep_timer2, "timer2");
|
||||||
|
|
||||||
uint32_t ticks_now = 0;
|
uint32_t now = 0;
|
||||||
uint32_t ticks_start = _xtimer_now();
|
uint32_t start = xtimer_now_usec();
|
||||||
uint32_t ticks_until = ticks_start + _xtimer_ticks_from_usec(TEST_TIME);
|
uint32_t until = start + (TEST_TIME_S * US_PER_SEC);
|
||||||
|
|
||||||
puts("[START]");
|
puts("[START]");
|
||||||
while((ticks_now = _xtimer_now()) < ticks_until) {
|
while((now = xtimer_now_usec()) < until) {
|
||||||
uint8_t percent = 100*(ticks_now - ticks_start)/(ticks_until - ticks_start);
|
unsigned percent = (100 * (now - start)) / (until - start);
|
||||||
xtimer_usleep(TEST_INTERVAL * US_PER_MS);
|
xtimer_usleep(TEST_INTERVAL_MS * US_PER_MS);
|
||||||
printf("Testing... (%u%%)\n", percent);
|
printf("Testing (%3u%%)\n", percent);
|
||||||
}
|
}
|
||||||
|
puts("Testing (100%)");
|
||||||
puts("[SUCCESS]");
|
puts("[SUCCESS]");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user