tests: kernel/common: fix inadequate failing to thread context
The thread context test has insufficient checkings for failing so add them: () The variable rv for pass/fail is set but never checked. So add a check to fail the test if such indicated. () Each thread's pass variable is set to TC_FAIL (== 1) and the check for successful thread execution simply checks if pass variable is not zero, which is always true. So change it so the check for failing condition is reasonable. Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
parent
b46916484a
commit
45940cf8cf
1 changed files with 6 additions and 2 deletions
|
@ -51,7 +51,7 @@ static void errno_thread(void *_n, void *_my_errno, void *_unused)
|
|||
|
||||
k_msleep(30 - (n * 10));
|
||||
if (errno == my_errno) {
|
||||
result[n].pass = 1;
|
||||
result[n].pass = TC_PASS;
|
||||
}
|
||||
|
||||
zassert_equal(errno, my_errno, NULL);
|
||||
|
@ -91,7 +91,7 @@ void test_thread_context(void)
|
|||
for (int ii = 0; ii < N_THREADS; ii++) {
|
||||
struct result *p = k_fifo_get(&fifo, K_MSEC(100));
|
||||
|
||||
if (!p || !p->pass) {
|
||||
if (!p || (p->pass != TC_PASS)) {
|
||||
rv = TC_FAIL;
|
||||
}
|
||||
}
|
||||
|
@ -106,6 +106,10 @@ void test_thread_context(void)
|
|||
for (int ii = 0; ii < N_THREADS; ii++) {
|
||||
k_thread_join(&threads[ii], K_FOREVER);
|
||||
}
|
||||
|
||||
if (rv != TC_PASS) {
|
||||
ztest_test_fail();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue