On Haiku, calling sethostname with a long host name does not fail. Instead it just truncates the hostname.
This patch documents it and avoids the test failure like we do on Cygwin. Not really a bug since this function isn't standardized. But since most implementations agree on rejecting large hostnames, I reported it to the Haiku tracker [1]. Collin [1] https://dev.haiku-os.org/ticket/19692
>From e936bfd8c0aad5eba0b6dfc7586d1b512bd90c26 Mon Sep 17 00:00:00 2001 Message-ID: <e936bfd8c0aad5eba0b6dfc7586d1b512bd90c26.1753325832.git.collin.fu...@gmail.com> From: Collin Funk <collin.fu...@gmail.com> Date: Wed, 23 Jul 2025 19:55:41 -0700 Subject: [PATCH] sethostname tests: Avoid test failure on Haiku. * tests/test-sethostname2.c (main): On Haiku, skip the "too long hostname" test. * doc/glibc-functions/sethostname.texi: Mention the Haiku problem. --- ChangeLog | 7 +++++++ doc/glibc-functions/sethostname.texi | 3 ++- tests/test-sethostname2.c | 7 ++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0bca5616a4..5a30fab82d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2025-07-23 Collin Funk <collin.fu...@gmail.com> + + sethostname tests: Avoid test failure on Haiku. + * tests/test-sethostname2.c (main): On Haiku, skip the "too long + hostname" test. + * doc/glibc-functions/sethostname.texi: Mention the Haiku problem. + 2025-07-23 Bruno Haible <br...@clisp.org> run-test: Suggest a more reliable way of invoking valgrind. diff --git a/doc/glibc-functions/sethostname.texi b/doc/glibc-functions/sethostname.texi index 51d1e3cb8a..16a5672797 100644 --- a/doc/glibc-functions/sethostname.texi +++ b/doc/glibc-functions/sethostname.texi @@ -44,5 +44,6 @@ @node sethostname @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. +@c https://dev.haiku-os.org/ticket/19692 +Cygwin 3.5.3, Haiku. @end itemize diff --git a/tests/test-sethostname2.c b/tests/test-sethostname2.c index df10cd3741..01a4053bfa 100644 --- a/tests/test-sethostname2.c +++ b/tests/test-sethostname2.c @@ -107,9 +107,10 @@ main (int argc, _GL_UNUSED char *argv[]) #endif } - /* Known Cygwin bug: - <https://cygwin.com/pipermail/cygwin/2024-May/255986.html> */ -#if !defined __CYGWIN__ + /* Known bug on Cygwin and Haiku: + <https://cygwin.com/pipermail/cygwin/2024-May/255986.html> + <https://dev.haiku-os.org/ticket/19692>. */ +#if !(defined __CYGWIN__ || defined __HAIKU__) { char longname[HOST_NAME_MAX + 2]; -- 2.50.1