Skip to content
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

Update HAL Sleep manager test to cope with STM32 LPTIM HW #10700

Merged
merged 8 commits into from
Jun 28, 2019

Conversation

LMESTM
Copy link
Contributor

@LMESTM LMESTM commented May 29, 2019

Description

Update HAL Sleep manager test to cope with STM32 LPTIM HW

those changes are generic and should not create any regression to other targets, but are required for oncoming changes on STM targets (#10701)

In particular and as kindly suggested by Przemec S. :

  1. Add setup/teardown handler’s for all cases. This disables sys-tick, so there should be no unexpected lp ticker interrupt scheduling.
  2. Modify setup/teardown handler’s: remove suspension of lp/us tickers, so they can count as this is required by test_lock_unlock_test_check test case.
  3. Use TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep_test_check()) after setting interrupt to cope with STM specific handling (CMPOK interrupt with deep-sleep locked). This performs wait only if needed and will not affect other targets which do not need extra wait.
  4. Move sleep_manager_lock_deep_sleep() after TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep_test_check())
  5. Use TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep_test_check()) in
    test_lock_unlock_test_check to let lower layers manage deep sleep.

Pull request type

[ ] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ x] Test update
[ ] Breaking change

Reviewers

@jeromecoutant @mprse

Release Notes

@ciarmcom
Copy link
Member

@LMESTM, thank you for your changes.
@mprse @ARMmbed/mbed-os-test @ARMmbed/mbed-os-hal @ARMmbed/mbed-os-maintainers please review.

@LMESTM
Copy link
Contributor Author

LMESTM commented Jun 4, 2019

Updated to keep the code in test setup that make sure that tickers are initialized.

Copy link
Contributor

@mprse mprse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

TESTS/mbed_hal/sleep_manager/main.cpp Outdated Show resolved Hide resolved
In particular and as kindly suggested by Przemec S. :
1. Add setup/teardown handler’s for all cases. This disables sys-tick,
so there should be no unexpected lp ticker interrupt scheduling.
2. Modify setup/teardown handler’s: remove suspension of lp/us tickers,
so they can count as this is required by test_lock_unlock_test_check test
case.
3. Use TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep_test_check()) after
setting interrupt to cope with STM specific handling (CMPOK interrupt with
deep-sleep locked). This performs wait only if needed and will not affect
other targets which do not need extra wait.
4. Move sleep_manager_lock_deep_sleep() after TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep_test_check())
5. Use TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep_test_check()) in
test_lock_unlock_test_check to let lower layers manage deep sleep.
@LMESTM LMESTM force-pushed the hal_sleep_manager_test_update branch from acfb6f8 to d4db0f3 Compare June 7, 2019 14:38
@LMESTM
Copy link
Contributor Author

LMESTM commented Jun 7, 2019

@mprse I've updated the PR - could be great if you can help getting more reviews or starting CI

@LMESTM
Copy link
Contributor Author

LMESTM commented Jun 11, 2019

@0xc0170 who else needs to review ?

and avoid associated warning ...
@0xc0170 0xc0170 removed the request for review from a team June 14, 2019 09:59
@0xc0170
Copy link
Contributor

0xc0170 commented Jun 14, 2019

I'll review shortly

TESTS/mbed_hal/sleep_manager/main.cpp Outdated Show resolved Hide resolved
TESTS/mbed_hal/sleep_manager/main.cpp Outdated Show resolved Hide resolved
@mprse
Copy link
Contributor

mprse commented Jun 18, 2019

Hi @LMESTM @fkjagodzinski !

After the @fkjagodzinski review, I suggest modifying the test as follows: mprse@90880ff
mprse@90880ff . This will also require to change the sleep_manager_can_deep_sleep_test_check() function (mprse@e5a91a0), so it does not use ticker common layer. I think that since this function is generally designed for testing using the common ticker is not a good idea. I suggest using simple wait_ns() while waiting on unlocking deep-sleep.

BTW I added a loop in sleep_manager_can_deep_sleep_test_check() test to be sure it always works. It can be removed in the final version I think. I tested this solution on K64F, NUCLEO_F429ZI, NUCLEO_L073RZ, NUCLEO_F070RB.

@LMESTM
Copy link
Contributor Author

LMESTM commented Jun 18, 2019

@mprse
I also made and tested few changes to this PR to cope with feeedback from @fkjagodzinski
You can check the updated version.

Otherwise, how would you suggest to proceed : do you want to make a new PR to replace this one, or shall I cherry-pick your suggested commit if @fkjagodzinski agrees this is a better way forward ?

@LMESTM LMESTM force-pushed the hal_sleep_manager_test_update branch from 83e274a to db57cd0 Compare June 18, 2019 11:27
@mprse
Copy link
Contributor

mprse commented Jun 18, 2019

