New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests-mbed_drivers-timer: change delay method #7752

merged 1 commit into from Aug 14, 2018


None yet
7 participants

maciejbocianski commented Aug 10, 2018


The test sometimes fails on NRF51_DK (test case: "Test: Timer - time measurement 1 ms.") in morph tests.

Fail log

[1533848813.22][CONN][RXD] >>> Running case #11: 'Test: Timer - time measurement 1 ms.'...
[1533848813.32][CONN][RXD] :730::FAIL: Expected 0.001000 Was 0.001633 
[1533848813.32][CONN][INF] found KV pair in stream: {{__testcase_start;Test: Timer - time measurement 1 ms.}}, queued... 
[1533848813.42][CONN][INF] found KV pair in stream: {{__testcase_finish;Test: Timer - time measurement 1 ms.;0;1}}, queued... 
[1533848813.52][CONN][RXD] >>> 'Test: Timer - time measurement 1 ms.': 0 passed, 1 failed with reason 'Assertion Failed'

The test verifies if Timer class correctly counts elapsed time. Sometimes we got measured ~1600us for delay 1000 us (delta 550 us). The delay is performed using wait_us() function which for delays greater than or equal to 1 ms (our case) calls Thread::wait((uint32_t)ms);. This causes rescheduling and potentially can put board into sleep (deep sleep mode is disabled by wait_us()). For our test purposes we don't need escheduling/sleep since this actions takes extra time and have influence on the time measurement accuracy. The solution is to implement function for delay which is based on busy loop and uses us ticker. It has been verified that this solves the problem. With this fix when test case is repeated 1000 times we got usually measured time equal to ~1080 us, and sometimes ~1300us (checked that this is caused by systick interrupt handling). Since this is test for drivers layer and the results are acceptable I decided to not disabling systick in the test).

Related PR's: #7471

Pull request type

[X] Fix
[ ] Refactor
[ ] Target update
[ ] Feature
[ ] Breaking change

@0xc0170 0xc0170 requested review from fkjagodzinski and jamesbeyond Aug 10, 2018


👍 for the detailed description.


Look good

@cmonr cmonr added needs: CI and removed needs: review labels Aug 13, 2018


This comment has been minimized.


cmonr commented Aug 13, 2018

/morph build


This comment has been minimized.

mbed-ci commented Aug 14, 2018


Build number : 2783
Build artifacts/logs :

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build


This comment has been minimized.


This comment has been minimized.

@cmonr cmonr added ready for merge and removed needs: CI labels Aug 14, 2018

@NirSonnenschein NirSonnenschein merged commit 2b8eb5e into ARMmbed:master Aug 14, 2018

14 checks passed

AWS-CI uVisor Build & Test Success
ci-morph-build build completed
ci-morph-exporter build completed
ci-morph-mbed2-build build completed
ci-morph-test test completed
continuous-integration/jenkins/pr-head This commit looks good
continuous-integration/travis-ci/pr The Travis CI build passed
travis-ci/astyle Passed, 568 files
travis-ci/docs Local docs testing has passed
travis-ci/events Passed, runtime is 10169 cycles (+105 cycles)
travis-ci/gitattributestest Local gitattributestest testing has passed
travis-ci/licence_check Local licence_check testing has passed
travis-ci/littlefs Passed, code size is 9960B (+0.00%)
travis-ci/tools-py2.7 Local tools-py2.7 testing has passed

pan- pushed a commit to pan-/mbed that referenced this pull request Aug 22, 2018

Merge pull request ARMmbed#7752 from maciejbocianski/timer_test_fix
tests-mbed_drivers-timer: change delay method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment