Skip to content

Commit c080d1c

Browse files
committed
tests: posix: add test for pthread_cond_init with existing condattr
Introduce new test for pthread_cond_init verifying successful initialization with a valid pre-initialized condattr. Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
1 parent 0c1dca5 commit c080d1c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/posix/common/src/cond.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,20 @@ ZTEST(cond, test_pthread_condattr)
6969
zassert_ok(pthread_condattr_destroy(&att));
7070
}
7171

72+
/**
73+
* @brief Test pthread_cond_init() with a pre-existing initialized attribute.
74+
*/
75+
ZTEST(cond, test_cond_init_existing_initialized_condattr)
76+
{
77+
pthread_cond_t cond;
78+
pthread_condattr_t att = {0};
79+
80+
zassert_ok(pthread_condattr_init(&att));
81+
zassert_ok(pthread_cond_init(&cond, &att), "pthread_cond_init failed with valid attr");
82+
83+
/* Clean up */
84+
zassert_ok(pthread_cond_destroy(&cond));
85+
zassert_ok(pthread_condattr_destroy(&att));
86+
}
87+
7288
ZTEST_SUITE(cond, NULL, NULL, NULL, NULL, NULL);

0 commit comments

Comments
 (0)