From f4be0ee859ae888cf5b8b18d4696c0021339e506 Mon Sep 17 00:00:00 2001 From: Chris Friedt Date: Mon, 20 May 2024 22:31:54 -0400 Subject: [PATCH] tests: posix: headers: check some structs only when posix_api=y Some POSIX header tests assumed that various structures would be declared even if POSIX_API=n. Actually most meaningful POSIX structures are guarded by feature test macros defined by the implementation (i.e. implementation conformance macros). So only run tests on those structures when CONFIG_POSIX_API=y. Signed-off-by: Chris Friedt --- tests/posix/headers/src/dirent_h.c | 26 ++-- tests/posix/headers/src/pthread_h.c | 202 ++++++++++++++-------------- 2 files changed, 114 insertions(+), 114 deletions(-) diff --git a/tests/posix/headers/src/dirent_h.c b/tests/posix/headers/src/dirent_h.c index ca5527603c0..dc7ef4ba8aa 100644 --- a/tests/posix/headers/src/dirent_h.c +++ b/tests/posix/headers/src/dirent_h.c @@ -19,22 +19,22 @@ */ ZTEST(posix_headers, test_dirent_h) { +#ifdef CONFIG_POSIX_API zassert_not_equal((DIR *)-1, (DIR *)NULL); zassert_not_equal(-1, offsetof(struct dirent, d_ino)); zassert_not_equal(-1, offsetof(struct dirent, d_name)); - if (IS_ENABLED(CONFIG_POSIX_API)) { - /* zassert_not_null(alphasort); */ /* not implemented */ - zassert_not_null(closedir); - /* zassert_not_null(dirfd); */ /* not implemented */ - /* zassert_not_null(fdopendir); */ /* not implemented */ - zassert_not_null(opendir); - zassert_not_null(readdir); - /* zassert_not_null(readdir_r); */ /* not implemented */ - /* zassert_not_null(rewinddir); */ /* not implemented */ - /* zassert_not_null(scandir); */ /* not implemented */ - /* zassert_not_null(seekdir); */ /* not implemented */ - /* zassert_not_null(telldir); */ /* not implemented */ - } + /* zassert_not_null(alphasort); */ /* not implemented */ + zassert_not_null(closedir); + /* zassert_not_null(dirfd); */ /* not implemented */ + /* zassert_not_null(fdopendir); */ /* not implemented */ + zassert_not_null(opendir); + zassert_not_null(readdir); + /* zassert_not_null(readdir_r); */ /* not implemented */ + /* zassert_not_null(rewinddir); */ /* not implemented */ + /* zassert_not_null(scandir); */ /* not implemented */ + /* zassert_not_null(seekdir); */ /* not implemented */ + /* zassert_not_null(telldir); */ /* not implemented */ +#endif } diff --git a/tests/posix/headers/src/pthread_h.c b/tests/posix/headers/src/pthread_h.c index fdf9b66c1ae..4363d3b4764 100644 --- a/tests/posix/headers/src/pthread_h.c +++ b/tests/posix/headers/src/pthread_h.c @@ -21,6 +21,7 @@ */ ZTEST(posix_headers, test_pthread_h) { +#ifdef CONFIG_POSIX_API zassert_not_equal(-1, PTHREAD_BARRIER_SERIAL_THREAD); zassert_not_equal(-1, PTHREAD_CANCEL_ASYNCHRONOUS); @@ -41,7 +42,7 @@ ZTEST(posix_headers, test_pthread_h) zassert_not_equal(-1, PTHREAD_MUTEX_ERRORCHECK); zassert_not_equal(-1, PTHREAD_MUTEX_ERRORCHECK); zassert_not_equal(-1, PTHREAD_MUTEX_RECURSIVE); - /* zassert_not_equal(-1, PTHREAD_MUTEX_ROBUST); */ /* not implemented */ + /* zassert_not_equal(-1, PTHREAD_MUTEX_ROBUST); */ /* not implemented */ /* zassert_not_equal(-1, PTHREAD_MUTEX_STALLED); */ /* not implemented */ pthread_once_t once = PTHREAD_ONCE_INIT; @@ -60,105 +61,104 @@ ZTEST(posix_headers, test_pthread_h) pthread_mutex_t mu = PTHREAD_MUTEX_INITIALIZER; /* pthread_rwlock_t lock = PTHREAD_RWLOCK_INITIALIZER; */ /* not implemented */ - if (IS_ENABLED(CONFIG_POSIX_API)) { - zassert_not_null(pthread_atfork); - zassert_not_null(pthread_attr_destroy); - zassert_not_null(pthread_attr_getdetachstate); - zassert_not_null(pthread_attr_getguardsize); - zassert_not_null(pthread_attr_getinheritsched); - zassert_not_null(pthread_attr_getschedparam); - zassert_not_null(pthread_attr_getschedpolicy); - zassert_not_null(pthread_attr_getscope); - zassert_not_null(pthread_attr_getstack); - zassert_not_null(pthread_attr_getstacksize); - zassert_not_null(pthread_attr_init); - zassert_not_null(pthread_attr_setdetachstate); - zassert_not_null(pthread_attr_setguardsize); - zassert_not_null(pthread_attr_setinheritsched); - zassert_not_null(pthread_attr_setschedparam); - zassert_not_null(pthread_attr_setschedpolicy); - zassert_not_null(pthread_attr_setscope); - zassert_not_null(pthread_attr_setstack); - zassert_not_null(pthread_attr_setstacksize); - zassert_not_null(pthread_barrier_destroy); - zassert_not_null(pthread_barrier_init); - zassert_not_null(pthread_barrier_wait); - zassert_not_null(pthread_barrierattr_destroy); - /* zassert_not_null(pthread_barrierattr_getpshared); */ /* not implemented */ - zassert_not_null(pthread_barrierattr_init); - /* zassert_not_null(pthread_barrierattr_setpshared); */ /* not implemented */ - zassert_not_null(pthread_cancel); - zassert_not_null(pthread_cond_broadcast); - zassert_not_null(pthread_cond_destroy); - zassert_not_null(pthread_cond_init); - zassert_not_null(pthread_cond_signal); - zassert_not_null(pthread_cond_timedwait); - zassert_not_null(pthread_cond_wait); - zassert_not_null(pthread_condattr_destroy); - zassert_not_null(pthread_condattr_getclock); - /* zassert_not_null(pthread_condattr_getpshared); */ /* not implemented */ - zassert_not_null(pthread_condattr_init); - zassert_not_null(pthread_condattr_setclock); - /* zassert_not_null(pthread_condattr_setpshared); */ /* not implemented */ - zassert_not_null(pthread_create); - zassert_not_null(pthread_detach); - zassert_not_null(pthread_equal); - zassert_not_null(pthread_exit); - zassert_not_null(pthread_getconcurrency); - /* zassert_not_null(pthread_getcpuclockid); */ /* not implemented */ - zassert_not_null(pthread_getschedparam); - zassert_not_null(pthread_getspecific); - zassert_not_null(pthread_join); - zassert_not_null(pthread_key_create); - zassert_not_null(pthread_key_delete); - /* zassert_not_null(pthread_mutex_consistent); */ /* not implemented */ - zassert_not_null(pthread_mutex_destroy); - /* zassert_not_null(pthread_mutex_getprioceiling); */ /* not implemented */ - zassert_not_null(pthread_mutex_init); - zassert_not_null(pthread_mutex_lock); - /* zassert_not_null(pthread_mutex_setprioceiling); */ /* not implemented */ - zassert_not_null(pthread_mutex_timedlock); - zassert_not_null(pthread_mutex_trylock); - zassert_not_null(pthread_mutex_unlock); - zassert_not_null(pthread_mutexattr_destroy); - /* zassert_not_null(pthread_mutexattr_getprioceiling); */ /* not implemented */ - zassert_not_null(pthread_mutexattr_getprotocol); - /* zassert_not_null(pthread_mutexattr_getpshared); */ /* not implemented */ - /* zassert_not_null(pthread_mutexattr_getrobust); */ /* not implemented */ - zassert_not_null(pthread_mutexattr_gettype); - zassert_not_null(pthread_mutexattr_init); - /* zassert_not_null(pthread_mutexattr_setprioceiling); */ /* not implemented */ - /* zassert_not_null(pthread_mutexattr_setprotocol); */ /* not implemented */ - /* zassert_not_null(pthread_mutexattr_setpshared); */ /* not implemented */ - /* zassert_not_null(pthread_mutexattr_setrobust); */ /* not implemented */ - zassert_not_null(pthread_mutexattr_settype); - zassert_not_null(pthread_once); - zassert_not_null(pthread_rwlock_destroy); - zassert_not_null(pthread_rwlock_init); - zassert_not_null(pthread_rwlock_rdlock); - zassert_not_null(pthread_rwlock_timedrdlock); - zassert_not_null(pthread_rwlock_timedwrlock); - zassert_not_null(pthread_rwlock_tryrdlock); - zassert_not_null(pthread_rwlock_trywrlock); - zassert_not_null(pthread_rwlock_unlock); - zassert_not_null(pthread_rwlock_wrlock); - zassert_not_null(pthread_rwlockattr_destroy); - zassert_not_null(pthread_rwlockattr_getpshared); - zassert_not_null(pthread_rwlockattr_init); - zassert_not_null(pthread_rwlockattr_setpshared); - zassert_not_null(pthread_self); - zassert_not_null(pthread_setcancelstate); - zassert_not_null(pthread_setcanceltype); - zassert_not_null(pthread_setconcurrency); - zassert_not_null(pthread_setschedparam); - zassert_not_null(pthread_setschedprio); - zassert_not_null(pthread_setspecific); - zassert_not_null(pthread_spin_destroy); - zassert_not_null(pthread_spin_init); - zassert_not_null(pthread_spin_lock); - zassert_not_null(pthread_spin_trylock); - zassert_not_null(pthread_spin_unlock); - zassert_not_null(pthread_testcancel); - } + zassert_not_null(pthread_atfork); + zassert_not_null(pthread_attr_destroy); + zassert_not_null(pthread_attr_getdetachstate); + zassert_not_null(pthread_attr_getguardsize); + zassert_not_null(pthread_attr_getinheritsched); + zassert_not_null(pthread_attr_getschedparam); + zassert_not_null(pthread_attr_getschedpolicy); + zassert_not_null(pthread_attr_getscope); + zassert_not_null(pthread_attr_getstack); + zassert_not_null(pthread_attr_getstacksize); + zassert_not_null(pthread_attr_init); + zassert_not_null(pthread_attr_setdetachstate); + zassert_not_null(pthread_attr_setguardsize); + zassert_not_null(pthread_attr_setinheritsched); + zassert_not_null(pthread_attr_setschedparam); + zassert_not_null(pthread_attr_setschedpolicy); + zassert_not_null(pthread_attr_setscope); + zassert_not_null(pthread_attr_setstack); + zassert_not_null(pthread_attr_setstacksize); + zassert_not_null(pthread_barrier_destroy); + zassert_not_null(pthread_barrier_init); + zassert_not_null(pthread_barrier_wait); + zassert_not_null(pthread_barrierattr_destroy); + /* zassert_not_null(pthread_barrierattr_getpshared); */ /* not implemented */ + zassert_not_null(pthread_barrierattr_init); + /* zassert_not_null(pthread_barrierattr_setpshared); */ /* not implemented */ + zassert_not_null(pthread_cancel); + zassert_not_null(pthread_cond_broadcast); + zassert_not_null(pthread_cond_destroy); + zassert_not_null(pthread_cond_init); + zassert_not_null(pthread_cond_signal); + zassert_not_null(pthread_cond_timedwait); + zassert_not_null(pthread_cond_wait); + zassert_not_null(pthread_condattr_destroy); + zassert_not_null(pthread_condattr_getclock); + /* zassert_not_null(pthread_condattr_getpshared); */ /* not implemented */ + zassert_not_null(pthread_condattr_init); + zassert_not_null(pthread_condattr_setclock); + /* zassert_not_null(pthread_condattr_setpshared); */ /* not implemented */ + zassert_not_null(pthread_create); + zassert_not_null(pthread_detach); + zassert_not_null(pthread_equal); + zassert_not_null(pthread_exit); + zassert_not_null(pthread_getconcurrency); + /* zassert_not_null(pthread_getcpuclockid); */ /* not implemented */ + zassert_not_null(pthread_getschedparam); + zassert_not_null(pthread_getspecific); + zassert_not_null(pthread_join); + zassert_not_null(pthread_key_create); + zassert_not_null(pthread_key_delete); + /* zassert_not_null(pthread_mutex_consistent); */ /* not implemented */ + zassert_not_null(pthread_mutex_destroy); + /* zassert_not_null(pthread_mutex_getprioceiling); */ /* not implemented */ + zassert_not_null(pthread_mutex_init); + zassert_not_null(pthread_mutex_lock); + /* zassert_not_null(pthread_mutex_setprioceiling); */ /* not implemented */ + zassert_not_null(pthread_mutex_timedlock); + zassert_not_null(pthread_mutex_trylock); + zassert_not_null(pthread_mutex_unlock); + zassert_not_null(pthread_mutexattr_destroy); + /* zassert_not_null(pthread_mutexattr_getprioceiling); */ /* not implemented */ + zassert_not_null(pthread_mutexattr_getprotocol); + /* zassert_not_null(pthread_mutexattr_getpshared); */ /* not implemented */ + /* zassert_not_null(pthread_mutexattr_getrobust); */ /* not implemented */ + zassert_not_null(pthread_mutexattr_gettype); + zassert_not_null(pthread_mutexattr_init); + /* zassert_not_null(pthread_mutexattr_setprioceiling); */ /* not implemented */ + /* zassert_not_null(pthread_mutexattr_setprotocol); */ /* not implemented */ + /* zassert_not_null(pthread_mutexattr_setpshared); */ /* not implemented */ + /* zassert_not_null(pthread_mutexattr_setrobust); */ /* not implemented */ + zassert_not_null(pthread_mutexattr_settype); + zassert_not_null(pthread_once); + zassert_not_null(pthread_rwlock_destroy); + zassert_not_null(pthread_rwlock_init); + zassert_not_null(pthread_rwlock_rdlock); + zassert_not_null(pthread_rwlock_timedrdlock); + zassert_not_null(pthread_rwlock_timedwrlock); + zassert_not_null(pthread_rwlock_tryrdlock); + zassert_not_null(pthread_rwlock_trywrlock); + zassert_not_null(pthread_rwlock_unlock); + zassert_not_null(pthread_rwlock_wrlock); + zassert_not_null(pthread_rwlockattr_destroy); + zassert_not_null(pthread_rwlockattr_getpshared); + zassert_not_null(pthread_rwlockattr_init); + zassert_not_null(pthread_rwlockattr_setpshared); + zassert_not_null(pthread_self); + zassert_not_null(pthread_setcancelstate); + zassert_not_null(pthread_setcanceltype); + zassert_not_null(pthread_setconcurrency); + zassert_not_null(pthread_setschedparam); + zassert_not_null(pthread_setschedprio); + zassert_not_null(pthread_setspecific); + zassert_not_null(pthread_spin_destroy); + zassert_not_null(pthread_spin_init); + zassert_not_null(pthread_spin_lock); + zassert_not_null(pthread_spin_trylock); + zassert_not_null(pthread_spin_unlock); + zassert_not_null(pthread_testcancel); +#endif } #pragma GCC diagnostic pop