-
Notifications
You must be signed in to change notification settings - Fork 3k
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_hal-sleep_manager: fix counter wraparound handling #12519
Conversation
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.
Thanks! 👍
@@ -141,7 +141,7 @@ void test_sleep_auto() | |||
const ticker_info_t *lp_ticker_info = get_lp_ticker_data()->interface->get_info(); | |||
const unsigned lp_ticker_mask = ((1 << lp_ticker_info->bits) - 1); | |||
const ticker_irq_handler_type lp_ticker_irq_handler_org = set_lp_ticker_irq_handler(lp_ticker_isr); | |||
us_timestamp_t us_ts1, us_ts2, lp_ts1, lp_ts2, us_diff1, us_diff2, lp_diff1, lp_diff2; | |||
unsigned int us_ts1, us_ts2, lp_ts1, lp_ts2, us_diff1, us_diff2, lp_diff1, lp_diff2; |
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.
unsigned int us_ts1, us_ts2, lp_ts1, lp_ts2, us_diff1, us_diff2, lp_diff1, lp_diff2; | |
uint32_t us_ts1, us_ts2, lp_ts1, lp_ts2, us_diff1, us_diff2, lp_diff1, lp_diff2; |
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.
fixed.
There is a mismatch while handling counter wraparound in `test_sleep_auto` test case. In the test timestamps in ticks are first converted to us and then while counting the time difference wraparound is handled (us and ticks fields are mismatched). The ticker wraparound case must be handled in the field of ticks, and then the difference converted to us.
a9763f4
to
42a9cc1
Compare
@mprse, thank you for your changes. |
CI started |
Test run: SUCCESSSummary: 5 of 5 test jobs passed |
Summary of changes
This PR is a fix for Issue: #12373.
The test needs to be fixed since there is a mismatch while handling counter wraparound in
test_sleep_auto
test case.In the test timestamps in ticks are first converted to us and then while counting the time difference wraparound is handled (us and ticks fields are mismatched). The ticker wraparound case must be handled in the field of ticks, and then the ticks difference converted to us.
In the following line:
us_diff1 = (us_ts1 <= us_ts2) ? (us_ts2 - us_ts1) : (us_ticker_mask - us_ts1 + us_ts2 + 1);
us_ts1
- timestamp before sleep in us.us_ts2
- timestamp after sleep in us.us_ticker_mask
- max ticks count (depending on ticker width).So when wraparound is detected we have mismatched arithmetic operations (ticks and us).
Test results:
Impact of changes
Migration actions required
Documentation
Pull request type
Test results
Reviewers
@stevew817 @amq @fkjagodzinski