public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] string: Do not run tst-strerror/tst-strsignal if msgfmt is not installed
@ 2020-07-09 16:37 Adhemerval Zanella
  2020-07-09 17:03 ` Andreas Schwab
  2020-07-09 17:12 ` Carlos O'Donell
  0 siblings, 2 replies; 7+ messages in thread
From: Adhemerval Zanella @ 2020-07-09 16:37 UTC (permalink / raw)
  To: libc-alpha

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        | 3 +++
 string/tst-strerror.c  | 3 +++
 string/tst-strsignal.c | 3 +++
 3 files changed, 9 insertions(+)

diff --git a/string/Makefile b/string/Makefile
index 206c9b103c..6d4f88ef36 100644
--- a/string/Makefile
+++ b/string/Makefile
@@ -65,7 +65,10 @@ tests		:= tester inl-tester noinl-tester testcopy test-ffs	\
 		   test-endian-sign-conversion tst-memmove-overflow	\
 		   test-sig_np
 
+# Both tests requires the .mo translation files generated by msgfmt.
+ifneq ($(MSGFMT),:)
 tests-container += tst-strsignal tst-strerror
+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");
-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] string: Do not run tst-strerror/tst-strsignal if msgfmt is not installed
  2020-07-09 16:37 [PATCH] string: Do not run tst-strerror/tst-strsignal if msgfmt is not installed Adhemerval Zanella
@ 2020-07-09 17:03 ` Andreas Schwab
  2020-07-09 17:06   ` Adhemerval Zanella
  2020-07-09 17:12 ` Carlos O'Donell
  1 sibling, 1 reply; 7+ messages in thread
From: Andreas Schwab @ 2020-07-09 17:03 UTC (permalink / raw)
  To: Adhemerval Zanella via Libc-alpha

On Jul 09 2020, Adhemerval Zanella via Libc-alpha wrote:

> diff --git a/string/Makefile b/string/Makefile
> index 206c9b103c..6d4f88ef36 100644
> --- a/string/Makefile
> +++ b/string/Makefile
> @@ -65,7 +65,10 @@ tests		:= tester inl-tester noinl-tester testcopy test-ffs	\
>  		   test-endian-sign-conversion tst-memmove-overflow	\
>  		   test-sig_np
>  
> +# Both tests requires the .mo translation files generated by msgfmt.

s/requires/require/

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] string: Do not run tst-strerror/tst-strsignal if msgfmt is not installed
  2020-07-09 17:03 ` Andreas Schwab
@ 2020-07-09 17:06   ` Adhemerval Zanella
  0 siblings, 0 replies; 7+ messages in thread
From: Adhemerval Zanella @ 2020-07-09 17:06 UTC (permalink / raw)
  To: Andreas Schwab, Adhemerval Zanella via Libc-alpha



On 09/07/2020 14:03, Andreas Schwab wrote:
> On Jul 09 2020, Adhemerval Zanella via Libc-alpha wrote:
> 
>> diff --git a/string/Makefile b/string/Makefile
>> index 206c9b103c..6d4f88ef36 100644
>> --- a/string/Makefile
>> +++ b/string/Makefile
>> @@ -65,7 +65,10 @@ tests		:= tester inl-tester noinl-tester testcopy test-ffs	\
>>  		   test-endian-sign-conversion tst-memmove-overflow	\
>>  		   test-sig_np
>>  
>> +# Both tests requires the .mo translation files generated by msgfmt.
> 
> s/requires/require/
> 
> Andreas.
> 

Ack, fixed locally.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] string: Do not run tst-strerror/tst-strsignal if msgfmt is not installed
  2020-07-09 16:37 [PATCH] string: Do not run tst-strerror/tst-strsignal if msgfmt is not installed Adhemerval Zanella
  2020-07-09 17:03 ` Andreas Schwab
@ 2020-07-09 17:12 ` Carlos O'Donell
  2020-07-09 18:28   ` [PATCH v2] string: Make tst-strerror/tst-strsignal unsupported " Adhemerval Zanella
  1 sibling, 1 reply; 7+ messages in thread
From: Carlos O'Donell @ 2020-07-09 17:12 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 7/9/20 12:37 PM, Adhemerval Zanella wrote:
> 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.

Please use tests-unsupported.

> ---
>  string/Makefile        | 3 +++
>  string/tst-strerror.c  | 3 +++
>  string/tst-strsignal.c | 3 +++
>  3 files changed, 9 insertions(+)
> 
> diff --git a/string/Makefile b/string/Makefile
> index 206c9b103c..6d4f88ef36 100644
> --- a/string/Makefile
> +++ b/string/Makefile
> @@ -65,7 +65,10 @@ tests		:= tester inl-tester noinl-tester testcopy test-ffs	\
>  		   test-endian-sign-conversion tst-memmove-overflow	\
>  		   test-sig_np
>  
> +# Both tests requires the .mo translation files generated by msgfmt.
> +ifneq ($(MSGFMT),:)

