1 /*
2  * Copyright (c) 2024, Meta
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <errno.h>
8 #include <pthread.h>
9 
10 #include <zephyr/ztest.h>
11 
ZTEST(mutex_attr,test_pthread_mutexattr_init)12 ZTEST(mutex_attr, test_pthread_mutexattr_init)
13 {
14 	pthread_mutexattr_t attr;
15 
16 	/* degenerate cases */
17 	{
18 		zassert_equal(EINVAL, pthread_mutexattr_init(NULL));
19 	}
20 
21 	zassert_ok(pthread_mutexattr_init(&attr));
22 	zassert_ok(pthread_mutexattr_destroy(&attr));
23 }
24 
ZTEST(mutex_attr,test_pthread_mutexattr_destroy)25 ZTEST(mutex_attr, test_pthread_mutexattr_destroy)
26 {
27 	pthread_mutexattr_t attr;
28 
29 	/* degenerate cases */
30 	{
31 		if (false) {
32 			/* undefined behaviour */
33 			zassert_equal(EINVAL, pthread_mutexattr_destroy(&attr));
34 		}
35 		zassert_equal(EINVAL, pthread_mutexattr_destroy(NULL));
36 	}
37 
38 	zassert_ok(pthread_mutexattr_init(&attr));
39 	zassert_ok(pthread_mutexattr_destroy(&attr));
40 	if (false) {
41 		/* undefined behaviour */
42 		zassert_equal(EINVAL, pthread_mutexattr_destroy(&attr));
43 	}
44 }
45 
46 ZTEST_SUITE(mutex_attr, NULL, NULL, NULL, NULL, NULL);
47