From 10b01bd4529336bffc2c398ce43a171ed94aacc7 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Thu, 9 Jul 2020 13:24:04 -0300 Subject: 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. --- string/Makefile | 9 ++++++++- string/tst-strerror.c | 3 +++ string/tst-strsignal.c | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) (limited to 'string') diff --git a/string/Makefile b/string/Makefile index 206c9b1..c5b8909 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 3af5123..1fc202e 100644 --- a/string/tst-strerror.c +++ b/string/tst-strerror.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -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 3f67649..2c549f4 100644 --- a/string/tst-strsignal.c +++ b/string/tst-strsignal.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -29,6 +30,8 @@ static int do_test (void) { + unsetenv ("LANGUAGE"); + xsetlocale (LC_ALL, "C"); TEST_COMPARE_STRING (strsignal (SIGINT), "Interrupt"); -- cgit v1.1