ROTS: SysTimer: Fix test timing issues

Use a busy loop with non-blocking Semaphore::wait(0) calls instead of a
single Semaphore::wait(osWaitForever) to improve time measurement
accuracy. Looping in Semaphore::wait(0) prevents the board from entering
sleep or deepsleep modes while waiting for the semaphore. By skipping
the overhead wakeup time, we get more accurate timings.
pull/9416/head
Filip Jagodzinski 2019-01-17 17:02:15 +01:00
parent 284781a565
commit 5840281682
1 changed files with 4 additions and 1 deletions

View File

@ -245,7 +245,10 @@ void test_handler_called_once(void)
int32_t sem_slots = st.sem_wait(0);
TEST_ASSERT_EQUAL_INT32(0, sem_slots);
sem_slots = st.sem_wait(osWaitForever);
// Wait in a busy loop to prevent entering sleep or deepsleep modes.
while (sem_slots != 1) {
sem_slots = st.sem_wait(0);
}
us_timestamp_t t2 = st.get_time();
TEST_ASSERT_EQUAL_INT32(1, sem_slots);
TEST_ASSERT_EQUAL_UINT32(1, st.get_tick());