From ab6102f70feb80254157f271793c9954368ac38c Mon Sep 17 00:00:00 2001 From: Chris Friedt Date: Thu, 27 Oct 2022 15:47:04 -0400 Subject: [PATCH] tests: posix: existence tests for standard POSIX includes Add a trivial suite that simply ensures headers exist and that they supply standard symbols and constants. These tests are intended to be ordered exactly as the respective feature appears in the respective specification at https://pubs.opengroup.org/onlinepubs/9699919799 Over time, as POSIX support improves, we can enable additional checks. If `CONFIG_POSIX_API=n`, then we simply ensure that the header can be included, that constants and structures exist, including the existence of required fields in each structure. We check that a constant exist, by comparing its value against an arbitrary number. If the constant does not exist, it would of course be a compile error. ``` zassert_not_equal(-1, POLLIN); ``` We check that a structure contains required fields by comparing the field offset with an arbitrary number. If the field does not exist, of course, there would be a compile error. ``` zassert_not_equal(-1, offsetof(struct pollfd, fd)); ``` For non-scalar constants, we simply attempt to assign a value to the specific type: ``` struct in6_addr any6 = IN6ADDR_ANY_INIT; ``` If `CONFIG_POSIX_API=y`, then we additionally check that required functions are non-NULL (limited to what is currently supported in Zephyr). ``` zassert_not_null(pthread_create); ``` Note: functional verification tests should be done outside of this test suite. Signed-off-by: Chris Friedt --- tests/posix/headers/CMakeLists.txt | 8 + tests/posix/headers/prj.conf | 20 ++ tests/posix/headers/src/_common.h | 13 + tests/posix/headers/src/_main.c | 9 + tests/posix/headers/src/arpa_inet_h.c | 33 ++ tests/posix/headers/src/dirent_h.c | 40 +++ tests/posix/headers/src/mqueue_h.c | 41 +++ tests/posix/headers/src/net_if_h.c | 33 ++ tests/posix/headers/src/netdb_h.c | 103 +++++++ tests/posix/headers/src/netinet_in_h.c | 88 ++++++ tests/posix/headers/src/netinet_tcp_h.c | 23 ++ tests/posix/headers/src/poll_h.c | 42 +++ tests/posix/headers/src/pthread_h.c | 162 ++++++++++ tests/posix/headers/src/sched_h.c | 43 +++ tests/posix/headers/src/semaphore_h.c | 36 +++ tests/posix/headers/src/signal_h.c | 191 ++++++++++++ tests/posix/headers/src/sys_eventfd_h.c | 35 +++ tests/posix/headers/src/sys_ioctl_h.c | 26 ++ tests/posix/headers/src/sys_select_h.c | 34 +++ tests/posix/headers/src/sys_socket_h.c | 123 ++++++++ tests/posix/headers/src/sys_time_h.c | 38 +++ tests/posix/headers/src/unistd_h.c | 389 ++++++++++++++++++++++++ tests/posix/headers/testcase.yaml | 44 +++ 23 files changed, 1574 insertions(+) create mode 100644 tests/posix/headers/CMakeLists.txt create mode 100644 tests/posix/headers/prj.conf create mode 100644 tests/posix/headers/src/_common.h create mode 100644 tests/posix/headers/src/_main.c create mode 100644 tests/posix/headers/src/arpa_inet_h.c create mode 100644 tests/posix/headers/src/dirent_h.c create mode 100644 tests/posix/headers/src/mqueue_h.c create mode 100644 tests/posix/headers/src/net_if_h.c create mode 100644 tests/posix/headers/src/netdb_h.c create mode 100644 tests/posix/headers/src/netinet_in_h.c create mode 100644 tests/posix/headers/src/netinet_tcp_h.c create mode 100644 tests/posix/headers/src/poll_h.c create mode 100644 tests/posix/headers/src/pthread_h.c create mode 100644 tests/posix/headers/src/sched_h.c create mode 100644 tests/posix/headers/src/semaphore_h.c create mode 100644 tests/posix/headers/src/signal_h.c create mode 100644 tests/posix/headers/src/sys_eventfd_h.c create mode 100644 tests/posix/headers/src/sys_ioctl_h.c create mode 100644 tests/posix/headers/src/sys_select_h.c create mode 100644 tests/posix/headers/src/sys_socket_h.c create mode 100644 tests/posix/headers/src/sys_time_h.c create mode 100644 tests/posix/headers/src/unistd_h.c create mode 100644 tests/posix/headers/testcase.yaml diff --git a/tests/posix/headers/CMakeLists.txt b/tests/posix/headers/CMakeLists.txt new file mode 100644 index 0000000000..16616d5885 --- /dev/null +++ b/tests/posix/headers/CMakeLists.txt @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(posix_headers) + +FILE(GLOB app_sources src/*.c) +target_sources(app PRIVATE ${app_sources}) diff --git a/tests/posix/headers/prj.conf b/tests/posix/headers/prj.conf new file mode 100644 index 0000000000..43b6bc147c --- /dev/null +++ b/tests/posix/headers/prj.conf @@ -0,0 +1,20 @@ +CONFIG_POSIX_API=y +CONFIG_ZTEST=y +CONFIG_ZTEST_NEW_API=y + +# for POSIX_FS +CONFIG_FILE_SYSTEM=y + +# for select to work +CONFIG_NET_TEST=y +CONFIG_TEST_RANDOM_GENERATOR=y +CONFIG_NET_SOCKETS=y +CONFIG_NETWORKING=y + +# for when CONFIG_POSIX_API is not selected +CONFIG_PTHREAD_IPC=y +CONFIG_POSIX_FS=y +CONFIG_POSIX_CLOCK=y +CONFIG_POSIX_MQUEUE=y +CONFIG_EVENTFD=y +CONFIG_GETOPT=y diff --git a/tests/posix/headers/src/_common.h b/tests/posix/headers/src/_common.h new file mode 100644 index 0000000000..47325c0547 --- /dev/null +++ b/tests/posix/headers/src/_common.h @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2022 Meta + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include +#include +#include + +#include diff --git a/tests/posix/headers/src/_main.c b/tests/posix/headers/src/_main.c new file mode 100644 index 0000000000..87e634f9b8 --- /dev/null +++ b/tests/posix/headers/src/_main.c @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2022 Meta + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "_common.h" + +ZTEST_SUITE(posix_headers, NULL, NULL, NULL, NULL, NULL); diff --git a/tests/posix/headers/src/arpa_inet_h.c b/tests/posix/headers/src/arpa_inet_h.c new file mode 100644 index 0000000000..06541e1cd7 --- /dev/null +++ b/tests/posix/headers/src/arpa_inet_h.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2022 Meta + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "_common.h" + +#ifdef CONFIG_POSIX_API +#include +#else +#include +#endif + +/** + * @brief existence test for `` + * + * @see arpa/inet.h + */ +ZTEST(posix_headers, test_arpa_inet_h) +{ + zassert_not_equal(-1, htonl(0)); + zassert_not_equal(-1, htons(0)); + zassert_not_equal(-1, ntohl(0)); + zassert_not_equal(-1, ntohs(0)); + + if (IS_ENABLED(CONFIG_POSIX_API)) { + /* zassert_not_null(inet_addr); */ /* not implemented */ + /* zassert_not_null(inet_ntoa); */ /* not implemented */ + zassert_not_null(inet_ntop); + zassert_not_null(inet_pton); + } +} diff --git a/tests/posix/headers/src/dirent_h.c b/tests/posix/headers/src/dirent_h.c new file mode 100644 index 0000000000..ca5527603c --- /dev/null +++ b/tests/posix/headers/src/dirent_h.c @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2022 Meta + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "_common.h" + +#ifdef CONFIG_POSIX_API +#include +#else +#include +#endif + +/** + * @brief existence test for `` + * + * @see dirent.h + */ +ZTEST(posix_headers, test_dirent_h) +{ + 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 */ + } +} diff --git a/tests/posix/headers/src/mqueue_h.c b/tests/posix/headers/src/mqueue_h.c new file mode 100644 index 0000000000..4a1209fe53 --- /dev/null +++ b/tests/posix/headers/src/mqueue_h.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2022 Meta + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "_common.h" + +#ifdef CONFIG_POSIX_API +#include +#else +#include +#endif + +/** + * @brief existence test for `` + * + * @see mqueue.h + */ +ZTEST(posix_headers, test_mqueue_h) +{ + zassert_not_equal((mqd_t)-1, (mqd_t)NULL); + + zassert_not_equal(-1, offsetof(struct mq_attr, mq_flags)); + zassert_not_equal(-1, offsetof(struct mq_attr, mq_maxmsg)); + zassert_not_equal(-1, offsetof(struct mq_attr, mq_msgsize)); + zassert_not_equal(-1, offsetof(struct mq_attr, mq_curmsgs)); + + if (IS_ENABLED(CONFIG_POSIX_API)) { + zassert_not_null(mq_close); + zassert_not_null(mq_getattr); + /* zassert_not_null(mq_notify); */ /* not implemented */ + zassert_not_null(mq_open); + zassert_not_null(mq_receive); + zassert_not_null(mq_send); + zassert_not_null(mq_setattr); + zassert_not_null(mq_timedreceive); + zassert_not_null(mq_timedsend); + zassert_not_null(mq_unlink); + } +} diff --git a/tests/posix/headers/src/net_if_h.c b/tests/posix/headers/src/net_if_h.c new file mode 100644 index 0000000000..f3e3cb77ac --- /dev/null +++ b/tests/posix/headers/src/net_if_h.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2022 Meta + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "_common.h" + +#ifdef CONFIG_POSIX_API +#include +#else +#include +#endif + +/** + * @brief existence test for `` + * + * @see net/if.h + */ +ZTEST(posix_headers, test_net_if_h) +{ + /* zassert_not_equal(-1, offsetof(struct if_nameindex, if_index)); */ /* not implemented */ + /* zassert_not_equal(-1, offsetof(struct if_nameindex, if_name)); */ /* not implemented */ + + /* zassert_not_equal(-1, IF_NAMESIZE); */ /* not implemented */ + + if (IS_ENABLED(CONFIG_POSIX_API)) { + /* zassert_not_null(if_freenameindex); */ /* not implemented */ + /* zassert_not_null(if_indextoname); */ /* not implemented */ + /* zassert_not_null(if_nameindex); */ /* not implemented */ + /* zassert_not_null(if_nametoindex); */ /* not implemented */ + } +} diff --git a/tests/posix/headers/src/netdb_h.c b/tests/posix/headers/src/netdb_h.c new file mode 100644 index 0000000000..3d6240fbfc --- /dev/null +++ b/tests/posix/headers/src/netdb_h.c @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2022 Meta + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "_common.h" + +#ifdef CONFIG_POSIX_API +#include +#else +#include +#endif + +/** + * @brief existence test for `` + * + * @see +#else +#include +#endif + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-variable" +/** + * @brief existence test for `` + * + * @see netinet/in.h + */ +ZTEST(posix_headers, test_netinet_in_h) +{ + zassert_equal(sizeof(in_port_t), sizeof(uint16_t)); + zassert_equal(sizeof(in_addr_t), sizeof(uint32_t)); + + zassert_not_equal(-1, offsetof(struct in_addr, s_addr)); + + zassert_not_equal(-1, offsetof(struct sockaddr_in, sin_family)); + zassert_not_equal(-1, offsetof(struct sockaddr_in, sin_port)); + zassert_not_equal(-1, offsetof(struct sockaddr_in, sin_addr)); + + zassert_not_equal(-1, offsetof(struct in6_addr, s6_addr)); + zassert_equal(sizeof(((struct in6_addr *)NULL)->s6_addr), 16 * sizeof(uint8_t)); + + zassert_not_equal(-1, offsetof(struct sockaddr_in6, sin6_family)); + zassert_not_equal(-1, offsetof(struct sockaddr_in6, sin6_port)); + /* not implemented */ + /* zassert_not_equal(-1, offsetof(struct sockaddr_in6, sin6_flowinfo)); */ + zassert_not_equal(-1, offsetof(struct sockaddr_in6, sin6_addr)); + /* not implemented */ + /* zassert_not_equal(-1, offsetof(struct sockaddr_in6, scope_id)); */ + + zassert_not_null(&in6addr_loopback); + struct in6_addr any6 = IN6ADDR_ANY_INIT; + struct in6_addr lo6 = IN6ADDR_LOOPBACK_INIT; + + /* not implemented */ + /* zassert_not_equal(-1, offsetof(struct ipv6_mreq, ipv6mr_multiaddr)); */ + /* not implemented */ + /* zassert_not_equal(-1, offsetof(struct ipv6_mreq, ipv6mr_interface)); */ + + zassert_not_equal(-1, IPPROTO_IP); + zassert_not_equal(-1, IPPROTO_IPV6); + zassert_not_equal(-1, IPPROTO_ICMP); + zassert_not_equal(-1, IPPROTO_RAW); + zassert_not_equal(-1, IPPROTO_TCP); + zassert_not_equal(-1, IPPROTO_UDP); + + zassert_not_equal(-1, INADDR_ANY); + /* zassert_not_equal(-1, INADDR_BROADCAST); */ /* not implemented */ + + zassert_equal(INET_ADDRSTRLEN, 16); + zassert_equal(INET6_ADDRSTRLEN, 46); + + /* zassert_not_equal(-1, IPV6_JOIN_GROUP); */ /* not implemented */ + /* zassert_not_equal(-1, IPV6_LEAVE_GROUP); */ /* not implemented */ + /* zassert_not_equal(-1, IPV6_MULTICAST_HOPS); */ /* not implemented */ + /* zassert_not_equal(-1, IPV6_MULTICAST_IF); */ /* not implemented */ + /* zassert_not_equal(-1, IPV6_MULTICAST_LOOP); */ /* not implemented */ + /* zassert_not_equal(-1, IPV6_UNICAST_HOPS); */ /* not implemented */ + zassert_not_equal(-1, IPV6_V6ONLY); + + /* IN6_IS_ADDR_UNSPECIFIED(&any6); */ /* not implemented */ + /* IN6_IS_ADDR_LOOPBACK(&lo6); */ /* not implemented */ + + /* IN6_IS_ADDR_MULTICAST(&lo6); */ /* not implemented */ + /* IN6_IS_ADDR_LINKLOCAL(&lo6); */ /* not implemented */ + /* IN6_IS_ADDR_SITELOCAL(&lo6); */ /* not implemented */ + /* IN6_IS_ADDR_V4MAPPED(&lo6); */ /* not implemented */ + /* IN6_IS_ADDR_V4COMPAT(&lo6); */ /* not implemented */ + /* IN6_IS_ADDR_MC_NODELOCAL(&lo6); */ /* not implemented */ + /* IN6_IS_ADDR_MC_LINKLOCAL(&lo6); */ /* not implemented */ + /* IN6_IS_ADDR_MC_SITELOCAL(&lo6); */ /* not implemented */ + /* IN6_IS_ADDR_MC_ORGLOCAL(&lo6); */ /* not implemented */ + /* IN6_IS_ADDR_MC_GLOBAL(&lo6); */ /* not implemented */ +} +#pragma GCC diagnostic pop diff --git a/tests/posix/headers/src/netinet_tcp_h.c b/tests/posix/headers/src/netinet_tcp_h.c new file mode 100644 index 0000000000..e476b4cbcd --- /dev/null +++ b/tests/posix/headers/src/netinet_tcp_h.c @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022 Meta + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "_common.h" + +#ifdef CONFIG_POSIX_API +#include +#else +#include +#endif + +/** + * @brief existence test for `` + * + * @see netinet/tcp.h + */ +ZTEST(posix_headers, test_netinet_tcp_h) +{ + zassert_not_equal(-1, TCP_NODELAY); +} diff --git a/tests/posix/headers/src/poll_h.c b/tests/posix/headers/src/poll_h.c new file mode 100644 index 0000000000..ff4257939d --- /dev/null +++ b/tests/posix/headers/src/poll_h.c @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2022 Meta + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "_common.h" + +#ifdef CONFIG_POSIX_API +#include +#else +#include +#endif + +/** + * @brief existence test for `` + * + * @see poll.h + */ +ZTEST(posix_headers, test_poll_h) +{ + zassert_not_equal(-1, offsetof(struct pollfd, fd)); + zassert_not_equal(-1, offsetof(struct pollfd, events)); + zassert_not_equal(-1, offsetof(struct pollfd, revents)); + + /* zassert_true(sizeof(nfds_t) <= sizeof(long)); */ /* not implemented */ + + zassert_not_equal(-1, POLLIN); + /* zassert_not_equal(-1, POLLRDNORM); */ /* not implemented */ + /* zassert_not_equal(-1, POLLRDBAND); */ /* not implemented */ + /* zassert_not_equal(-1, POLLPRI); */ /* not implemented */ + zassert_not_equal(-1, POLLOUT); + /* zassert_not_equal(-1, POLLWRNORM); */ /* not implemented */ + /* zassert_not_equal(-1, POLLWRBAND); */ /* not implemented */ + zassert_not_equal(-1, POLLERR); + zassert_not_equal(-1, POLLHUP); + zassert_not_equal(-1, POLLNVAL); + + if (IS_ENABLED(CONFIG_POSIX_API)) { + zassert_not_null(poll); + } +} diff --git a/tests/posix/headers/src/pthread_h.c b/tests/posix/headers/src/pthread_h.c new file mode 100644 index 0000000000..d535a13469 --- /dev/null +++ b/tests/posix/headers/src/pthread_h.c @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2022 Meta + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "_common.h" + +#ifdef CONFIG_POSIX_API +#include +#else +#include +#endif + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-variable" +/** + * @brief existence test for `` + * + * @see pthread.h + */ +ZTEST(posix_headers, test_pthread_h) +{ + zassert_not_equal(-1, PTHREAD_BARRIER_SERIAL_THREAD); + + /* zassert_not_equal(-1, PTHREAD_CANCEL_ASYNCHRONOUS); */ /* not implemented */ + zassert_not_equal(-1, PTHREAD_CANCEL_ENABLE); + /* zassert_not_equal(-1, PTHREAD_CANCEL_DEFERRED); */ /* not implemented */ + zassert_not_equal(-1, PTHREAD_CANCEL_DISABLE); + + /* zassert_not_equal(-1, PTHREAD_CANCELED); */ /* not implemented */ + + zassert_not_equal(-1, PTHREAD_CREATE_DETACHED); + zassert_not_equal(-1, PTHREAD_CREATE_JOINABLE); + + /* zassert_not_equal(-1, PTHREAD_EXPLICIT_SCHED); */ /* not implemented */ + /* zassert_not_equal(-1, PTHREAD_INHERIT_SCHED); */ /* not implemented */ + + zassert_not_equal(-1, PTHREAD_MUTEX_DEFAULT); + 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_STALLED); */ /* not implemented */ + + pthread_once_t once = PTHREAD_ONCE_INIT; + + /* zassert_not_equal(-1, PTHREAD_PRIO_INHERIT); */ /* not implemented */ + zassert_not_equal(-1, PTHREAD_PRIO_NONE); + /* zassert_not_equal(-1, PTHREAD_PRIO_PROTECT); */ /* not implemented */ + + /* zassert_not_equal(-1, PTHREAD_PROCESS_SHARED); */ /* not implemented */ + /* zassert_not_equal(-1, PTHREAD_PROCESS_PRIVATE); */ /* not implemented */ + + /* zassert_not_equal(-1, PTHREAD_SCOPE_PROCESS); */ /* not implemented */ + /* zassert_not_equal(-1, PTHREAD_SCOPE_SYSTEM); */ /* not implemented */ + + /* pthread_cond_t cond = PTHREAD_COND_INITIALIZER; */ /* not implemented */ + /* pthread_mutex_t mu = PTHREAD_MUTEX_INITIALIZER; */ /* not implemented */ + /* pthread_rwlock_t lock = PTHREAD_RWLOCK_INITIALIZER; */ /* not implemented */ + + if (IS_ENABLED(CONFIG_POSIX_API)) { + /* zassert_not_null(pthread_atfork); */ /* not implemented */ + zassert_not_null(pthread_attr_destroy); + zassert_not_null(pthread_attr_getdetachstate); + /* zassert_not_null(pthread_attr_getguardsize); */ /* not implemented */ + /* zassert_not_null(pthread_attr_getinheritsched); */ /* not implemented */ + zassert_not_null(pthread_attr_getschedparam); + zassert_not_null(pthread_attr_getschedpolicy); + /* zassert_not_null(pthread_attr_getscope); */ /* not implemented */ + 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); */ /* not implemented */ + /* zassert_not_null(pthread_attr_setinheritsched); */ /* not implemented */ + zassert_not_null(pthread_attr_setschedparam); + zassert_not_null(pthread_attr_setschedpolicy); + /* zassert_not_null(pthread_attr_setscope); */ /* not implemented */ + 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); */ /* not implemented */ + /* zassert_not_null(pthread_condattr_getpshared); */ /* not implemented */ + zassert_not_null(pthread_condattr_init); + /* zassert_not_null(pthread_condattr_setclock); */ /* not implemented */ + /* 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); */ /* not implemented */ + /* 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); */ /* not implemented */ + zassert_not_null(pthread_rwlockattr_init); + /* zassert_not_null(pthread_rwlockattr_setpshared); */ /* not implemented */ + zassert_not_null(pthread_self); + /* zassert_not_null(pthread_setcancelstate); */ /* not implemented */ + /* zassert_not_null(pthread_setcanceltype); */ /* not implemented */ + /* zassert_not_null(pthread_setconcurrency); */ /* not implemented */ + zassert_not_null(pthread_setschedparam); + /* zassert_not_null(pthread_setschedprio); */ /* not implemented */ + zassert_not_null(pthread_setspecific); + /* zassert_not_null(pthread_spin_destroy); */ /* not implemented */ + /* zassert_not_null(pthread_spin_init); */ /* not implemented */ + /* zassert_not_null(pthread_spin_lock); */ /* not implemented */ + /* zassert_not_null(pthread_spin_unlock); */ /* not implemented */ + /* zassert_not_null(pthread_testcancel); */ /* not implemented */ + } +} +#pragma GCC diagnostic pop diff --git a/tests/posix/headers/src/sched_h.c b/tests/posix/headers/src/sched_h.c new file mode 100644 index 0000000000..fb4f2de268 --- /dev/null +++ b/tests/posix/headers/src/sched_h.c @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 Meta + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "_common.h" + +#ifdef CONFIG_POSIX_API +#include +#else +#include +#endif + +/** + * @brief existence test for `` + * + * @see sched.h + */ +ZTEST(posix_headers, test_sched_h) +{ + zassert_not_equal(-1, offsetof(struct sched_param, sched_priority)); + + zassert_not_equal(-1, SCHED_FIFO); + zassert_not_equal(-1, SCHED_RR); + /* zassert_not_equal(-1, SCHED_SPORADIC); */ /* not implemented */ + /* zassert_not_equal(-1, SCHED_OTHER); */ /* not implemented */ + + if (IS_ENABLED(CONFIG_POSIX_API)) { + zassert_not_null(sched_get_priority_max); + zassert_not_null(sched_get_priority_min); + + /* zassert_not_null(sched_getparam); */ /* not implemented */ + /* zassert_not_null(sched_getscheduler); */ /* not implemented */ + + /* zassert_not_null(sched_rr_get_interval); */ /* not implemented */ + + /* zassert_not_null(sched_setparam); */ /* not implemented */ + /* zassert_not_null(sched_setscheduler); */ /* not implemented */ + + zassert_not_null(sched_yield); + } +} diff --git a/tests/posix/headers/src/semaphore_h.c b/tests/posix/headers/src/semaphore_h.c new file mode 100644 index 0000000000..0ac1de36f2 --- /dev/null +++ b/tests/posix/headers/src/semaphore_h.c @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2022 Meta + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "_common.h" + +#ifdef CONFIG_POSIX_API +#include +#else +#include +#endif + +/** + * @brief existence test for `` + * + * @see semaphore.h + */ +ZTEST(posix_headers, test_semaphore_h) +{ + /* zassert_not_equal(SEM_FAILED, (sem_t *)42); */ /* not implemented */ + + if (IS_ENABLED(CONFIG_POSIX_API)) { + /* zassert_not_null(sem_close); */ /* not implemented */ + zassert_not_null(sem_destroy); + zassert_not_null(sem_getvalue); + zassert_not_null(sem_init); + /* zassert_not_null(sem_open); */ /* not implemented */ + zassert_not_null(sem_post); + zassert_not_null(sem_timedwait); + zassert_not_null(sem_trywait); + /* zassert_not_null(sem_unlink); */ /* not implemented */ + zassert_not_null(sem_wait); + } +} diff --git a/tests/posix/headers/src/signal_h.c b/tests/posix/headers/src/signal_h.c new file mode 100644 index 0000000000..9b8711e530 --- /dev/null +++ b/tests/posix/headers/src/signal_h.c @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2022 Meta + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "_common.h" + +#ifdef CONFIG_POSIX_API +#include +#else +#include +#endif + +/** + * @brief existence test for `` + * + * @see signal.h + */ +ZTEST(posix_headers, test_signal_h) +{ + /* zassert_not_equal(-1, SIG_DFL); */ /* not implemented */ + /* zassert_not_equal(-1, SIG_ERR); */ /* not implemented */ + /* zassert_not_equal(-1, SIG_HOLD); */ /* not implemented */ + /* zassert_not_equal(-1, SIG_IGN); */ /* not implemented */ + + /* zassert_not_equal((sig_atomic_t)-1, (sig_atomic_t)0); */ /* not implemented */ + /* zassert_not_equal((sigset_t)-1, (sigset_t)0); */ /* not implemented */ + /* zassert_not_equal((pid_t)-1, (pid_t)0); */ /* not implemented */ + + zassert_not_equal(-1, offsetof(struct sigevent, sigev_notify)); + zassert_not_equal(-1, offsetof(struct sigevent, sigev_signo)); + zassert_not_equal(-1, offsetof(struct sigevent, sigev_value)); + zassert_not_equal(-1, offsetof(struct sigevent, sigev_notify_function)); + zassert_not_equal(-1, offsetof(struct sigevent, sigev_notify_attributes)); + + zassert_not_equal(-1, SIGEV_NONE); + zassert_not_equal(-1, SIGEV_SIGNAL); + zassert_not_equal(-1, SIGEV_THREAD); + + zassert_not_equal(-1, offsetof(union sigval, sival_int)); + zassert_not_equal(-1, offsetof(union sigval, sival_ptr)); + + /* zassert_not_equal(-1, RTSIG_MAX); */ /* not implemented */ + /* zassert_true(SIGRTMIN >= 0); */ /* not implemented */ + /* zassert_true(SIGRTMAX >= SIGRTMIN); */ /* not implemented */ + /* zassert_true(SIGRTMAX - SIGRTMIN >= RTSIG_MAX); */ /* not implemented */ + + /* zassert_not_equal(-1, SIGABRT); */ /* not implemented */ + /* zassert_not_equal(-1, SIGALRM); */ /* not implemented */ + /* zassert_not_equal(-1, SIGBUS); */ /* not implemented */ + /* zassert_not_equal(-1, SIGCHLD); */ /* not implemented */ + /* zassert_not_equal(-1, SIGCONT); */ /* not implemented */ + /* zassert_not_equal(-1, SIGFPE); */ /* not implemented */ + /* zassert_not_equal(-1, SIGHUP); */ /* not implemented */ + /* zassert_not_equal(-1, SIGILL); */ /* not implemented */ + /* zassert_not_equal(-1, SIGINT); */ /* not implemented */ + /* zassert_not_equal(-1, SIGKILL); */ /* not implemented */ + /* zassert_not_equal(-1, SIGPIPE); */ /* not implemented */ + /* zassert_not_equal(-1, SIGQUIT); */ /* not implemented */ + /* zassert_not_equal(-1, SIGSEGV); */ /* not implemented */ + /* zassert_not_equal(-1, SIGSTOP); */ /* not implemented */ + /* zassert_not_equal(-1, SIGTERM); */ /* not implemented */ + /* zassert_not_equal(-1, SIGTSTP); */ /* not implemented */ + /* zassert_not_equal(-1, SIGTTIN); */ /* not implemented */ + /* zassert_not_equal(-1, SIGTTOU); */ /* not implemented */ + /* zassert_not_equal(-1, SIGUSR1); */ /* not implemented */ + /* zassert_not_equal(-1, SIGUSR2); */ /* not implemented */ + /* zassert_not_equal(-1, SIGTRAP); */ /* not implemented */ + /* zassert_not_equal(-1, SIGURG); */ /* not implemented */ + /* zassert_not_equal(-1, SIGXCPU); */ /* not implemented */ + /* zassert_not_equal(-1, SIGXFSZ); */ /* not implemented */ + + /* zassert_not_equal(-1, SIG_BLOCK); */ /* not implemented */ + /* zassert_not_equal(-1, SIG_UNBLOCK); */ /* not implemented */ + /* zassert_not_equal(-1, SIG_SETMASK); */ /* not implemented */ + + /* zassert_not_equal(-1, SA_NOCLDSTOP); */ /* not implemented */ + /* zassert_not_equal(-1, SA_ONSTACK); */ /* not implemented */ + /* zassert_not_equal(-1, SA_RESETHAND); */ /* not implemented */ + /* zassert_not_equal(-1, SA_RESTART); */ /* not implemented */ + /* zassert_not_equal(-1, SA_SIGINFO); */ /* not implemented */ + /* zassert_not_equal(-1, SA_NOCLDWAIT); */ /* not implemented */ + /* zassert_not_equal(-1, SA_NODEFER); */ /* not implemented */ + + /* zassert_not_equal(-1, SS_ONSTACK); */ /* not implemented */ + /* zassert_not_equal(-1, SS_DISABLE); */ /* not implemented */ + + /* zassert_not_equal(-1, MINSIGSTKSZ); */ /* not implemented */ + /* zassert_not_equal(-1, SIGSTKSZ); */ /* not implemented */ + + /* mcontext_t mctx = {0}; */ /* not implemented */ + + /* zassert_not_equal(-1, offsetof(ucontext_t, uc_link)); */ /* not implemented */ + /* zassert_not_equal(-1, offsetof(ucontext_t, uc_sigmask)); */ /* not implemented */ + /* zassert_not_equal(-1, offsetof(ucontext_t, uc_stack)); */ /* not implemented */ + /* zassert_not_equal(-1, offsetof(ucontext_t, uc_mcontext)); */ /* not implemented */ + + /* zassert_not_equal(-1, offsetof(stack_t, ss_sp)); */ /* not implemented */ + /* zassert_not_equal(-1, offsetof(stack_t, ss_size)); */ /* not implemented */ + /* zassert_not_equal(-1, offsetof(stack_t, ss_flags)); */ /* not implemented */ + + /* zassert_not_equal(-1, offsetof(siginfo_t, si_signo)); */ /* not implemented */ + /* zassert_not_equal(-1, offsetof(siginfo_t, si_code)); */ /* not implemented */ + /* zassert_not_equal(-1, offsetof(siginfo_t, si_errno)); */ /* not implemented */ + /* zassert_not_equal(-1, offsetof(siginfo_t, si_pid)); */ /* not implemented */ + /* zassert_not_equal(-1, offsetof(siginfo_t, si_uid)); */ /* not implemented */ + /* zassert_not_equal(-1, offsetof(siginfo_t, si_addr)); */ /* not implemented */ + /* zassert_not_equal(-1, offsetof(siginfo_t, si_status)); */ /* not implemented */ + /* zassert_not_equal(-1, offsetof(siginfo_t, si_band)); */ /* not implemented */ + /* zassert_not_equal(-1, offsetof(siginfo_t, si_value)); */ /* not implemented */ + + /* zassert_not_equal(-1, ILL_ILLOPC); */ /* not implemented */ + /* zassert_not_equal(-1, ILL_ILLOPN); */ /* not implemented */ + /* zassert_not_equal(-1, ILL_ILLADR); */ /* not implemented */ + /* zassert_not_equal(-1, ILL_ILLTRP); */ /* not implemented */ + /* zassert_not_equal(-1, ILL_PRVOPC); */ /* not implemented */ + /* zassert_not_equal(-1, ILL_PRVREG); */ /* not implemented */ + /* zassert_not_equal(-1, ILL_COPROC); */ /* not implemented */ + /* zassert_not_equal(-1, ILL_BADSTK); */ /* not implemented */ + + /* zassert_not_equal(-1, FPE_INTDIV); */ /* not implemented */ + /* zassert_not_equal(-1, FPE_INTOVF); */ /* not implemented */ + /* zassert_not_equal(-1, FPE_FLTDIV); */ /* not implemented */ + /* zassert_not_equal(-1, FPE_FLTOVF); */ /* not implemented */ + /* zassert_not_equal(-1, FPE_FLTUND); */ /* not implemented */ + /* zassert_not_equal(-1, FPE_FLTRES); */ /* not implemented */ + /* zassert_not_equal(-1, FPE_FLTINV); */ /* not implemented */ + /* zassert_not_equal(-1, FPE_FLTSUB); */ /* not implemented */ + + /* zassert_not_equal(-1, SEGV_MAPERR); */ /* not implemented */ + /* zassert_not_equal(-1, SEGV_ACCERR); */ /* not implemented */ + + /* zassert_not_equal(-1, BUS_ADRALN); */ /* not implemented */ + /* zassert_not_equal(-1, BUS_ADRERR); */ /* not implemented */ + /* zassert_not_equal(-1, BUS_OBJERR); */ /* not implemented */ + + /* zassert_not_equal(-1, TRAP_BRKPT); */ /* not implemented */ + /* zassert_not_equal(-1, TRAP_TRACE); */ /* not implemented */ + + /* zassert_not_equal(-1, CLD_EXITED); */ /* not implemented */ + /* zassert_not_equal(-1, CLD_KILLED); */ /* not implemented */ + /* zassert_not_equal(-1, CLD_DUMPED); */ /* not implemented */ + /* zassert_not_equal(-1, CLD_TRAPPED); */ /* not implemented */ + /* zassert_not_equal(-1, CLD_STOPPED); */ /* not implemented */ + /* zassert_not_equal(-1, CLD_CONTINUED); */ /* not implemented */ + + /* zassert_not_equal(-1, POLL_IN); */ /* not implemented */ + /* zassert_not_equal(-1, POLL_OUT); */ /* not implemented */ + /* zassert_not_equal(-1, POLL_MSG); */ /* not implemented */ + /* zassert_not_equal(-1, POLL_ERR); */ /* not implemented */ + /* zassert_not_equal(-1, POLL_PRI); */ /* not implemented */ + /* zassert_not_equal(-1, POLL_HUP); */ /* not implemented */ + + /* zassert_not_equal(-1, SI_USER); */ /* not implemented */ + /* zassert_not_equal(-1, SI_QUEUE); */ /* not implemented */ + /* zassert_not_equal(-1, SI_TIMER); */ /* not implemented */ + /* zassert_not_equal(-1, SI_ASYNCIO); */ /* not implemented */ + /* zassert_not_equal(-1, SI_MESGQ); */ /* not implemented */ + + if (IS_ENABLED(CONFIG_POSIX_API)) { + /* zassert_not_null(kill); */ /* not implemented */ + /* zassert_not_null(killpg); */ /* not implemented */ + /* zassert_not_null(psiginfo); */ /* not implemented */ + /* zassert_not_null(psignal); */ /* not implemented */ + /* zassert_not_null(pthread_kill); */ /* not implemented */ + /* zassert_not_null(pthread_sigmask); */ /* not implemented */ + /* zassert_not_null(raise); */ /* not implemented */ + /* zassert_not_null(sigaction); */ /* not implemented */ + /* zassert_not_null(sigaddset); */ /* not implemented */ + /* zassert_not_null(sigaltstack); */ /* not implemented */ + /* zassert_not_null(sigdelset); */ /* not implemented */ + /* zassert_not_null(sigemptyset); */ /* not implemented */ + /* zassert_not_null(sigfillset); */ /* not implemented */ + /* zassert_not_null(sighold); */ /* not implemented */ + /* zassert_not_null(sigignore); */ /* not implemented */ + /* zassert_not_null(siginterrupt); */ /* not implemented */ + /* zassert_not_null(sigismember); */ /* not implemented */ + /* zassert_not_null(signal); */ /* not implemented */ + /* zassert_not_null(sigpause); */ /* not implemented */ + /* zassert_not_null(sigpending); */ /* not implemented */ + /* zassert_not_null(sigprocmask); */ /* not implemented */ + /* zassert_not_null(sigqueue); */ /* not implemented */ + /* zassert_not_null(sigrelse); */ /* not implemented */ + /* zassert_not_null(sigset); */ /* not implemented */ + /* zassert_not_null(sigsuspend); */ /* not implemented */ + /* zassert_not_null(sigtimedwait); */ /* not implemented */ + /* zassert_not_null(sigwait); */ /* not implemented */ + /* zassert_not_null(sigwaitinfo); */ /* not implemented */ + } +} diff --git a/tests/posix/headers/src/sys_eventfd_h.c b/tests/posix/headers/src/sys_eventfd_h.c new file mode 100644 index 0000000000..6f666393f2 --- /dev/null +++ b/tests/posix/headers/src/sys_eventfd_h.c @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2022 Meta + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "_common.h" + +#ifdef CONFIG_POSIX_API +#include +#else +#include +#endif + +/** + * @brief existence test for `` + * + * @note the eventfd API is not (yet) a part of POSIX. + * + * @see sys/eventfd.h + */ +ZTEST(posix_headers, test_sys_eventfd_h) +{ + /* zassert_not_equal(-1, EFD_CLOEXEC); */ /* not implemented */ + zassert_not_equal(-1, EFD_NONBLOCK); + zassert_not_equal(-1, EFD_SEMAPHORE); + + zassert_not_equal((eventfd_t)-1, (eventfd_t)0); + + if (IS_ENABLED(CONFIG_POSIX_API)) { + zassert_not_null(eventfd); + zassert_not_null(eventfd_read); + zassert_not_null(eventfd_write); + } +} diff --git a/tests/posix/headers/src/sys_ioctl_h.c b/tests/posix/headers/src/sys_ioctl_h.c new file mode 100644 index 0000000000..286cd78353 --- /dev/null +++ b/tests/posix/headers/src/sys_ioctl_h.c @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022 Meta + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "_common.h" + +#ifdef CONFIG_POSIX_API +#include +#else +#include +#endif + +/** + * @brief existence test for `` + * + * @see ioctl + * @see ioctl(2) + */ +ZTEST(posix_headers, test_sys_ioctl_h) +{ + if (IS_ENABLED(CONFIG_POSIX_API)) { + zassert_not_null(ioctl); + } +} diff --git a/tests/posix/headers/src/sys_select_h.c b/tests/posix/headers/src/sys_select_h.c new file mode 100644 index 0000000000..6ea986cbae --- /dev/null +++ b/tests/posix/headers/src/sys_select_h.c @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022 Meta + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "_common.h" + +#ifdef CONFIG_POSIX_API +#include +#else +#include +#endif + +/** + * @brief existence test for `` + * + * @see sys/select.h + */ +ZTEST(posix_headers, test_sys_select_h) +{ + fd_set fds = {0}; + + zassert_not_equal(-1, FD_SETSIZE); + FD_CLR(0, &fds); + FD_ISSET(0, &fds); + FD_SET(0, &fds); + FD_ZERO(&fds); + + if (IS_ENABLED(CONFIG_POSIX_API)) { + /* zassert_not_null(pselect); */ /* not implemented */ + zassert_not_null(select); + } +} diff --git a/tests/posix/headers/src/sys_socket_h.c b/tests/posix/headers/src/sys_socket_h.c new file mode 100644 index 0000000000..81ab9f95fd --- /dev/null +++ b/tests/posix/headers/src/sys_socket_h.c @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2022 Meta + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "_common.h" + +#ifdef CONFIG_POSIX_API +#include +#else +#include +#endif + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-value" +/** + * @brief existence test for `` + * + * @see sys/socket.h + */ +ZTEST(posix_headers, test_sys_socket_h) +{ + struct cmsghdr cmsg = {0}; + struct msghdr mhdr = {0}; + + zassert_true(sizeof(socklen_t) >= sizeof(uint32_t)); + zassert_true((sa_family_t)-1 >= 0); + + zassert_not_equal(-1, offsetof(struct sockaddr, sa_family)); + /* + * FIXME: in zephyr, we define struct sockaddr in + * The sa_data field is defined (incorrectly) as data. + * Fixing that is a (possibly breaking) tree-wide change. + */ + /* zassert_not_equal(-1, offsetof(struct sockaddr, sa_data)); */ /* not implemented */ + + zassert_not_equal(-1, offsetof(struct sockaddr_storage, ss_family)); + zassert_equal(offsetof(struct sockaddr, sa_family), + offsetof(struct sockaddr_storage, ss_family)); + + zassert_not_equal(-1, offsetof(struct msghdr, msg_name)); + zassert_not_equal(-1, offsetof(struct msghdr, msg_namelen)); + zassert_not_equal(-1, offsetof(struct msghdr, msg_iov)); + zassert_not_equal(-1, offsetof(struct msghdr, msg_iovlen)); + zassert_not_equal(-1, offsetof(struct msghdr, msg_control)); + zassert_not_equal(-1, offsetof(struct msghdr, msg_controllen)); + zassert_not_equal(-1, offsetof(struct msghdr, msg_flags)); + + zassert_not_equal(-1, offsetof(struct cmsghdr, cmsg_len)); + zassert_not_equal(-1, offsetof(struct cmsghdr, cmsg_level)); + zassert_not_equal(-1, offsetof(struct cmsghdr, cmsg_type)); + + CMSG_DATA(&cmsg); + CMSG_NXTHDR(&mhdr, &cmsg); + CMSG_FIRSTHDR(&mhdr); + + zassert_not_equal(-1, offsetof(struct linger, l_onoff)); + zassert_not_equal(-1, offsetof(struct linger, l_linger)); + + zassert_not_equal(-1, SOCK_DGRAM); + zassert_not_equal(-1, SOCK_RAW); + /* zassert_not_equal(-1, SOCK_SEQPACKET); */ /* not implemented */ + zassert_not_equal(-1, SOCK_STREAM); + + zassert_not_equal(-1, SO_ACCEPTCONN); + zassert_not_equal(-1, SO_BROADCAST); + zassert_not_equal(-1, SO_DEBUG); + zassert_not_equal(-1, SO_DONTROUTE); + zassert_not_equal(-1, SO_ERROR); + zassert_not_equal(-1, SO_KEEPALIVE); + zassert_not_equal(-1, SO_LINGER); + zassert_not_equal(-1, SO_OOBINLINE); + zassert_not_equal(-1, SO_RCVBUF); + zassert_not_equal(-1, SO_RCVLOWAT); + zassert_not_equal(-1, SO_RCVTIMEO); + zassert_not_equal(-1, SO_REUSEADDR); + zassert_not_equal(-1, SO_SNDBUF); + zassert_not_equal(-1, SO_SNDLOWAT); + zassert_not_equal(-1, SO_SNDTIMEO); + zassert_not_equal(-1, SO_TYPE); + + zassert_not_equal(-1, SOMAXCONN); + + /* zassert_not_equal(-1, MSG_CTRUNC); */ /* not implemented */ + /* zassert_not_equal(-1, MSG_DONTROUTE); */ /* not implemented */ + /* zassert_not_equal(-1, MSG_EOR); */ /* not implemented */ + /* zassert_not_equal(-1, MSG_OOB); */ /* not implemented */ + /* zassert_not_equal(-1, MSG_NOSIGNAL); */ /* not implemented */ + zassert_not_equal(-1, MSG_PEEK); + zassert_not_equal(-1, MSG_TRUNC); + zassert_not_equal(-1, MSG_WAITALL); + + zassert_not_equal(-1, AF_INET); + zassert_not_equal(-1, AF_INET6); + zassert_not_equal(-1, AF_UNIX); + zassert_not_equal(-1, AF_UNSPEC); + + zassert_not_equal(-1, SHUT_RD); + zassert_not_equal(-1, SHUT_RDWR); + zassert_not_equal(-1, SHUT_WR); + + if (IS_ENABLED(CONFIG_POSIX_API)) { + zassert_not_null(accept); + zassert_not_null(bind); + zassert_not_null(connect); + zassert_not_null(getpeername); + zassert_not_null(getsockname); + zassert_not_null(listen); + zassert_not_null(recv); + zassert_not_null(recvfrom); + /* zassert_not_null(recvmsg); */ /* not implemented */ + zassert_not_null(send); + zassert_not_null(sendmsg); + zassert_not_null(sendto); + zassert_not_null(setsockopt); + zassert_not_null(shutdown); + /* zassert_not_null(sockatmark); */ /* not implemented */ + zassert_not_null(socket); + zassert_not_null(socketpair); + } +} +#pragma GCC diagnostic pop diff --git a/tests/posix/headers/src/sys_time_h.c b/tests/posix/headers/src/sys_time_h.c new file mode 100644 index 0000000000..aa76694396 --- /dev/null +++ b/tests/posix/headers/src/sys_time_h.c @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2022 Meta + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "_common.h" + +#ifdef CONFIG_POSIX_API +#include +#else +#include +#endif + +/** + * @brief existence test for `` + * + * @see sys/time.h + */ +ZTEST(posix_headers, test_sys_time_h) +{ + zassert_not_equal(-1, offsetof(struct timeval, tv_sec)); + zassert_not_equal(-1, offsetof(struct timeval, tv_usec)); + + /* zassert_not_equal(-1, offsetof(struct itimerval, it_interval)); */ /* not implemented */ + /* zassert_not_equal(-1, offsetof(struct itimerval, it_value)); */ /* not implemented */ + + /* zassert_not_equal(-1, ITIMER_REAL); */ /* not implemented */ + /* zassert_not_equal(-1, ITIMER_VIRTUAL); */ /* not implemented */ + /* zassert_not_equal(-1, ITIMER_PROF); */ /* not implemented */ + + if (IS_ENABLED(CONFIG_POSIX_API)) { + /* zassert_not_null(getitimer); */ /* not implemented */ + zassert_not_null(gettimeofday); + /* zassert_not_null(setitimer); */ /* not implemented */ + /* zassert_not_null(utimes); */ /* not implemented */ + } +} diff --git a/tests/posix/headers/src/unistd_h.c b/tests/posix/headers/src/unistd_h.c new file mode 100644 index 0000000000..79586c5b00 --- /dev/null +++ b/tests/posix/headers/src/unistd_h.c @@ -0,0 +1,389 @@ +/* + * Copyright (c) 2022 Meta + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "_common.h" + +#ifdef CONFIG_POSIX_API +#include +#else +#include +#endif + +/** + * @brief existence test for `` + * + * @see unistd.h + */ +ZTEST(posix_headers, test_unistd_h) +{ + /* zassert_not_equal(-1, _POSIX_VERSION); */ /* not implemented */ + /* zassert_not_equal(-1, _POSIX2_VERSION); */ /* not implemented */ + /* zassert_not_equal(-1, _XOPEN_VERSION); */ /* not implemented */ + + /* zassert_not_equal(INT_MIN, _POSIX_ADVISORY_INFO); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_ASYNCHRONOUS_IO); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_BARRIERS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_CHOWN_RESTRICTED); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_CPUTIME); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_FSYNC); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_IPV6); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_JOB_CONTROL); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_MAPPED_FILES); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_MEMLOCK); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_MEMLOCK_RANGE); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_MEMORY_PROTECTION); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_MESSAGE_PASSING); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_MONOTONIC_CLOCK); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_NO_TRUNC); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_PRIORITIZED_IO); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_PRIORITY_SCHEDULING); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_RAW_SOCKETS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_READER_WRITER_LOCKS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_REALTIME_SIGNALS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_REGEXP); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_SAVED_IDS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_SHARED_MEMORY_OBJECTS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_SHELL); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_SPAWN); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_SPIN_LOCKS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_SPORADIC_SERVER); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_SYNCHRONIZED_IO); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_THREAD_ATTR_STACKADDR); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_THREAD_ATTR_STACKSIZE); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_THREAD_CPUTIME); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_THREAD_PRIO_INHERIT); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_THREAD_PRIO_PROTECT); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_THREAD_PRIORITY_SCHEDULING); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_THREAD_PROCESS_SHARED); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_THREAD_ROBUST_PRIO_INHERIT); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_THREAD_ROBUST_PRIO_PROTECT); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_THREAD_SAFE_FUNCTIONS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_THREAD_SPORADIC_SERVER); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_THREADS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_TIMEOUTS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_TIMERS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_TRACE); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_TRACE_EVENT_FILTER); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_TRACE_INHERIT); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_TRACE_LOG); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_TYPED_MEMORY_OBJECTS); */ /* not implemented */ + + /* zassert_not_equal(INT_MIN, _POSIX_V6_ILP32_OFF32); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_V6_ILP32_OFFBIG); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_V6_LP64_OFF64); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_V6_LPBIG_OFFBIG); */ /* not implemented */ + + /* zassert_not_equal(INT_MIN, _POSIX_V7_ILP32_OFF32); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_V7_ILP32_OFFBIG); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_V7_LP64_OFF64); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_V7_LPBIG_OFFBIG); */ /* not implemented */ + + /* zassert_not_equal(INT_MIN, _POSIX2_C_BIND); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX2_C_DEV); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX2_CHAR_TERM); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX2_FORT_DEV); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX2_FORT_RUN); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX2_LOCALEDEF); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX2_PBS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX2_PBS_ACCOUNTING); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX2_PBS_CHECKPOINT); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX2_PBS_LOCATE); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX2_PBS_MESSAGE); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX2_PBS_TRACK); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX2_SW_DEV); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX2_UPE); */ /* not implemented */ + + /* zassert_not_equal(INT_MIN, _XOPEN_CRYPT); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _XOPEN_ENH_I18N); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _XOPEN_REALTIME); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _XOPEN_REALTIME_THREADS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _XOPEN_SHM); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _XOPEN_STREAMS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _XOPEN_UNIX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _XOPEN_UUCP); */ /* not implemented */ + + /* zassert_not_equal(INT_MIN, _POSIX_ASYNC_IO); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_PRIO_IO); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX_SYNC_IO); */ /* not implemented */ + + /* zassert_not_equal(-1, _POSIX_TIMESTAMP_RESOLUTION); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _POSIX2_SYMLINKS); */ /* not implemented */ + + /* zassert_not_equal(-1, F_OK); */ /* not implemented */ + /* zassert_not_equal(-1, R_OK); */ /* not implemented */ + /* zassert_not_equal(-1, W_OK); */ /* not implemented */ + /* zassert_not_equal(-1, X_OK); */ /* not implemented */ + + /* zassert_not_equal(INT_MIN, _CS_PATH); */ /* not implemented */ + + /* zassert_not_equal(INT_MIN, _CS_POSIX_V7_ILP32_OFF32_CFLAGS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _CS_POSIX_V7_ILP32_OFF32_LDFLAGS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _CS_POSIX_V7_ILP32_OFF32_LIBS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _CS_POSIX_V7_ILP32_OFFBIG_LIBS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _CS_POSIX_V7_LP64_OFF64_CFLAGS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _CS_POSIX_V7_LP64_OFF64_LDFLAGS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _CS_POSIX_V7_LP64_OFF64_LIBS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _CS_POSIX_V7_LPBIG_OFFBIG_LIBS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _CS_POSIX_V7_THREADS_CFLAGS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _CS_POSIX_V7_THREADS_LDFLAGS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _CS_V7_ENV); */ /* not implemented */ + + /* zassert_not_equal(-1, F_LOCK); */ /* not implemented */ + /* zassert_not_equal(-1, F_TEST); */ /* not implemented */ + /* zassert_not_equal(-1, F_TLOCK); */ /* not implemented */ + /* zassert_not_equal(-1, F_ULOCK); */ /* not implemented */ + + /* zassert_not_equal(INT_MIN, _PC_2_SYMLINKS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _PC_ALLOC_SIZE_MIN); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _PC_ASYNC_IO); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _PC_CHOWN_RESTRICTED); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _PC_FILESIZEBITS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _PC_LINK_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _PC_MAX_CANON); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _PC_MAX_INPUT); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _PC_NAME_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _PC_NO_TRUNC); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _PC_PATH_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _PC_PIPE_BUF); */ /* not imp``lemented */ + /* zassert_not_equal(INT_MIN, _PC_PRIO_IO); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _PC_REC_INCR_XFER_SIZE); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _PC_REC_MAX_XFER_SIZE); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _PC_REC_MIN_XFER_SIZE); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _PC_REC_XFER_ALIGN); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _PC_SYMLINK_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _PC_SYNC_IO); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _PC_TIMESTAMP_RESOLUTION); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _PC_VDISABLE); */ /* not implemented */ + + /* zassert_not_equal(INT_MIN, _SC_2_C_BIND); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_2_C_DEV); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_2_CHAR_TERM); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_2_FORT_DEV); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_2_FORT_RUN); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_2_LOCALEDEF); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_2_PBS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_2_PBS_ACCOUNTING); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_2_PBS_CHECKPOINT); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_2_PBS_LOCATE); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_2_PBS_MESSAGE); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_2_PBS_TRACK); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_2_SW_DEV); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_2_UPE); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_2_VERSION); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_ADVISORY_INFO); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_AIO_LISTIO_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_AIO_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_AIO_PRIO_DELTA_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_ARG_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_ASYNCHRONOUS_IO); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_ATEXIT_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_BARRIERS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_BC_BASE_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_BC_DIM_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_BC_SCALE_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_BC_STRING_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_CHILD_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_CLK_TCK); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_CLOCK_SELECTION); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_COLL_WEIGHTS_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_CPUTIME); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_DELAYTIMER_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_EXPR_NEST_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_FSYNC); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_GETGR_R_SIZE_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_GETPW_R_SIZE_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_HOST_NAME_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_IOV_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_IPV6); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_JOB_CONTROL); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_LINE_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_LOGIN_NAME_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_MAPPED_FILES); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_MEMLOCK); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_MEMLOCK_RANGE); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_MEMORY_PROTECTION); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_MESSAGE_PASSING); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_MONOTONIC_CLOCK); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_MQ_OPEN_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_MQ_PRIO_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_NGROUPS_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_OPEN_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_PAGE_SIZE); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_PAGESIZE); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_PRIORITIZED_IO); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_PRIORITY_SCHEDULING); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_RAW_SOCKETS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_RE_DUP_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_READER_WRITER_LOCKS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_REALTIME_SIGNALS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_REGEXP); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_RTSIG_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_SAVED_IDS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_SEM_NSEMS_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_SEM_VALUE_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_SEMAPHORES); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_SHARED_MEMORY_OBJECTS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_SHELL); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_SIGQUEUE_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_SPAWN); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_SPIN_LOCKS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_SPORADIC_SERVER); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_SS_REPL_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_STREAM_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_SYMLOOP_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_SYNCHRONIZED_IO); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_THREAD_ATTR_STACKADDR); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_THREAD_ATTR_STACKSIZE); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_THREAD_CPUTIME); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_THREAD_DESTRUCTOR_ITERATIONS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_THREAD_KEYS_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_THREAD_PRIO_INHERIT); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_THREAD_PRIO_PROTECT); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_THREAD_PRIORITY_SCHEDULING); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_THREAD_PROCESS_SHARED); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_THREAD_ROBUST_PRIO_INHERIT); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_THREAD_ROBUST_PRIO_PROTECT); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_THREAD_SAFE_FUNCTIONS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_THREAD_SPORADIC_SERVER); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_THREAD_STACK_MIN); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_THREAD_THREADS_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_THREADS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_TIMEOUTS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_TIMER_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_TIMERS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_TRACE); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_TRACE_EVENT_FILTER); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_TRACE_EVENT_NAME_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_TRACE_INHERIT); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_TRACE_LOG); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_TRACE_NAME_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_TRACE_SYS_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_TRACE_USER_EVENT_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_TTY_NAME_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_TYPED_MEMORY_OBJECTS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_TZNAME_MAX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_V7_ILP32_OFF32); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_V7_ILP32_OFFBIG); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_V7_LP64_OFF64); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_V7_LPBIG_OFFBIG); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_V6_ILP32_OFF32); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_V6_ILP32_OFFBIG); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_V6_LP64_OFF64); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_V6_LPBIG_OFFBIG); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_VERSION); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_XOPEN_CRYPT); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_XOPEN_ENH_I18N); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_XOPEN_REALTIME); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_XOPEN_REALTIME_THREADS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_XOPEN_SHM); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_XOPEN_STREAMS); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_XOPEN_UNIX); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_XOPEN_UUCP); */ /* not implemented */ + /* zassert_not_equal(INT_MIN, _SC_XOPEN_VERSION); */ /* not implemented */ + + /* zassert_equal(STDERR_FILENO, 2); */ /* not implemented */ + /* zassert_equal(STDIN_FILENO, 0); */ /* not implemented */ + /* zassert_equal(STDOUT_FILENO, 1); */ /* not implemented */ + + /* zassert_not_equal(INT_MIN, _POSIX_VDISABLE); */ /* not implemented */ + +/* + * FIXME: this should really use IS_ENABLED() + * When CONFIG_POSIX_API is n-selected (i.e. POSIX headers can only be + * included with , i.e. are namespaced), then there + * should be no reason to conditionally declare standard posix + * function prototypes. + */ +#ifdef CONFIG_POSIX_API + /* zassert_not_null(access); */ /* not implemented */ + /* zassert_not_null(alarm); */ /* not implemented */ + /* zassert_not_null(chdir); */ /* not implemented */ + /* zassert_not_null(chown); */ /* not implemented */ + zassert_not_null(close); + /* zassert_not_null(confstr); */ /* not implemented */ + /* zassert_not_null(crypt); */ /* not implemented */ + /* zassert_not_null(dup); */ /* not implemented */ + /* zassert_not_null(dup2); */ /* not implemented */ + zassert_not_null(_exit); + /* zassert_not_null(encrypt); */ /* not implemented */ + /* zassert_not_null(execl); */ /* not implemented */ + /* zassert_not_null(execle); */ /* not implemented */ + /* zassert_not_null(execlp); */ /* not implemented */ + /* zassert_not_null(execv); */ /* not implemented */ + /* zassert_not_null(execve); */ /* not implemented */ + /* zassert_not_null(execvp); */ /* not implemented */ + /* zassert_not_null(faccessat); */ /* not implemented */ + /* zassert_not_null(fchdir); */ /* not implemented */ + /* zassert_not_null(fchown); */ /* not implemented */ + /* zassert_not_null(fchownat); */ /* not implemented */ + /* zassert_not_null(fdatasync); */ /* not implemented */ + /* zassert_not_null(fexecve); */ /* not implemented */ + /* zassert_not_null(fork); */ /* not implemented */ + /* zassert_not_null(fpathconf); */ /* not implemented */ + /* zassert_not_null(fsync); */ /* not implemented */ + /* zassert_not_null(ftruncate); */ /* not implemented */ + /* zassert_not_null(getcwd); */ /* not implemented */ + /* zassert_not_null(getegid); */ /* not implemented */ + /* zassert_not_null(geteuid); */ /* not implemented */ + /* zassert_not_null(getgid); */ /* not implemented */ + /* zassert_not_null(getgroups); */ /* not implemented */ + /* zassert_not_null(gethostid); */ /* not implemented */ + /* zassert_not_null(gethostname); */ /* not implemented */ + /* zassert_not_null(getlogin); */ /* not implemented */ + /* zassert_not_null(getlogin_r); */ /* not implemented */ + zassert_not_null(getopt); + /* zassert_not_null(getpgid); */ /* not implemented */ + /* zassert_not_null(getpgrp); */ /* not implemented */ + /* zassert_not_null(getpid); */ /* not implemented */ + /* zassert_not_null(getppid); */ /* not implemented */ + /* zassert_not_null(getsid); */ /* not implemented */ + /* zassert_not_null(getuid); */ /* not implemented */ + /* zassert_not_null(isatty); */ /* not implemented */ + /* zassert_not_null(lchown); */ /* not implemented */ + /* zassert_not_null(link); */ /* not implemented */ + /* zassert_not_null(linkat); */ /* not implemented */ + /* zassert_not_null(lockf); */ /* not implemented */ + zassert_not_null(lseek); + /* zassert_not_null(nice); */ /* not implemented */ + /* zassert_not_null(pathconf); */ /* not implemented */ + /* zassert_not_null(pause); */ /* not implemented */ + /* zassert_not_null(pipe); */ /* not implemented */ + /* zassert_not_null(pread); */ /* not implemented */ + /* zassert_not_null(pwrite); */ /* not implemented */ + zassert_not_null(read); + /* zassert_not_null(readlink); */ /* not implemented */ + /* zassert_not_null(readlinkat); */ /* not implemented */ + /* zassert_not_null(rmdir); */ /* not implemented */ + /* zassert_not_null(setegid); */ /* not implemented */ + /* zassert_not_null(seteuid); */ /* not implemented */ + /* zassert_not_null(setgid); */ /* not implemented */ + /* zassert_not_null(setpgid); */ /* not implemented */ + /* zassert_not_null(setpgrp); */ /* not implemented */ + /* zassert_not_null(setregid); */ /* not implemented */ + /* zassert_not_null(setreuid); */ /* not implemented */ + /* zassert_not_null(setsid); */ /* not implemented */ + /* zassert_not_null(setuid); */ /* not implemented */ + zassert_not_null(sleep); + /* zassert_not_null(swab); */ /* not implemented */ + /* zassert_not_null(symlink); */ /* not implemented */ + /* zassert_not_null(symlinkat); */ /* not implemented */ + /* zassert_not_null(sync); */ /* not implemented */ + /* zassert_not_null(sysconf); */ /* not implemented */ + /* zassert_not_null(tcgetpgrp); */ /* not implemented */ + /* zassert_not_null(tcsetpgrp); */ /* not implemented */ + /* zassert_not_null(truncate); */ /* not implemented */ + /* zassert_not_null(ttyname); */ /* not implemented */ + /* zassert_not_null(ttyname_r); */ /* not implemented */ + zassert_not_null(unlink); + /* zassert_not_null(unlinkat); */ /* not implemented */ + zassert_not_null(write); +#endif +} diff --git a/tests/posix/headers/testcase.yaml b/tests/posix/headers/testcase.yaml new file mode 100644 index 0000000000..fde61e0745 --- /dev/null +++ b/tests/posix/headers/testcase.yaml @@ -0,0 +1,44 @@ +common: + arch_exclude: posix + tags: posix net socket + +tests: + portability.posix.headers.with_posix_api: + extra_configs: + - CONFIG_POSIX_API=y + portability.posix.headers.without_posix_api: + extra_configs: + - CONFIG_POSIX_API=n + portability.posix.headers.picolibc.with_posix_api: + tags: picolibc + filter: CONFIG_PICOLIBC_SUPPORTED + extra_configs: + - CONFIG_POSIX_API=y + - CONFIG_PICOLIBC=y + portability.posix.headers.picolibc.without_posix_api: + tags: picolibc + filter: CONFIG_PICOLIBC_SUPPORTED + extra_configs: + - CONFIG_POSIX_API=n + - CONFIG_PICOLIBC=y + portability.posix.headers.newlib.with_posix_api: + tags: newlib + filter: TOOLCHAIN_HAS_NEWLIB == 1 + extra_configs: + - CONFIG_POSIX_API=y + - CONFIG_NEWLIB_LIBC=y + portability.posix.headers.newlib.without_posix_api: + filter: TOOLCHAIN_HAS_NEWLIB == 1 + extra_configs: + - CONFIG_POSIX_API=n + - CONFIG_NEWLIB_LIBC=y + portability.posix.headers.arcmwdtlib.with_posix_api: + toolchain_allow: arcmwdt + extra_configs: + - CONFIG_POSIX_API=y + - CONFIG_ARCMWDT_LIBC=y + portability.posix.headers.arcmwdtlib.without_posix_api: + toolchain_allow: arcmwdt + extra_configs: + - CONFIG_POSIX_API=n + - CONFIG_ARCMWDT_LIBC=y