tests/thread_flags_xtimer: minor improvements in test application
This commit is contained in:
parent
84fbd62034
commit
7d4dc0456f
@ -24,7 +24,7 @@
|
|||||||
#include "thread_flags.h"
|
#include "thread_flags.h"
|
||||||
|
|
||||||
#define TIMEOUT (100UL * US_PER_MS)
|
#define TIMEOUT (100UL * US_PER_MS)
|
||||||
#define REPEAT (5)
|
#define REPEAT (5U)
|
||||||
#define RUNTIME (TIMEOUT * REPEAT)
|
#define RUNTIME (TIMEOUT * REPEAT)
|
||||||
|
|
||||||
static void time_evt(void *arg)
|
static void time_evt(void *arg)
|
||||||
@ -34,30 +34,30 @@ static void time_evt(void *arg)
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
puts("START");
|
||||||
xtimer_t timer;
|
xtimer_t timer;
|
||||||
timer.callback = time_evt;
|
timer.callback = time_evt;
|
||||||
timer.arg = (void *)sched_active_thread;
|
timer.arg = (void *)sched_active_thread;
|
||||||
uint32_t last = xtimer_now_usec();
|
uint32_t last = xtimer_now_usec();
|
||||||
|
|
||||||
puts("\nTest setting thread flags from (x)timer callback");
|
puts("Test setting thread flags from (x)timer callback");
|
||||||
printf("You should see the message '+++ timeout XX +++' printed to the \n"
|
printf("You should see the message '+++ timeout XX +++' printed to the \n"
|
||||||
"screen %i times, once every %lu milliseconds\n\n",
|
"screen %u times, once every %lu milliseconds\n\n",
|
||||||
REPEAT, (TIMEOUT / US_PER_MS));
|
REPEAT, (TIMEOUT / US_PER_MS));
|
||||||
|
|
||||||
for (int i = 1; i <= REPEAT; i++) {
|
for (unsigned i = 1; i <= REPEAT; i++) {
|
||||||
xtimer_set(&timer, TIMEOUT);
|
xtimer_set(&timer, TIMEOUT);
|
||||||
thread_flags_wait_any(0x1);
|
thread_flags_wait_any(0x1);
|
||||||
printf("+++ timeout %2i +++\n", i);
|
printf("+++ timeout %2u +++\n", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we consider the test successful, if the runtime was above 500ms */
|
/* we consider the test successful, if the runtime was above 500ms */
|
||||||
uint32_t runtime = xtimer_now_usec() - last;
|
uint32_t runtime = xtimer_now_usec() - last;
|
||||||
if (runtime > RUNTIME) {
|
if (runtime > RUNTIME) {
|
||||||
puts("Test finished: SUCCESS\n");
|
puts("SUCCESS");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
puts("Test finished: FAILED\n");
|
puts("FAILURE");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user