diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2025-03-22 18:00:25 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2025-03-22 18:00:25 +0100 |
commit | 0737819efdd0bae112d16d874cac7e747e43cd08 (patch) | |
tree | 98a9ac84f7f347ae530c14852c68870682f3d04c /tests/test-sys_socket.c | |
parent | 163a663518f33bab48b28431972e580b366b4d49 (diff) | |
parent | e670957a8693f860cf7d77fed4ce6b4b056a8083 (diff) |
Merge branch 'release/debian/1.3-1'debian/1.3-1
Diffstat (limited to 'tests/test-sys_socket.c')
-rw-r--r-- | tests/test-sys_socket.c | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/tests/test-sys_socket.c b/tests/test-sys_socket.c index 4e0f9ad4..5c1ad115 100644 --- a/tests/test-sys_socket.c +++ b/tests/test-sys_socket.c @@ -20,10 +20,8 @@ #include <sys/socket.h> -#if HAVE_SHUTDOWN -/* Check some integer constant expressions. */ -int a[] = { SHUT_RD, SHUT_WR, SHUT_RDWR }; -#endif +/* POSIX mandates that AF_UNSPEC shall be 0. */ +static_assert (AF_UNSPEC == 0); /* Check that the 'socklen_t' type is defined. */ socklen_t t1; @@ -40,6 +38,16 @@ struct msghdr msg; #include <errno.h> +#include "intprops.h" + +/* POSIX requires that 'socklen_t' is an integer type with a width of at + least 32 bits. */ +static_assert (32 <= TYPE_WIDTH (socklen_t)); + +/* POSIX requires that sa_family_t is an unsigned integer type. */ +static_assert (! TYPE_SIGNED (sa_family_t)); + + int main (void) { @@ -59,6 +67,35 @@ main (void) break; } + /* Check that each supported address family has a distinct value. */ + switch (0) + { + case AF_UNSPEC: +#if HAVE_IPV4 + case AF_INET: +#endif +#if HAVE_IPV6 + case AF_INET6: +#endif +#if HAVE_UNIXSOCKET + case AF_UNIX: +#endif + default: + break; + } + + /* Check that the shutdown type macros are defined to distinct values. */ +#if HAVE_SHUTDOWN + switch (0) + { + case SHUT_RD: + case SHUT_WR: + case SHUT_RDWR: + default: + break; + } +#endif + x.ss_family = 42; i = 42; msg.msg_iov = &io; |