]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
string: Make tst-strerror/tst-strsignal unsupported if msgfmt is not installed
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 9 Jul 2020 16:24:04 +0000 (13:24 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 13 Jul 2020 12:16:11 +0000 (09:16 -0300)
Without msgfmt libc.mo files are not generated and its loading failure
is silent ignored with xsetlocale.

Also unset LANGUAGE environment variable to avoid it taking precedence
when loading the message catalog.  Although not strictly required
(since the test is issued with test-container and it sets a strict
environment variable) it follows other tests that deal with
translation.

Checked on x86_64-linux-gnu.

string/Makefile
string/tst-strerror.c
string/tst-strsignal.c

index 206c9b103c145e548ab192391701b99cf1d9063c..c5b8909f372d65b38ff30c2a754554a8d261a050 100644 (file)
@@ -65,7 +65,14 @@ tests                := tester inl-tester noinl-tester testcopy test-ffs     \
                   test-endian-sign-conversion tst-memmove-overflow     \
                   test-sig_np
 
-tests-container += tst-strsignal tst-strerror
+# Both tests require the .mo translation files generated by msgfmt.
+tests-translation := tst-strsignal                                     \
+                    tst-strerror
+
+tests-container   += $(tests-translation)
+ifeq ($(MSGFMT),:)
+tests-unsupported += $(tests-translation)
+endif
 
 # This test allocates a lot of memory and can run for a long time.
 xtests = tst-strcoll-overflow
index 3af51236d7f66ae645b1be8b5b2834d1f3be0e84..1fc202e4eaa0abc0ed7a8de16b775469eaefde5d 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <string.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <errno.h>
 #include <locale.h>
 #include <array_length.h>
@@ -29,6 +30,8 @@
 static int
 do_test (void)
 {
+  unsetenv ("LANGUAGE");
+
   xsetlocale (LC_ALL, "C");
 
   TEST_COMPARE_STRING (strerror (EINVAL), "Invalid argument");
index 3f6764989f27501b7371ef27a016ba51b9bf6c50..2c549f4620a6d9181791416c9d8fe1026d268898 100644 (file)
@@ -20,6 +20,7 @@
 #include <string.h>
 #include <stdio.h>
 #include <signal.h>
+#include <stdlib.h>
 #include <locale.h>
 #include <array_length.h>
 
@@ -29,6 +30,8 @@
 static int
 do_test (void)
 {
+  unsetenv ("LANGUAGE");
+
   xsetlocale (LC_ALL, "C");
 
   TEST_COMPARE_STRING (strsignal (SIGINT),     "Interrupt");