b748d5219a
The test_timer_periodicity test is racy and subject to initial state bugs. The operation of that test is to: 1. Start a timer with a known period 2. Take the current time with k_uptime_get() 3. Wait for the timer to fire with k_timer_status_sync() 4. Check that the current time minus start time is the period But that's wrong, because a tick expiring between any of the first three steps is going to skew the math (i.e. the timer will have started on a different tick than the "start time"). And taking an interrupt lock around the process can't fix the issue, because in the tickless world we live in k_uptime_get() is actually a realtime quanity based on a hardware counter and doesn't rely on interrupt delivery. Instead, use another timer object to synchronize the test start to a driver tick, ensuring that even if the race is unfixable the initial conditions are always correct. Signed-off-by: Andy Ross <andrew.j.ross@intel.com> |
||
---|---|---|
.. | ||
src | ||
CMakeLists.txt | ||
README | ||
prj.conf | ||
prj_tickless.conf | ||
testcase.yaml |
README
$ make run [QEMU] CPU: qemu32 Running test suite test_timer_api tc_start() - test_timer_duration_period =================================================================== PASS - test_timer_duration_period. tc_start() - test_timer_period_0 =================================================================== PASS - test_timer_period_0. tc_start() - test_timer_expirefn_null =================================================================== PASS - test_timer_expirefn_null. tc_start() - test_timer_status_get =================================================================== PASS - test_timer_status_get. tc_start() - test_timer_status_get_anytime =================================================================== PASS - test_timer_status_get_anytime. tc_start() - test_timer_status_sync =================================================================== PASS - test_timer_status_sync. tc_start() - test_timer_k_define =================================================================== PASS - test_timer_k_define. =================================================================== PROJECT EXECUTION SUCCESSFUL