+2024-05-23 Bruno Haible <bruno@clisp.org>
+
+ sethostname tests: Avoid test failure on Cygwin.
+ * tests/test-sethostname2.c (main): On Cygwin, skip the "too long
+ hostname" test.
+ * doc/glibc-functions/sethostname.texi: Mention the Cygwin problem.
+
2024-05-23 Bruno Haible <bruno@clisp.org>
access, euidaccess tests: Avoid test failures on Cygwin.
The second parameter is @code{int} instead of @code{size_t}
on some platforms:
macOS 12.5, FreeBSD 14.0, MidnightBSD 3.0, Solaris 11 2010-11, Solaris 11 OpenIndiana, Solaris 11 OmniOS.
+@item
+This function does not reject a too long host name on some platforms:
+@c https://cygwin.com/pipermail/cygwin/2024-May/255986.html
+Cygwin 3.5.3.
@end itemize
{
char origname[HOST_NAME_MAX];
char newname[HOST_NAME_MAX];
- char longname[HOST_NAME_MAX + 2];
int rcs, i;
/* skip the tests if we don't have root privilege. this does not
#endif
}
- /* glibc does allow setting a zero length name, so the lower bound
- needs no test. validate that we are constrained by
- HOST_NAME_MAX */
- for (i = 0; i < (HOST_NAME_MAX + 1); i++)
- longname[i] = 'a';
-
- longname[i] = '\0';
-
- rcs = sethostname (longname, (HOST_NAME_MAX + 1));
-
- if (rcs != -1)
- {
- /* attempt to restore the original name. */
- ASSERT (sethostname (origname, strlen (origname)) == 0);
- fprintf (stderr, "setting a too long hostname succeeded.\n");
- return 1;
- }
+ /* Known Cygwin bug:
+ <https://cygwin.com/pipermail/cygwin/2024-May/255986.html> */
+#if !defined __CYGWIN__
+ {
+ char longname[HOST_NAME_MAX + 2];
+
+ /* glibc does allow setting a zero length name, so the lower bound
+ needs no test. validate that we are constrained by
+ HOST_NAME_MAX */
+ for (i = 0; i < (HOST_NAME_MAX + 1); i++)
+ longname[i] = 'a';
+
+ longname[i] = '\0';
+
+ rcs = sethostname (longname, (HOST_NAME_MAX + 1));
+
+ if (rcs != -1)
+ {
+ /* attempt to restore the original name. */
+ ASSERT (sethostname (origname, strlen (origname)) == 0);
+ fprintf (stderr, "setting a too long hostname succeeded.\n");
+ return 1;
+ }
+ }
+#endif
/* restore the original name. */
ASSERT (sethostname (origname, strlen (origname)) == 0);