-
Notifications
You must be signed in to change notification settings - Fork 3k
Ticker tests fix #5971
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
Ticker tests fix #5971
Conversation
8a2e177
to
93bb31a
Compare
This commit fixes ticker cross-schedule bug in test_case_2x_callbacks subtest In effect of this bug: ticker_callback_1_switch_to_2 was called only once ticker2 was never been fired because it was repeatedly detached just before fire and attached again
test_case_2x_callbacks test was redesigned to eliminate ticker rescheduling and improve time mesure accuracy. Constant ticker rescheduling (detach()/attach_us() calls) was causing the gap between consecutive callback calls was not exact 1ms but 1ms + time needed to call the callback and attach new one. New design just uses two tickers to update counter alternatively every 1ms without rescheduling them
93bb31a
to
1437651
Compare
Great, this fixes the issue of test never completing. only problem (which should probably go in its own issue) is that the tests will occasionally fail on nRF51 boards when using the internal RC (tested with an nRF51-DK). I wonder if the tolerance shouldnt be increased for those targets since the RC clock is never going to match the accuracy of the external crystal |
@drewcassidy usually tests are designed and run for default targets configuration so there is nothing unusual that test is failing if we change configuration. Especially when we use oscillator with lower accuracy then assumed by test designer. If we increase test tolerance then more configurations will pass but test will be less reliable |
Log here: https://gist.github.com/anonymous/4873033bb990e29f3f321b5f61c1c9a4, usually the result is closer to the expected value. This is on an nRF51-DK with the RC clock selected with the app_config.json file This should probably move back to #5892, which is attempting to add a target using the nRF51822 using the RC clock. I didnt mean to suggest increasing the tolerance universally, but as something based on the configuration. I'm not sure if thats set in the test and can just use an #ifdef or if it would require extra python tooling |
Thanks @drewcassidy , we will look into this to find a way to set tolerance better |
I checked the nRF51822 datasheet again and the internal RC clock SHOULD have an accuracy of ±250ppm, far less than the ±5% its currently failing to reach. Either the datasheet is wildly off, I have multiple defective chips, or there is something wrong with the way this test is being performed |
/morph build |
Build : SUCCESSBuild number : 1072 Triggering tests/morph test |
There is target addition in #5996, and having the issue with ticker, but solved with this PR.
We will review this test fix, and we should still look at why it still fails for your setup, but as you mentioned, might move to 5892 (in case this goes in, you can review the test with your new target addition, and resolve the issue there). Restarting /morph uvisor-test |
/morph uvisor-test |
Test : SUCCESSBuild number : 880 |
Exporter Build : SUCCESSBuild number : 750 |
/morph uvisor-test |
1 similar comment
/morph uvisor-test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good!
Description
This PR contains fix for mbed_drivers-ticker tests.
Despite the test was always green there was hidden bug in
test_case_2x_callbacks
subtest detected in #5955 and #5892.In effect of this bug (source code 1):
ticker_callback_1_switch_to_2
was called only onceticker2
was never been fired because it was repeatedly detached just before fire and attached againFix for this bug (source code 2) showed that time measure with repeatedly rescheduled ticker is not accurate. When we use ticker without rescheduling (like in
test_case_1x_ticker
) ticker callback is executed within ticker interval time - not extra time is added to ticker interval until the callback execution time is less then ticker interval time.Test
test_case_2x_callbacks
(after fix - source code 2) at each interval(callback call) reschedules ticker (calldetach()
anattach_us()
) what cause that the time between consecutive callback calls is not 1ms but 1ms + time needed to call the callback and attach new one.So the cross-call fix, fixed the algorithm but caused the test inaccurate.
Finally the two tickers test was redesigned and now it just uses two tickers to update counter alternatively every 1ms without rescheduling
Status
READY
Migrations
NO