All tests should always be present in all configurations.

>  tests-container += tst-strsignal tst-strerror
> +endif

You need to use tests-unsupported to mark the tests as
unsupported.

>  
>  # 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");
> 


-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] string: Make tst-strerror/tst-strsignal unsupported if msgfmt is not installed
  2020-07-09 17:12 ` Carlos O'Donell
@ 2020-07-09 18:28   ` Adhemerval Zanella
  2020-07-09 18:35     ` Carlos O'Donell
  0 siblings, 1 reply; 7+ messages in thread
From: Adhemerval Zanella @ 2020-07-09 18:28 UTC (permalink / raw)
  To: libc-alpha

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        | 11 ++++++++++-
 string/tst-strerror.c  |  3 +++
 string/tst-strsignal.c |  3 +++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/string/Makefile b/string/Makefile
index 206c9b103c..e958431f60 100644
--- a/string/Makefile
+++ b/string/Makefile
@@ -65,7 +65,16 @@ 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
+
+ifneq ($(MSGFMT),:)
+tests-container   += $(tests-translation)
+else
+tests             += $(tests-translation)
+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");
-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] string: Make tst-strerror/tst-strsignal unsupported if msgfmt is not installed
  2020-07-09 18:28   ` [PATCH v2] string: Make tst-strerror/tst-strsignal unsupported " Adhemerval Zanella
@ 2020-07-09 18:35     ` Carlos O'Donell
  2020-07-09 18:38       ` Adhemerval Zanella
  0 siblings, 1 reply; 7+ messages in thread
From: Carlos O'Donell @ 2020-07-09 18:35 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 7/9/20 2:28 PM, Adhemerval Zanella via Libc-alpha wrote:
> 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        | 11 ++++++++++-
>  string/tst-strerror.c  |  3 +++
>  string/tst-strsignal.c |  3 +++
>  3 files changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/string/Makefile b/string/Makefile
> index 206c9b103c..e958431f60 100644
> --- a/string/Makefile
> +++ b/string/Makefile
> @@ -65,7 +65,16 @@ 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
> +
> +ifneq ($(MSGFMT),:)
> +tests-container   += $(tests-translation)
> +else
> +tests             += $(tests-translation)
> +tests-unsupported += $(tests-translation)
> +endif

Does it work if we do this?

# Both tests require the .mo translation files generated by msgfmt.
tests-container += tst-strsignal tst-strerror
ifeq ($(MSGFMT),:)
tests-unsupported += $(tests-translation)
endif

Shorter and easier to read and understand.

>  
>  # 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");
> 


-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] string: Make tst-strerror/tst-strsignal unsupported if msgfmt is not installed
  2020-07-09 18:35     ` Carlos O'Donell
@ 2020-07-09 18:38       ` Adhemerval Zanella
  0 siblings, 0 replies; 7+ messages in thread
From: Adhemerval Zanella @ 2020-07-09 18:38 UTC (permalink / raw)
  To: Carlos O'Donell, libc-alpha



On 09/07/2020 15:35, Carlos O'Donell wrote:
> On 7/9/20 2:28 PM, Adhemerval Zanella via Libc-alpha wrote:
>> 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        | 11 ++++++++++-
>>  string/tst-strerror.c  |  3 +++
>>  string/tst-strsignal.c |  3 +++
>>  3 files changed, 16 insertions(+), 1 deletion(-)
>>
>> diff --git a/string/Makefile b/string/Makefile
>> index 206c9b103c..e958431f60 100644
>> --- a/string/Makefile
>> +++ b/string/Makefile
>> @@ -65,7 +65,16 @@ 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
>> +
>> +ifneq ($(MSGFMT),:)
>> +tests-container   += $(tests-translation)
>> +else
>> +tests             += $(tests-translation)
>> +tests-unsupported += $(tests-translation)
>> +endif
> 
> Does it work if we do this?
> 
> # Both tests require the .mo translation files generated by msgfmt.
> tests-container += tst-strsignal tst-strerror
> ifeq ($(MSGFMT),:)
> tests-unsupported += $(tests-translation)
> endif
> 
> Shorter and easier to read and understand.

It does and it is indeed simpler, thanks.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-07-09 18:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-09 16:37 [PATCH] string: Do not run tst-strerror/tst-strsignal if msgfmt is not installed Adhemerval Zanella
2020-07-09 17:03 ` Andreas Schwab
2020-07-09 17:06   ` Adhemerval Zanella
2020-07-09 17:12 ` Carlos O'Donell
2020-07-09 18:28   ` [PATCH v2] string: Make tst-strerror/tst-strsignal unsupported " Adhemerval Zanella
2020-07-09 18:35     ` Carlos O'Donell
2020-07-09 18:38       ` 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).