Join GitHub today
schedule_api test uses zassert without cleaning up properly #3666
Reported by Andrew Boie:
The problem is the zassert() calls in the test functions. If any fail, the functions are immediately aborted without calling teardown_threads().
Then, in the next test case, it will try to spawn the same threads again, which leads to undefined behavior, on ARM we are seeing hardfaults. See GH-3657
Either fix the test case so that all cleanup is done before zasserts are called,
(Imported from Jira ZEP-2230)
by Sharron LIU:
The test case itself supposed to keep the original logic to ensure assertion is made before test exiting, which is expected in the normal test flow.
As per the details provided in #3657, when there is any zassert failure, the threads are not terminated or clean up of threads (teardown_threads()) are not called, causing next set of tests to crash. (as the thread to be instantiated is already existing).
This issue is no more seen. I tried to reproduce the issue by causing zassert condition to fail, see the code below:
but ztest handles the assert failures gracefully and doesn't propagate any crash. See the execution log below with the code changes mentioned above:
Tested on nrf51_pca10028:
So, the issue reported is no more seen and the issue can be closed.