ztest: do teardown in main thread
If the test exits from some APIs like ztest_test_pass(), ztest_test_skip(), or a test crashes out, the teardown function is never run. Fixes: #16329 Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
9a9f0ed84a
commit
7d29f3b06e
1 changed files with 5 additions and 3 deletions
|
@ -146,9 +146,6 @@ static void run_test_functions(struct unit_test *test)
|
||||||
test->setup();
|
test->setup();
|
||||||
phase = TEST_PHASE_TEST;
|
phase = TEST_PHASE_TEST;
|
||||||
test->test();
|
test->test();
|
||||||
phase = TEST_PHASE_TEARDOWN;
|
|
||||||
test->teardown();
|
|
||||||
phase = TEST_PHASE_FRAMEWORK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef KERNEL
|
#ifndef KERNEL
|
||||||
|
@ -312,6 +309,11 @@ static int run_test(struct unit_test *test)
|
||||||
* phase": this will corrupt the kernel ready queue.
|
* phase": this will corrupt the kernel ready queue.
|
||||||
*/
|
*/
|
||||||
k_sem_take(&test_end_signal, K_FOREVER);
|
k_sem_take(&test_end_signal, K_FOREVER);
|
||||||
|
|
||||||
|
phase = TEST_PHASE_TEARDOWN;
|
||||||
|
test->teardown();
|
||||||
|
phase = TEST_PHASE_FRAMEWORK;
|
||||||
|
|
||||||
if (test_result == -1) {
|
if (test_result == -1) {
|
||||||
ret = TC_FAIL;
|
ret = TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue