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 <cfriedt@tenstorrent.com>
This commit is contained in:
Chris Friedt 2024-05-20 22:31:54 -04:00 committed by David Leach
commit f4be0ee859
2 changed files with 114 additions and 114 deletions

View file

@ -19,22 +19,22 @@
*/ */
ZTEST(posix_headers, test_dirent_h) ZTEST(posix_headers, test_dirent_h)
{ {
#ifdef CONFIG_POSIX_API
zassert_not_equal((DIR *)-1, (DIR *)NULL); zassert_not_equal((DIR *)-1, (DIR *)NULL);
zassert_not_equal(-1, offsetof(struct dirent, d_ino)); zassert_not_equal(-1, offsetof(struct dirent, d_ino));
zassert_not_equal(-1, offsetof(struct dirent, d_name)); zassert_not_equal(-1, offsetof(struct dirent, d_name));
if (IS_ENABLED(CONFIG_POSIX_API)) { /* zassert_not_null(alphasort); */ /* not implemented */
/* zassert_not_null(alphasort); */ /* not implemented */ zassert_not_null(closedir);
zassert_not_null(closedir); /* zassert_not_null(dirfd); */ /* not implemented */
/* zassert_not_null(dirfd); */ /* not implemented */ /* zassert_not_null(fdopendir); */ /* not implemented */
/* zassert_not_null(fdopendir); */ /* not implemented */ zassert_not_null(opendir);
zassert_not_null(opendir); zassert_not_null(readdir);
zassert_not_null(readdir); /* zassert_not_null(readdir_r); */ /* not implemented */
/* zassert_not_null(readdir_r); */ /* not implemented */ /* zassert_not_null(rewinddir); */ /* not implemented */
/* zassert_not_null(rewinddir); */ /* not implemented */ /* zassert_not_null(scandir); */ /* not implemented */
/* zassert_not_null(scandir); */ /* not implemented */ /* zassert_not_null(seekdir); */ /* not implemented */
/* zassert_not_null(seekdir); */ /* not implemented */ /* zassert_not_null(telldir); */ /* not implemented */
/* zassert_not_null(telldir); */ /* not implemented */ #endif
}
} }

View file

@ -21,6 +21,7 @@
*/ */
ZTEST(posix_headers, test_pthread_h) ZTEST(posix_headers, test_pthread_h)
{ {
#ifdef CONFIG_POSIX_API
zassert_not_equal(-1, PTHREAD_BARRIER_SERIAL_THREAD); zassert_not_equal(-1, PTHREAD_BARRIER_SERIAL_THREAD);
zassert_not_equal(-1, PTHREAD_CANCEL_ASYNCHRONOUS); 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_ERRORCHECK); zassert_not_equal(-1, PTHREAD_MUTEX_ERRORCHECK);
zassert_not_equal(-1, PTHREAD_MUTEX_RECURSIVE); 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 */ /* zassert_not_equal(-1, PTHREAD_MUTEX_STALLED); */ /* not implemented */
pthread_once_t once = PTHREAD_ONCE_INIT; 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_mutex_t mu = PTHREAD_MUTEX_INITIALIZER;
/* pthread_rwlock_t lock = PTHREAD_RWLOCK_INITIALIZER; */ /* not implemented */ /* pthread_rwlock_t lock = PTHREAD_RWLOCK_INITIALIZER; */ /* not implemented */
if (IS_ENABLED(CONFIG_POSIX_API)) { zassert_not_null(pthread_atfork);
zassert_not_null(pthread_atfork); zassert_not_null(pthread_attr_destroy);
zassert_not_null(pthread_attr_destroy); zassert_not_null(pthread_attr_getdetachstate);
zassert_not_null(pthread_attr_getdetachstate); zassert_not_null(pthread_attr_getguardsize);
zassert_not_null(pthread_attr_getguardsize); zassert_not_null(pthread_attr_getinheritsched);
zassert_not_null(pthread_attr_getinheritsched); zassert_not_null(pthread_attr_getschedparam);
zassert_not_null(pthread_attr_getschedparam); zassert_not_null(pthread_attr_getschedpolicy);
zassert_not_null(pthread_attr_getschedpolicy); zassert_not_null(pthread_attr_getscope);
zassert_not_null(pthread_attr_getscope); zassert_not_null(pthread_attr_getstack);
zassert_not_null(pthread_attr_getstack); zassert_not_null(pthread_attr_getstacksize);
zassert_not_null(pthread_attr_getstacksize); zassert_not_null(pthread_attr_init);
zassert_not_null(pthread_attr_init); zassert_not_null(pthread_attr_setdetachstate);
zassert_not_null(pthread_attr_setdetachstate); zassert_not_null(pthread_attr_setguardsize);
zassert_not_null(pthread_attr_setguardsize); zassert_not_null(pthread_attr_setinheritsched);
zassert_not_null(pthread_attr_setinheritsched); zassert_not_null(pthread_attr_setschedparam);
zassert_not_null(pthread_attr_setschedparam); zassert_not_null(pthread_attr_setschedpolicy);
zassert_not_null(pthread_attr_setschedpolicy); zassert_not_null(pthread_attr_setscope);
zassert_not_null(pthread_attr_setscope); zassert_not_null(pthread_attr_setstack);
zassert_not_null(pthread_attr_setstack); zassert_not_null(pthread_attr_setstacksize);
zassert_not_null(pthread_attr_setstacksize); zassert_not_null(pthread_barrier_destroy);
zassert_not_null(pthread_barrier_destroy); zassert_not_null(pthread_barrier_init);
zassert_not_null(pthread_barrier_init); zassert_not_null(pthread_barrier_wait);
zassert_not_null(pthread_barrier_wait); zassert_not_null(pthread_barrierattr_destroy);
zassert_not_null(pthread_barrierattr_destroy); /* zassert_not_null(pthread_barrierattr_getpshared); */ /* not implemented */
/* zassert_not_null(pthread_barrierattr_getpshared); */ /* not implemented */ zassert_not_null(pthread_barrierattr_init);
zassert_not_null(pthread_barrierattr_init); /* zassert_not_null(pthread_barrierattr_setpshared); */ /* not implemented */
/* zassert_not_null(pthread_barrierattr_setpshared); */ /* not implemented */ zassert_not_null(pthread_cancel);
zassert_not_null(pthread_cancel); zassert_not_null(pthread_cond_broadcast);
zassert_not_null(pthread_cond_broadcast); zassert_not_null(pthread_cond_destroy);
zassert_not_null(pthread_cond_destroy); zassert_not_null(pthread_cond_init);
zassert_not_null(pthread_cond_init); zassert_not_null(pthread_cond_signal);
zassert_not_null(pthread_cond_signal); zassert_not_null(pthread_cond_timedwait);
zassert_not_null(pthread_cond_timedwait); zassert_not_null(pthread_cond_wait);
zassert_not_null(pthread_cond_wait); zassert_not_null(pthread_condattr_destroy);
zassert_not_null(pthread_condattr_destroy); zassert_not_null(pthread_condattr_getclock);
zassert_not_null(pthread_condattr_getclock); /* zassert_not_null(pthread_condattr_getpshared); */ /* not implemented */
/* zassert_not_null(pthread_condattr_getpshared); */ /* not implemented */ zassert_not_null(pthread_condattr_init);
zassert_not_null(pthread_condattr_init); zassert_not_null(pthread_condattr_setclock);
zassert_not_null(pthread_condattr_setclock); /* zassert_not_null(pthread_condattr_setpshared); */ /* not implemented */
/* zassert_not_null(pthread_condattr_setpshared); */ /* not implemented */ zassert_not_null(pthread_create);
zassert_not_null(pthread_create); zassert_not_null(pthread_detach);
zassert_not_null(pthread_detach); zassert_not_null(pthread_equal);
zassert_not_null(pthread_equal); zassert_not_null(pthread_exit);
zassert_not_null(pthread_exit); zassert_not_null(pthread_getconcurrency);
zassert_not_null(pthread_getconcurrency); /* zassert_not_null(pthread_getcpuclockid); */ /* not implemented */
/* zassert_not_null(pthread_getcpuclockid); */ /* not implemented */ zassert_not_null(pthread_getschedparam);
zassert_not_null(pthread_getschedparam); zassert_not_null(pthread_getspecific);
zassert_not_null(pthread_getspecific); zassert_not_null(pthread_join);
zassert_not_null(pthread_join); zassert_not_null(pthread_key_create);
zassert_not_null(pthread_key_create); zassert_not_null(pthread_key_delete);
zassert_not_null(pthread_key_delete); /* zassert_not_null(pthread_mutex_consistent); */ /* not implemented */
/* zassert_not_null(pthread_mutex_consistent); */ /* not implemented */ zassert_not_null(pthread_mutex_destroy);
zassert_not_null(pthread_mutex_destroy); /* zassert_not_null(pthread_mutex_getprioceiling); */ /* not implemented */
/* zassert_not_null(pthread_mutex_getprioceiling); */ /* not implemented */ zassert_not_null(pthread_mutex_init);
zassert_not_null(pthread_mutex_init); zassert_not_null(pthread_mutex_lock);
zassert_not_null(pthread_mutex_lock); /* zassert_not_null(pthread_mutex_setprioceiling); */ /* not implemented */
/* zassert_not_null(pthread_mutex_setprioceiling); */ /* not implemented */ zassert_not_null(pthread_mutex_timedlock);
zassert_not_null(pthread_mutex_timedlock); zassert_not_null(pthread_mutex_trylock);
zassert_not_null(pthread_mutex_trylock); zassert_not_null(pthread_mutex_unlock);
zassert_not_null(pthread_mutex_unlock); zassert_not_null(pthread_mutexattr_destroy);
zassert_not_null(pthread_mutexattr_destroy); /* zassert_not_null(pthread_mutexattr_getprioceiling); */ /* not implemented */
/* zassert_not_null(pthread_mutexattr_getprioceiling); */ /* not implemented */ zassert_not_null(pthread_mutexattr_getprotocol);
zassert_not_null(pthread_mutexattr_getprotocol); /* zassert_not_null(pthread_mutexattr_getpshared); */ /* not implemented */
/* zassert_not_null(pthread_mutexattr_getpshared); */ /* not implemented */ /* zassert_not_null(pthread_mutexattr_getrobust); */ /* not implemented */
/* zassert_not_null(pthread_mutexattr_getrobust); */ /* not implemented */ zassert_not_null(pthread_mutexattr_gettype);
zassert_not_null(pthread_mutexattr_gettype); zassert_not_null(pthread_mutexattr_init);
zassert_not_null(pthread_mutexattr_init); /* zassert_not_null(pthread_mutexattr_setprioceiling); */ /* not implemented */
/* zassert_not_null(pthread_mutexattr_setprioceiling); */ /* not implemented */ /* zassert_not_null(pthread_mutexattr_setprotocol); */ /* not implemented */
/* zassert_not_null(pthread_mutexattr_setprotocol); */ /* not implemented */ /* zassert_not_null(pthread_mutexattr_setpshared); */ /* not implemented */
/* zassert_not_null(pthread_mutexattr_setpshared); */ /* not implemented */ /* zassert_not_null(pthread_mutexattr_setrobust); */ /* not implemented */
/* zassert_not_null(pthread_mutexattr_setrobust); */ /* not implemented */ zassert_not_null(pthread_mutexattr_settype);
zassert_not_null(pthread_mutexattr_settype); zassert_not_null(pthread_once);
zassert_not_null(pthread_once); zassert_not_null(pthread_rwlock_destroy);
zassert_not_null(pthread_rwlock_destroy); zassert_not_null(pthread_rwlock_init);
zassert_not_null(pthread_rwlock_init); zassert_not_null(pthread_rwlock_rdlock);
zassert_not_null(pthread_rwlock_rdlock); zassert_not_null(pthread_rwlock_timedrdlock);
zassert_not_null(pthread_rwlock_timedrdlock); zassert_not_null(pthread_rwlock_timedwrlock);
zassert_not_null(pthread_rwlock_timedwrlock); zassert_not_null(pthread_rwlock_tryrdlock);
zassert_not_null(pthread_rwlock_tryrdlock); zassert_not_null(pthread_rwlock_trywrlock);
zassert_not_null(pthread_rwlock_trywrlock); zassert_not_null(pthread_rwlock_unlock);
zassert_not_null(pthread_rwlock_unlock); zassert_not_null(pthread_rwlock_wrlock);
zassert_not_null(pthread_rwlock_wrlock); zassert_not_null(pthread_rwlockattr_destroy);
zassert_not_null(pthread_rwlockattr_destroy); zassert_not_null(pthread_rwlockattr_getpshared);
zassert_not_null(pthread_rwlockattr_getpshared); zassert_not_null(pthread_rwlockattr_init);
zassert_not_null(pthread_rwlockattr_init); zassert_not_null(pthread_rwlockattr_setpshared);
zassert_not_null(pthread_rwlockattr_setpshared); zassert_not_null(pthread_self);
zassert_not_null(pthread_self); zassert_not_null(pthread_setcancelstate);
zassert_not_null(pthread_setcancelstate); zassert_not_null(pthread_setcanceltype);
zassert_not_null(pthread_setcanceltype); zassert_not_null(pthread_setconcurrency);
zassert_not_null(pthread_setconcurrency); zassert_not_null(pthread_setschedparam);
zassert_not_null(pthread_setschedparam); zassert_not_null(pthread_setschedprio);
zassert_not_null(pthread_setschedprio); zassert_not_null(pthread_setspecific);
zassert_not_null(pthread_setspecific); zassert_not_null(pthread_spin_destroy);
zassert_not_null(pthread_spin_destroy); zassert_not_null(pthread_spin_init);
zassert_not_null(pthread_spin_init); zassert_not_null(pthread_spin_lock);
zassert_not_null(pthread_spin_lock); zassert_not_null(pthread_spin_trylock);
zassert_not_null(pthread_spin_trylock); zassert_not_null(pthread_spin_unlock);
zassert_not_null(pthread_spin_unlock); zassert_not_null(pthread_testcancel);
zassert_not_null(pthread_testcancel); #endif
}
} }
#pragma GCC diagnostic pop #pragma GCC diagnostic pop