The locale names that I hardcoded in some tests are not those present in some systems. This patch fixes it.
2024-07-13 Bruno Haible <br...@clisp.org> tests: Don't depend on the exact locale name. * tests/test-c-ctype.c: Include <stdlib.h>. (main): Test the return value of setlocale(). Try not only de_DE, but also de_DE.ISO-8859-1. * tests/test-vasnprintf-posix3.c (main): Try not only fa_IR.UTF-8, but also fa_IR. * tests/test-vasnwprintf-posix3.c (main): Likewise. diff --git a/tests/test-c-ctype.c b/tests/test-c-ctype.c index 898e79cc8a..7816543a72 100644 --- a/tests/test-c-ctype.c +++ b/tests/test-c-ctype.c @@ -23,6 +23,7 @@ #include <ctype.h> #include <limits.h> #include <locale.h> +#include <stdlib.h> #include "macros.h" @@ -218,11 +219,16 @@ main () test_all (); - setlocale (LC_ALL, "de_DE"); - test_all (); + /* Run the tests in a German unibyte locale. */ + if ((setlocale (LC_ALL, "de_DE") != NULL + || setlocale (LC_ALL, "de_DE.ISO-8859-1") != NULL) + && MB_CUR_MAX == 1) + test_all (); - setlocale (LC_ALL, "ja_JP.EUC-JP"); - test_all (); + /* Run the tests in a traditional Japanese locale. */ + if (setlocale (LC_ALL, "ja_JP.EUC-JP") != NULL + && MB_CUR_MAX == 2) + test_all (); return test_exit_status; } diff --git a/tests/test-vasnprintf-posix3.c b/tests/test-vasnprintf-posix3.c index 0db514c601..568bfa912e 100644 --- a/tests/test-vasnprintf-posix3.c +++ b/tests/test-vasnprintf-posix3.c @@ -79,7 +79,8 @@ main (int argc, char *argv[]) { #if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__ /* Select a locale with Arabic 'outdigits'. */ - if (setlocale (LC_ALL, "fa_IR.UTF-8") == NULL) + if (setlocale (LC_ALL, "fa_IR.UTF-8") == NULL + && setlocale (LC_ALL, "fa_IR") == NULL) { fprintf (stderr, "Skipping test: no Iranian locale is installed\n"); return 77; diff --git a/tests/test-vasnwprintf-posix3.c b/tests/test-vasnwprintf-posix3.c index f2ddc82660..53923bab77 100644 --- a/tests/test-vasnwprintf-posix3.c +++ b/tests/test-vasnwprintf-posix3.c @@ -83,7 +83,8 @@ main (int argc, char *argv[]) { #if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__ /* Select a locale with Arabic 'outdigits'. */ - if (setlocale (LC_ALL, "fa_IR.UTF-8") == NULL) + if (setlocale (LC_ALL, "fa_IR.UTF-8") == NULL + && setlocale (LC_ALL, "fa_IR") == NULL) { fprintf (stderr, "Skipping test: no Iranian locale is installed\n"); return 77;