From: Collin Funk Date: Thu, 25 Jul 2024 03:16:26 +0000 (-0700) Subject: sys_un: Add tests. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=c2d32810156e4d2473e534feca6ba141c29deeed;p=gnulib.git sys_un: Add tests. * modules/sys_un-tests: New file. * tests/test-sys_un.c: New file. --- diff --git a/ChangeLog b/ChangeLog index 6342a6ce7f..8c93d18bdc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2024-07-24 Collin Funk + 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 index 0000000000..a7d912be0c --- /dev/null +++ b/modules/sys_un-tests @@ -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 index 0000000000..c6b293179c --- /dev/null +++ b/tests/test-sys_un.c @@ -0,0 +1,50 @@ +/* Test of the 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 . */ + +/* Written by Collin Funk , 2024. */ + +#include + +#if HAVE_UNIXSOCKET + +/* Specification. */ +# include + +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 + +int +main (void) +{ + fputs ("Skipping test: UNIX domain sockets not supported\n", stderr); + return 77; +} + +#endif