summaryrefslogtreecommitdiff
path: root/tests/test-sys_socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-sys_socket.c')
-rw-r--r--tests/test-sys_socket.c45
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;