diff mbox series

[v5,09/13] string: Add strsignal test

Message ID 20200619134352.297146-9-adhemerval.zanella@linaro.org
State New
Headers show
Series [v5,01/13] signal: Add signum-{generic,arch}.h | expand

Commit Message

Adhemerval Zanella June 19, 2020, 1:43 p.m. UTC
Checked on x86-64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
and s390x-linux-gnu.
---
 string/Makefile        |  5 +++-
 string/tst-strsignal.c | 57 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 1 deletion(-)
 create mode 100644 string/tst-strsignal.c

Comments

Carlos O'Donell July 2, 2020, 7:55 p.m. UTC | #1
On 6/19/20 9:43 AM, Adhemerval Zanella wrote:
> Checked on x86-64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
> and s390x-linux-gnu.

OK for master if you fix the typo.

No regressions on x86_64 and i686.

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> ---
>  string/Makefile        |  5 +++-
>  string/tst-strsignal.c | 57 ++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 61 insertions(+), 1 deletion(-)
>  create mode 100644 string/tst-strsignal.c
> 
> diff --git a/string/Makefile b/string/Makefile
> index e1cca5516b..470ff77ded 100644
> --- a/string/Makefile
> +++ b/string/Makefile
> @@ -65,6 +65,8 @@ tests		:= tester inl-tester noinl-tester testcopy test-ffs	\
>  # This test allocates a lot of memory and can run for a long time.
>  xtests = tst-strcoll-overflow
>  
> +tests-container += tst-strsignal

OK.

> +
>  # This test needs libdl.
>  ifeq (yes,$(build-shared))
>  tests += test-strerror-errno
> @@ -105,7 +107,7 @@ $(objpfx)tst-svc-cmp.out: tst-svc.expect $(objpfx)tst-svc.out
>  
>  LOCALES := de_DE.UTF-8 en_US.ISO-8859-1 en_US.UTF-8 \
>             tr_TR.ISO-8859-9 tr_TR.UTF-8 cs_CZ.UTF-8 \
> -	   da_DK.ISO-8859-1 en_GB.UTF-8
> +	   da_DK.ISO-8859-1 en_GB.UTF-8 pt_BR.UTF-8

OK. Ugly. This list should be one per line and alpha-sorted. Some other day.

>  include ../gen-locales.mk
>  
>  $(objpfx)test-strcasecmp.out: $(gen-locales)
> @@ -115,5 +117,6 @@ $(objpfx)tst-strxfrm2.out: $(gen-locales)
>  # bug-strcoll2 needs cs_CZ.UTF-8 and da_DK.ISO-8859-1.
>  $(objpfx)bug-strcoll2.out: $(gen-locales)
>  $(objpfx)tst-strcoll-overflow.out: $(gen-locales)
> +$(objpfx)tst-strsignal.out: $(gen-locales)

OK.

