|
10 | 10 | #include <zephyr/sys/util.h> |
11 | 11 | #include <zephyr/ztest.h> |
12 | 12 |
|
| 13 | +#define DETACH_THR_ID 2 |
| 14 | + |
13 | 15 | #define N_THR_E 3 |
14 | 16 | #define N_THR_T 4 |
15 | 17 | #define BOUNCES 64 |
@@ -202,7 +204,7 @@ static void *thread_top_term(void *p1) |
202 | 204 | zassert_false(ret, "Unable to set cancel state!"); |
203 | 205 | } |
204 | 206 |
|
205 | | - if (id >= 2) { |
| 207 | + if (id >= DETACH_THR_ID) { |
206 | 208 | zassert_ok(pthread_detach(self), "failed to set detach state"); |
207 | 209 | zassert_equal(pthread_detach(self), EINVAL, "re-detached thread!"); |
208 | 210 | } |
@@ -355,15 +357,17 @@ ZTEST(pthread, test_pthread_termination) |
355 | 357 | zassert_equal(ret, EINVAL, "invalid cancel state set!"); |
356 | 358 |
|
357 | 359 | for (i = 0; i < N_THR_T; i++) { |
358 | | - pthread_join(newthread[i], &retval); |
| 360 | + if (i < DETACH_THR_ID) { |
| 361 | + zassert_ok(pthread_join(newthread[i], &retval)); |
| 362 | + } |
359 | 363 | } |
360 | 364 |
|
361 | 365 | /* TESTPOINT: Test for deadlock */ |
362 | 366 | ret = pthread_join(pthread_self(), &retval); |
363 | 367 | zassert_equal(ret, EDEADLK, "thread joined with self inexplicably!"); |
364 | 368 |
|
365 | 369 | /* TESTPOINT: Try canceling a terminated thread */ |
366 | | - ret = pthread_cancel(newthread[N_THR_T/2]); |
| 370 | + ret = pthread_cancel(newthread[0]); |
367 | 371 | zassert_equal(ret, ESRCH, "cancelled a terminated thread!"); |
368 | 372 | } |
369 | 373 |
|
|
0 commit comments