@mprse
I also made and tested few changes to this PR to cope with feeedback from @fkjagodzinski
You can check the updated version.

Otherwise, how would you suggest to proceed : do you want to make a new PR to replace this one, or shall I cherry-pick your suggested commit if @fkjagodzinski agrees this is a better way forward ?

I think we should continue this one. If you agree with proposed changes and they are also accepted by @fkjagodzinski feel free to cherry-pick or use provided commits to further changes.

@LMESTM
Copy link
Contributor Author

LMESTM commented Jun 18, 2019

@fkjagodzinski could you please provide feedback on @mprse changes before I consider including them into this PR ?

@mprse I'll rely on you explaining the changes even if I take them in this PR :-)

Changes:
- restore the original form of setup/teardown handlers,
- test_lock_unlock_test_check(): do not use common ticker layer (Timer, Timeout). Use only ticker HAL layer.
- Increase DEEP_SLEEP_TEST_CHECK_WAIT_DELTA_US delta.
With the DEEP_SLEEP_TEST_CHECK_WAIT_DELTA_US increased,
we now have TEST_ASSERT_UINT64_WITHIN(delta=1000, expected=1000, actual=1000)
so this assertion needed to be updated.

What we need is the deep sleep to be enabled after the programed interrupt
has fired and before a 2ms timeout expiration, which means >= 1000 and < 2000.
@LMESTM LMESTM force-pushed the hal_sleep_manager_test_update branch from 45a0fef to 8476be6 Compare June 19, 2019 13:33
@LMESTM
Copy link
Contributor Author

LMESTM commented Jun 19, 2019

Just fixed a minor astyle issue

@LMESTM
Copy link
Contributor Author

LMESTM commented Jun 20, 2019

@adbridge I think I've done the requested changes. I guess that Label needs work could be removed.

@adbridge
Copy link
Contributor

CI started

@mbed-ci
Copy link

mbed-ci commented Jun 24, 2019

Test run: FAILED

Summary: 2 of 11 test jobs failed
Build number : 1
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_greentea-test
  • jenkins-ci/mbed-os-ci_cloud-client-test

@LMESTM
Copy link
Contributor Author

LMESTM commented Jun 24, 2019

@fkjagodzinski @mprse Could you have a look at the CI failure root cause ?

@fkjagodzinski
Copy link
Member

fkjagodzinski commented Jun 24, 2019

@LMESTM the ticker_event_handler_stub() which is an interrupt handler used in test_lock_unlock_test_check() test case did not clear the interrupt. This caused the NRF51_DK & NRF52_DK to handle same interrupt again and again, and in consequence, starve the main thread.

You can cherry-pick my fix from: fkjagodzinski@318f195.

@LMESTM
Copy link
Contributor Author

LMESTM commented Jun 24, 2019

@fkjagodzinski Cherry-pick fails ... it seems you haven't taken my latest commit.
Could you rebase it ? Or do you mean that I need to replace my latest commits by mine ?

@fkjagodzinski
Copy link
Member

Cherry-pick fails ... it seems you haven't taken my latest commit.

Sorry about that; indeed, I used an outdated branch from your repo. Here is the new commit that should work fine: fkjagodzinski@a1436c5.

BTW, I've just noticed that NRF51_DK fires a bit early sometimes (976 us instead of >= 1000 us), so this assertion TEST_ASSERT(diff_us(start, stop, p_ticker_info) >= DEEP_SLEEP_TEST_CHECK_WAIT_US / 2); also has to be changed (included in my patch).

Add missing `lp_ticker_clear_interrupt()` in the interrput handler used
in `test_lock_unlock_test_check()` test.
Remove redefined `us_to_ticks()`.
@LMESTM
Copy link
Contributor Author

LMESTM commented Jun 24, 2019

Branch updated with your fix.
I'll start tests here.
EDIT:
Test results: Tested OK on 1 STM32 per family, as listed below:
['NUCLEO_F091RC', 'NUCLEO_F103RB', 'NUCLEO_F207ZG', 'NUCLEO_F303ZE', 'NUCLEO_F446RE', 'NUCLEO_F767ZI', 'NUCLEO_H743ZI', 'NUCLEO_L073RZ', 'NUCLEO_L152RE', 'NUCLEO_L476RG', 'NUCLEO_WB55RG']

@LMESTM
Copy link
Contributor Author

LMESTM commented Jun 27, 2019

@0xc0170 @adbridge - the issue found in CI should have been solved with fix from @fkjagodzinski now part of this PR - could you restart CI to check it's ok ?

@adbridge
Copy link
Contributor

CI started

@mbed-ci
Copy link

mbed-ci commented Jun 27, 2019

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 2
Build artifacts

@0xc0170 0xc0170 merged commit a2c9152 into ARMmbed:master Jun 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants