Building a testdir for module getlocalename_l-simple, I see a test failure on NetBSD 10.0.
This patch fixes it. 2026-04-30 Bruno Haible <[email protected]> getlocalename_l-simple tests: Avoid test failure on NetBSD. * tests/test-getlocalename_l.c (FAKE_COLLATE): New macro. (main): If FAKE_COLLATE is true, don't compare the result of getlocalename_l (LC_COLLATE, ...). * doc/posix-functions/getlocalename_l.texi: Mention the NetBSD bug. diff --git a/doc/posix-functions/getlocalename_l.texi b/doc/posix-functions/getlocalename_l.texi index b8f7e495ad..c0288a1db5 100644 --- a/doc/posix-functions/getlocalename_l.texi +++ b/doc/posix-functions/getlocalename_l.texi @@ -33,4 +33,9 @@ on some platforms: @c https://cygwin.com/pipermail/cygwin/2025-March/257715.html Cygwin 3.6.0. +@item +This function always returns @code{"C"} +when the first argument is @code{LC_COLLATE} +on some platforms: +NetBSD 10.0. @end itemize diff --git a/tests/test-getlocalename_l.c b/tests/test-getlocalename_l.c index e79dd3e7eb..e17393dadf 100644 --- a/tests/test-getlocalename_l.c +++ b/tests/test-getlocalename_l.c @@ -28,6 +28,14 @@ SIGNATURE_CHECK (getlocalename_l, const char *, (int, locale_t)); #include "macros.h" +/* On NetBSD, the LC_COLLATE locales are all fake: they all have the + name "C". */ +#ifdef __NetBSD__ +# define FAKE_COLLATE 1 +#else +# define FAKE_COLLATE 0 +#endif + #ifdef __HAIKU__ /* Work around Haiku bug <https://dev.haiku-os.org/ticket/18344>. */ # define freelocale(loc) ((void) (loc)) @@ -94,7 +102,7 @@ main () const char *ret; ret = getlocalename_l (LC_COLLATE, locale1); - ASSERT (streq (ret, LOCALE1)); + if (!FAKE_COLLATE) ASSERT (streq (ret, LOCALE1)); ret = getlocalename_l (LC_CTYPE, locale1); ASSERT (streq (ret, LOCALE1)); @@ -126,7 +134,7 @@ main () const char *ret; ret = getlocalename_l (LC_COLLATE, locale2); - ASSERT (streq (ret, LOCALE2)); + if (!FAKE_COLLATE) ASSERT (streq (ret, LOCALE2)); ret = getlocalename_l (LC_CTYPE, locale2); ASSERT (streq (ret, LOCALE1)); @@ -159,7 +167,7 @@ main () const char *ret; ret = getlocalename_l (LC_COLLATE, locale2); - ASSERT (streq (ret, LOCALE1)); + if (!FAKE_COLLATE) ASSERT (streq (ret, LOCALE1)); ret = getlocalename_l (LC_CTYPE, locale2); ASSERT (streq (ret, LOCALE2)); @@ -192,7 +200,7 @@ main () const char *ret; ret = getlocalename_l (LC_COLLATE, locale2); - ASSERT (streq (ret, LOCALE1)); + if (!FAKE_COLLATE) ASSERT (streq (ret, LOCALE1)); ret = getlocalename_l (LC_CTYPE, locale2); ASSERT (streq (ret, LOCALE1)); @@ -225,7 +233,7 @@ main () const char *ret; ret = getlocalename_l (LC_COLLATE, locale2); - ASSERT (streq (ret, LOCALE1)); + if (!FAKE_COLLATE) ASSERT (streq (ret, LOCALE1)); ret = getlocalename_l (LC_CTYPE, locale2); ASSERT (streq (ret, LOCALE1)); @@ -258,7 +266,7 @@ main () const char *ret; ret = getlocalename_l (LC_COLLATE, locale2); - ASSERT (streq (ret, LOCALE1)); + if (!FAKE_COLLATE) ASSERT (streq (ret, LOCALE1)); ret = getlocalename_l (LC_CTYPE, locale2); ASSERT (streq (ret, LOCALE1)); @@ -291,7 +299,7 @@ main () const char *ret; ret = getlocalename_l (LC_COLLATE, locale2); - ASSERT (streq (ret, LOCALE1)); + if (!FAKE_COLLATE) ASSERT (streq (ret, LOCALE1)); ret = getlocalename_l (LC_CTYPE, locale2); ASSERT (streq (ret, LOCALE1)); @@ -345,7 +353,7 @@ main () const char *ret; ret = getlocalename_l (LC_COLLATE, LC_GLOBAL_LOCALE); - ASSERT (streq (ret, LOCALE1)); + if (!FAKE_COLLATE) ASSERT (streq (ret, LOCALE1)); ret = getlocalename_l (LC_CTYPE, LC_GLOBAL_LOCALE); ASSERT (streq (ret, LOCALE1));
