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: finish UART transmission before sleep test #8257

Merged
merged 2 commits into from Oct 5, 2018

Conversation

Projects
None yet
5 participants
@mprse
Member

mprse commented Sep 26, 2018

Description

There is no problem with this test during the morph, but some issue has been noticed while testing new Jenkins CI in Oulu on NRF52_DK.
I was able to reproduce the issue locally. The difference between morph and local run is that CPU statistics are enabled on morph. This makes the difference and test passes.

The sleep test case perform sleep for 100 us, 200 us, ... ,1000 us in loop (us ticker wakes the board) and verifies if sleep time matches the assumption.
I got the following results in case of failure:

sleep                 wake-up after
100 us                   ~100 us    ok
200 us                   ~200 us    ok
300 us                   ~300 us    ok
400 us                   ~400 us    ok
500 us                   ~14 us     (??)

When requested sleep time is equal to 500 us some unexpected interrupt occurs which wake-up the board and force the test to fail.
Register state just after exit from sleep:
Control and State Register: 0x00400000 (ISRPENDING - Interrupt pending flag is set).
NVIC Interrupt Set-pending Register[0]: 0x00000004 (UARTE0_UART0_IRQn) or 0x00000200 (TIMER1_IRQn - timer used by us ticker).

UART interrupt is generated because of green-tea transmission. We know that it is performed while test is executed since we need to wait before going into deep-sleep because otherwise the transmission will be broken. So to take care of UART interrupt we need to wait before sleep test in the same way like it is done in deep-sleep test.

Pull request type

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

@jamesbeyond Can you confirm that this patch fixes problem with this test on the new Jenkins CI?

tests-mbed_hal-sleep: finish UART transmission before sleep test
There is no problem with this test during the morph, but some issue has been noticed while testing new Jenkins CI in Oulu on NRF52_DK.
I was able to reproduce the issue locally. The difference between morph and local run is that CPU statistics are enabled on morph. This makes the difference and test passes.

The sleep test case perform sleep for 100 us, 200 us, ... ,1000 us in loop (us ticker wakes the board) and verifies if sleep time matches the assumption.
I got the following results:

sleep                 wake-up after
100 us                   ~100 us    ok
200 us                   ~200 us    ok
300 us                   ~300 us    ok
400 us                   ~400 us    ok
500 us                   ~14 us     (??)

When requested sleep time is equal to 500 us some unexpected interrupt occurs which wakeup the board and force the test to fail.
Register state just after exit from sleep:
Control and State Register: 0x00400000 (ISRPENDING - Interrupt pending flag is set).
NVIC Interrupt Set-pending Register[0]: 0x00000004 (UARTE0_UART0_IRQn) or 0x00000200 (TIMER1_IRQn - timer used by us ticker).

UART interrupt is generated because of green-tea transmission. We know that it is performed while test is executed since we need to wait before going into deep-sleep since otherwise the transmission will be broken. So to take care of UART interrupt we need to wait before sleep test in the same way like it is done in deep-sleep test.
@jamesbeyond

@mprse I can confirm this fix works on the new Oulu CI. NRF52_DK pass all the tests
Good job for digging out the real reason caused this problem!

Another thing is could you improved the error thrown out from the test in:
https://github.com/ARMmbed/mbed-os/blob/master/TESTS/mbed_hal/sleep/main.cpp#L159
https://github.com/ARMmbed/mbed-os/blob/master/TESTS/mbed_hal/sleep/main.cpp#L200
https://github.com/ARMmbed/mbed-os/blob/master/TESTS/mbed_hal/sleep/main.cpp#L244
The test error messages are not really helping:

[1537949816.01][CONN][RXD] >>> Running case #1: 'sleep - source of wake-up - us ticker'...
[1537949816.01][CONN][INF] found KV pair in stream: {{__testcase_name;deep-sleep - high-speed clocks are turned off}}, queued...
[1537949816.12][CONN][RXD] :161::FAIL: Expression Evaluated To FALSE
[1537949816.12][CONN][INF] found KV pair in stream: {{__testcase_start;sleep - source of wake-up - us ticker}}, queued...
[1537949816.22][CONN][RXD] :161::FAIL: Expression Evaluated To FALSE
[1537949816.22][CONN][RXD] :161::FAIL: Expression Evaluated To FALSE
[1537949816.34][CONN][INF] found KV pair in stream: {{__testcase_finish;sleep - source of wake-up - us ticker;0;3}}, queued...
[1537949816.40][CONN][RXD] >>> 'sleep - source of wake-up - us ticker': 0 passed, 3 failed with reason 'Test Cases Failed'

it didn't give much info, like what is the sleep time, what is the expected, what is the actual value etc.
Maybe we could use TEST_ASSERT_MESAGE macro instead?

@jeromecoutant

This comment has been minimized.

Contributor

jeromecoutant commented Sep 27, 2018

Hi
Note that fix for this issue is waiting for #4408 HAL correction

@mprse

This comment has been minimized.

Member

mprse commented Sep 27, 2018

@jamesbeyond Ohh, I forgot to add some additional info about the failure. I will add this on Monday.

@mprse

This comment has been minimized.

Member

mprse commented Sep 30, 2018

@jamesbeyond Fixed as suggested.

@jamesbeyond

Looks good! Thanks

@0xc0170

0xc0170 approved these changes Oct 1, 2018

@0xc0170

This comment has been minimized.

Member

0xc0170 commented Oct 1, 2018

/morph build

@mbed-ci

This comment has been minimized.

mbed-ci commented Oct 1, 2018

Build : SUCCESS

Build number : 3207
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/8257/

Triggering tests

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

@mbed-ci

This comment has been minimized.

@mbed-ci

This comment has been minimized.

@0xc0170

This comment has been minimized.

Member

0xc0170 commented Oct 2, 2018

Aborted early, there's at least one failure not related to this patch, I am trying to reproduce this locally

@0xc0170 0xc0170 added needs: CI and removed needs: review labels Oct 4, 2018

@0xc0170

This comment has been minimized.

Member

0xc0170 commented Oct 4, 2018

/morph export-build

@mbed-ci

This comment has been minimized.

@0xc0170

This comment has been minimized.

Member

0xc0170 commented Oct 5, 2018

/morph export-build

@mbed-ci

This comment has been minimized.

@0xc0170 0xc0170 merged commit 9d39f23 into ARMmbed:master Oct 5, 2018

15 checks passed

ci-morph-build build completed
Details
ci-morph-exporter build completed
Details
ci-morph-mbed2-build build completed
Details
ci-morph-test test completed , RTOS ROM(+0.0%) RAM(+0.0%)
Details
continuous-integration/jenkins/pr-head This commit looks good
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
jenkins-ci/cloud_client_smoke_test Success
Details
jenkins-ci/unittests Success
Details
travis-ci/astyle Passed, 627 files
Details
travis-ci/docs Local docs testing has passed
Details
travis-ci/events Passed, runtime is 10513 cycles (+520 cycles)
Details
travis-ci/gitattributestest Local gitattributestest testing has passed
Details
travis-ci/licence_check Local licence_check testing has passed
Details
travis-ci/littlefs Passed, code size is 8372B (+0.00%)
Details
travis-ci/tools-py2.7 Local tools-py2.7 testing has passed
Details

@0xc0170 0xc0170 removed the ready for merge label Oct 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment