Skip to content

Commit 091a6aa

Browse files
committed
test: add tick check in idle loop
1 parent b0b8d1e commit 091a6aa

File tree

1 file changed

+4
-0
lines changed
  • TESTS/mbedmicro-rtos-mbed/idle_loop

1 file changed

+4
-0
lines changed

TESTS/mbedmicro-rtos-mbed/idle_loop/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,19 @@ void idle_loop_test_sleep_ms_callback(timestamp_t *time_ms)
3131
{
3232
LowPowerTimer timer;
3333
timer.start();
34+
const uint64_t kernel_tick_start = osKernelGetTickCount();
3435
Thread::wait(*time_ms);
3536
const timestamp_t end = timer.read_ms();
37+
const uint64_t kernel_tick_end = osKernelGetTickCount();
3638

3739
// this does not test accurancy for waking up
3840
// just that we are with some margin awake (10ms)
3941
// sleep/low power ticker will test this
4042
// Note: if this does not work, we wake up with
4143
// default freq - 1ms
4244
TEST_ASSERT_UINT32_WITHIN(3, *time_ms, end);
45+
uint64_t kernel_ticks_expected = (uint64_t)*time_ms * osKernelGetTickFreq() * 1000UL;
46+
TEST_ASSERT_UINT32_WITHIN(3, kernel_ticks_expected, kernel_tick_end - kernel_tick_start);
4347
}
4448

4549
template<timestamp_t time_ms>

0 commit comments

Comments
 (0)