* modules/sys_socket-tests (Depends-on): Add assert-h.
* tests/test-sys_socket.c (a): Remove variable.
(main): Test that each supported address family is defined to a distinct
value. Test that each constant passed as the second argument of
'shutdown' is defined to a distinct value.
+2024-07-22 Collin Funk <collin.funk1@gmail.com>
+
+ sys_socket tests: Improve tests for macro definitions.
+ * modules/sys_socket-tests (Depends-on): Add assert-h.
+ * tests/test-sys_socket.c (a): Remove variable.
+ (main): Test that each supported address family is defined to a distinct
+ value. Test that each constant passed as the second argument of
+ 'shutdown' is defined to a distinct value.
+
2024-07-22 Bruno Haible <bruno@clisp.org>
gnulib-tool: Omit the logs of skipped tests from test-suite.log.
tests/test-sys_socket.c
Depends-on:
+assert-h
sys_socket-c++-tests
configure.ac:
#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;
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;