]> Savannah Git Hosting - gnulib.git/commitdiff
sys_un: Add tests.
authorCollin Funk <collin.funk1@gmail.com>
Thu, 25 Jul 2024 03:16:26 +0000 (20:16 -0700)
committerCollin Funk <collin.funk1@gmail.com>
Thu, 25 Jul 2024 03:16:26 +0000 (20:16 -0700)
* modules/sys_un-tests: New file.
* tests/test-sys_un.c: New file.

ChangeLog
modules/sys_un-tests [new file with mode: 0644]
tests/test-sys_un.c [new file with mode: 0644]

index 6342a6ce7fdfd6aaf2095be90eed3ee9e3a24aec..8c93d18bdc554ded56efd6f20d8c25363e71eaa0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2024-07-24  Collin Funk  <collin.funk1@gmail.com>
 
+       sys_un: Add tests.
+       * modules/sys_un-tests: New file.
+       * tests/test-sys_un.c: New file.
+
        sys_un: New module.
        * doc/posix-headers/sys_un.texi (sys/un.h): Mention it.
        * lib/sys_un.in.h: New file.
diff --git a/modules/sys_un-tests b/modules/sys_un-tests
new file mode 100644 (file)
index 0000000..a7d912b
--- /dev/null
@@ -0,0 +1,11 @@
+Files:
+tests/test-sys_un.c
+
+Depends-on:
+assert-h
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-sys_un
+check_PROGRAMS += test-sys_un
diff --git a/tests/test-sys_un.c b/tests/test-sys_un.c
new file mode 100644 (file)
index 0000000..c6b2931
--- /dev/null
@@ -0,0 +1,50 @@
+/* Test of the <sys/un.h> substitute.
+   Copyright (C) 2024 Free Software Foundation, Inc.
+
+   This file is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published
+   by the Free Software Foundation, either version 3 of the License,
+   or (at your option) any later version.
+
+   This file is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+/* Written by Collin Funk <collin.funk1@gmail.com>, 2024.  */
+
+#include <config.h>
+
+#if HAVE_UNIXSOCKET
+
+/* Specification.  */
+# include <sys/un.h>
+
+int
+main (void)
+{
+  struct sockaddr_un sa;
+
+  /* POSIX requires sun_path is 92 bytes or greater.  */
+  static_assert (92 <= sizeof sa.sun_path);
+
+  return 0;
+}
+
+#else
+
+/* UNIX domain sockets unsupported.  */
+
+# include <stdio.h>
+
+int
+main (void)
+{
+  fputs ("Skipping test: UNIX domain sockets not supported\n", stderr);
+  return 77;
+}
+
+#endif