>  
>  endif
> diff --git a/string/tst-strsignal.c b/string/tst-strsignal.c
> new file mode 100644
> index 0000000000..93a46dbc78
> --- /dev/null
> +++ b/string/tst-strsignal.c
> @@ -0,0 +1,57 @@
> +/* Test for strsignal.

OK.

> +
> +   Copyright (C) 2020 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <string.h>
> +#include <stdio.h>
> +#include <signal.h>
> +#include <locale.h>
> +#include <array_length.h>
> +
> +#include <support/support.h>
> +#include <support/check.h>
> +

OK. Test a few operations of strsignal.

> +static int
> +do_test (void)
> +{
> +  xsetlocale (LC_ALL, "C");
> +
> +  TEST_COMPARE_STRING (strsignal (SIGINT),     "Interrupt");
> +  TEST_COMPARE_STRING (strsignal (-1),         "Unknown signal -1");
> +#ifdef SIGRTMIN
> +  TEST_COMPARE_STRING (strsignal (SIGRTMIN),   "Real-time signal 0");
> +#endif
> +#ifdef SIGRTMAX
> +  TEST_COMPARE_STRING (strsignal (SIGRTMAX+1), "Unknown signal 65");
> +#endif
> +
> +  xsetlocale (LC_ALL, "pt_BR.UTF-8");
> +
> +  TEST_COMPARE_STRING (strsignal (SIGINT),    "Interrup\xc3\xa7\xc3\xa3\x6f");
> +  TEST_COMPARE_STRING (strsignal (-1),        "Sinal desconhecido -1");
> +#ifdef SIGRTMI
          ^^^^^^^ Typo. SIGRTMIN.

> +  TEST_COMPARE_STRING (strsignal (SIGRTMIN),  "Sinal de tempo-real 0");
> +#endif
> +#ifdef SIGRTMAX
> +  TEST_COMPARE_STRING (strsignal (SIGRTMAX+1), "Sinal desconhecido 65");
> +#endif
> +
> +  return 0;
> +}
> +
> +#include <support/test-driver.c>
>
Carlos O'Donell July 2, 2020, 8:01 p.m. UTC | #2
On 6/19/20 9:43 AM, Adhemerval Zanella wrote:
> +tests-container += tst-strsignal

Did you intend to put this in tests-container?

The test does nothing particularly destructive to the environment.

It will only increase the test time by running it in a container.

Likewise for patch 10.
Adhemerval Zanella July 3, 2020, 8:06 p.m. UTC | #3
On 02/07/2020 17:01, Carlos O'Donell wrote:
> On 6/19/20 9:43 AM, Adhemerval Zanella wrote:
>> +tests-container += tst-strsignal
> 
> Did you intend to put this in tests-container?

I have added them for some reason in development, but indeed there
is no need.  I have removed it from tests-container.

> 
> The test does nothing particularly destructive to the environment.
> 
> It will only increase the test time by running it in a container.
> 
> Likewise for patch 10.
> 

I also moved it to the default tests.
diff mbox series

Patch

diff --git a/string/Makefile b/string/Makefile
index e1cca5516b..470ff77ded 100644
--- a/string/Makefile
+++ b/string/Makefile
@@ -65,6 +65,8 @@  tests		:= tester inl-tester noinl-tester testcopy test-ffs	\
 # This test allocates a lot of memory and can run for a long time.
 xtests = tst-strcoll-overflow
 
+tests-container += tst-strsignal
+
 # This test needs libdl.
 ifeq (yes,$(build-shared))
 tests += test-strerror-errno
@@ -105,7 +107,7 @@  $(objpfx)tst-svc-cmp.out: tst-svc.expect $(objpfx)tst-svc.out
 
 LOCALES := de_DE.UTF-8 en_US.ISO-8859-1 en_US.UTF-8 \
            tr_TR.ISO-8859-9 tr_TR.UTF-8 cs_CZ.UTF-8 \
-	   da_DK.ISO-8859-1 en_GB.UTF-8
+	   da_DK.ISO-8859-1 en_GB.UTF-8 pt_BR.UTF-8
 include ../gen-locales.mk
 
 $(objpfx)test-strcasecmp.out: $(gen-locales)
@@ -115,5 +117,6 @@  $(objpfx)tst-strxfrm2.out: $(gen-locales)
 # bug-strcoll2 needs cs_CZ.UTF-8 and da_DK.ISO-8859-1.
 $(objpfx)bug-strcoll2.out: $(gen-locales)
 $(objpfx)tst-strcoll-overflow.out: $(gen-locales)
+$(objpfx)tst-strsignal.out: $(gen-locales)
 
 endif
diff --git a/string/tst-strsignal.c b/string/tst-strsignal.c
new file mode 100644
index 0000000000..93a46dbc78
--- /dev/null
+++ b/string/tst-strsignal.c
@@ -0,0 +1,57 @@ 
+/* Test for strsignal.
+
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <string.h>
+#include <stdio.h>
+#include <signal.h>
+#include <locale.h>
+#include <array_length.h>
+
+#include <support/support.h>
+#include <support/check.h>
+
+static int
+do_test (void)
+{
+  xsetlocale (LC_ALL, "C");
+
+  TEST_COMPARE_STRING (strsignal (SIGINT),     "Interrupt");
+  TEST_COMPARE_STRING (strsignal (-1),         "Unknown signal -1");
+#ifdef SIGRTMIN
+  TEST_COMPARE_STRING (strsignal (SIGRTMIN),   "Real-time signal 0");
+#endif
+#ifdef SIGRTMAX
+  TEST_COMPARE_STRING (strsignal (SIGRTMAX+1), "Unknown signal 65");
+#endif
+
+  xsetlocale (LC_ALL, "pt_BR.UTF-8");
+
+  TEST_COMPARE_STRING (strsignal (SIGINT),    "Interrup\xc3\xa7\xc3\xa3\x6f");
+  TEST_COMPARE_STRING (strsignal (-1),        "Sinal desconhecido -1");
+#ifdef SIGRTMI
+  TEST_COMPARE_STRING (strsignal (SIGRTMIN),  "Sinal de tempo-real 0");
+#endif
+#ifdef SIGRTMAX
+  TEST_COMPARE_STRING (strsignal (SIGRTMAX+1), "Sinal desconhecido 65");
+#endif
+
+  return 0;
+}
+
+#include <support/test-driver.c>