Skip to content

Commit

Permalink
POSIX: Add tests for pthread_condattr
Browse files Browse the repository at this point in the history
Add test coverage for init, destroy, setclock, getclock

Signed-off-by: Mateusz Marszalek <matti.marszalek@gmail.com>
  • Loading branch information
Durchbruchswagen authored and mbolivar-ampere committed Aug 30, 2023
1 parent 61219da commit 295eb1b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/posix/common/src/pthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,28 @@ void *thread_top_term(void *p1)
return NULL;
}

ZTEST(posix_apis, test_pthread_condattr)
{
clockid_t clock_id;
pthread_condattr_t att;

zassert_ok(pthread_condattr_init(&att), "pthread_condattr_init failed");

zassert_ok(pthread_condattr_getclock(&att, &clock_id), "pthread_condattr_getclock failed");
zassert_equal(clock_id, CLOCK_MONOTONIC, "clock attribute not set correctly");

zassert_ok(pthread_condattr_setclock(&att, CLOCK_REALTIME),
"pthread_condattr_setclock failed");

zassert_ok(pthread_condattr_getclock(&att, &clock_id), "pthread_condattr_setclock failed");
zassert_equal(clock_id, CLOCK_REALTIME, "clock attribute not set correctly");

zassert_equal(pthread_condattr_setclock(&att, 42),
-EINVAL, "pthread_condattr_setclock did not return EINVAL");

zassert_ok(pthread_condattr_destroy(&att), "pthread_condattr_destroy failed");
}

ZTEST(posix_apis, test_pthread_execution)
{
int i, ret, min_prio, max_prio;
Expand Down

0 comments on commit 295eb1b

Please sign in to comment.