Skip to content

tests-mbed_hal-sleep: finish UART transmission before sleep test #8257

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

Merged
merged 2 commits into from
Oct 5, 2018

Conversation

mprse
Copy link
Contributor

@mprse 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?

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.
Copy link
Contributor

@jamesbeyond jamesbeyond left a comment

Choose a reason for hiding this comment

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

@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
Copy link
Collaborator

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

@mprse
Copy link
Contributor Author

mprse commented Sep 27, 2018

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

@mprse
Copy link
Contributor Author

mprse commented Sep 30, 2018

@jamesbeyond Fixed as suggested.

Copy link
Contributor

@jamesbeyond jamesbeyond left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 1, 2018

/morph build

@mbed-ci
Copy link

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
Copy link

mbed-ci commented Oct 2, 2018

@mbed-ci
Copy link

mbed-ci commented Oct 2, 2018

@0xc0170
Copy link
Contributor

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
Copy link
Contributor

0xc0170 commented Oct 4, 2018

/morph export-build

@mbed-ci
Copy link

mbed-ci commented Oct 4, 2018

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 5, 2018

/morph export-build

@mbed-ci
Copy link

mbed-ci commented Oct 5, 2018

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.

5 participants