Skip to content

Commit 0d702f3

Browse files
committed
tests: posix: pthread: correct cases for pthread_timedjoin_np()
pthread_timedjoin_np() is allowed to take a negative tv_sec parameter, since that is still a valid timespec. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
1 parent a4e41f4 commit 0d702f3

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

tests/posix/common/src/pthread.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,8 @@ ZTEST(pthread, test_pthread_timedjoin)
404404
struct timespec not_done;
405405
struct timespec done;
406406
struct timespec invalid[] = {
407-
[0] = {.tv_sec = -1},
408-
[1] = {.tv_nsec = -1},
409-
[2] = {.tv_nsec = NSEC_PER_SEC},
407+
{.tv_nsec = -1},
408+
{.tv_nsec = NSEC_PER_SEC},
410409
};
411410

412411
/* setup timespecs when the thread is still running and when it is done */
@@ -426,7 +425,7 @@ ZTEST(pthread, test_pthread_timedjoin)
426425
/* Creating a thread that exits after 200ms*/
427426
zassert_ok(pthread_create(&th, NULL, timedjoin_thread, INT_TO_POINTER(sleep_duration_ms)));
428427

429-
/* pthread_timedjoin-np must return -EINVAL for invalid struct timespecs */
428+
/* pthread_timedjoin-np must return EINVAL for invalid struct timespecs */
430429
zassert_equal(pthread_timedjoin_np(th, &ret, NULL), EINVAL);
431430
for (size_t i = 0; i < ARRAY_SIZE(invalid); ++i) {
432431
zassert_equal(pthread_timedjoin_np(th, &ret, &invalid[i]), EINVAL);

0 commit comments

Comments
 (0)