public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] string: Make tst-strerror/tst-strsignal unsupported if msgfmt is not installed
@ 2020-07-13 12:33 Adhemerval Zanella
  0 siblings, 0 replies; only message in thread
From: Adhemerval Zanella @ 2020-07-13 12:33 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=10b01bd4529336bffc2c398ce43a171ed94aacc7

commit 10b01bd4529336bffc2c398ce43a171ed94aacc7
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Jul 9 13:24:04 2020 -0300

    string: Make tst-strerror/tst-strsignal unsupported if msgfmt is not installed
    
    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.

Diff:
---
 string/Makefile        | 9 ++++++++-
 string/tst-strerror.c  | 3 +++
 string/tst-strsignal.c | 3 +++
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/string/Makefile b/string/Makefile
index 206c9b103c..c5b8909f37 100644
--- a/string/Makefile
+++ b/string/Makefile
@@ -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
diff --git a/string/tst-strerror.c b/string/tst-strerror.c
index 3af51236d7..1fc202e4ea 100644
--- a/string/tst-strerror.c
+++ b/string/tst-strerror.c
@@ -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");
diff --git a/string/tst-strsignal.c b/string/tst-strsignal.c
index 3f6764989f..2c549f4620 100644
--- a/string/tst-strsignal.c
+++ b/string/tst-strsignal.c
@@ -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");


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-07-13 12:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-13 12:33 [glibc] string: Make tst-strerror/tst-strsignal unsupported if msgfmt is not installed Adhemerval Zanella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).