]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
bench-tests: work with wchar-single
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 7 May 2026 18:24:22 +0000 (11:24 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 7 May 2026 18:27:03 +0000 (11:27 -0700)
* modules/mbiter-bench-tests, modules/mbiterf-bench-tests:
* modules/mbswidth-bench-tests, modules/mbuiter-bench-tests:
* modules/mbuiterf-bench-tests, modules/mcel-bench-tests:
(Depends-on): Add streq.
* tests/bench-mbiter.c, tests/bench-mbiterf.c, tests/bench-mbswidth.c:
* tests/bench-mbuiter.c, tests/bench-mbuiterf.c, tests/bench-mcel.c:
If GNULIB_WCHAR_SINGLE_LOCALE, don’t call setlocale with different
locales.

13 files changed:
ChangeLog
modules/mbiter-bench-tests
modules/mbiterf-bench-tests
modules/mbswidth-bench-tests
modules/mbuiter-bench-tests
modules/mbuiterf-bench-tests
modules/mcel-bench-tests
tests/bench-mbiter.c
tests/bench-mbiterf.c
tests/bench-mbswidth.c
tests/bench-mbuiter.c
tests/bench-mbuiterf.c
tests/bench-mcel.c

index c2c49d0ca5b64aea064cc9c4b6c8cd9017a283b8..a3e37f6e93a91b0e4a9272d1c1aa9536f8943440 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2026-05-07  Paul Eggert  <eggert@cs.ucla.edu>
 
+       bench-tests: work with wchar-single
+       * modules/mbiter-bench-tests, modules/mbiterf-bench-tests:
+       * modules/mbswidth-bench-tests, modules/mbuiter-bench-tests:
+       * modules/mbuiterf-bench-tests, modules/mcel-bench-tests:
+       (Depends-on): Add streq.
+       * tests/bench-mbiter.c, tests/bench-mbiterf.c, tests/bench-mbswidth.c:
+       * tests/bench-mbuiter.c, tests/bench-mbuiterf.c, tests/bench-mcel.c:
+       If GNULIB_WCHAR_SINGLE_LOCALE, don’t call setlocale with different
+       locales.
+
        regex-tests: fix usage of fastmap API
        * tests/test-regex.c (main): Use documented fastmap API
        rather than relying on undocumented behavior.
index ec22673d1a0b3f222a9ec7618cfd8d4fb1fb7970..1648054e84e730cbe9441239269ea439e4958e6f 100644 (file)
@@ -7,6 +7,7 @@ Depends-on:
 mbrtoc32-regular
 mbiter
 setlocale
+streq
 striconv
 getrusage
 gettimeofday
index b4b530dc5a4f564af29a58eb0ded84e2f3b5f95a..dc837a230445da7493378ce8e9e450147d518420 100644 (file)
@@ -7,6 +7,7 @@ Depends-on:
 mbrtoc32-regular
 mbiterf
 setlocale
+streq
 striconv
 getrusage
 gettimeofday
index f8edf91dfe7c666decde6f3cbdd79a35ebcb80af..8ffc21db2eb2190b1344be1eb1dd785a99e4d2cc 100644 (file)
@@ -7,6 +7,7 @@ Depends-on:
 mbrtoc32-regular
 mbswidth
 setlocale
+streq
 striconv
 getrusage
 gettimeofday
index de98778fd6c9cbfac40b765e5f7077f4b03e2080..29b72b342e5104555206c8971f5ff32160ff9d42 100644 (file)
@@ -7,6 +7,7 @@ Depends-on:
 mbrtoc32-regular
 mbuiter
 setlocale
+streq
 striconv
 getrusage
 gettimeofday
index cf806ecc49fd3c614308fc5be4fc24a187215f82..c9551bff883f01cfb2334f68a9c684afbb2db9fb 100644 (file)
@@ -7,6 +7,7 @@ Depends-on:
 mbrtoc32-regular
 mbuiterf
 setlocale
+streq
 striconv
 getrusage
 gettimeofday
index 0c54aad819e861e63ae481372c9ca805cc177c18..1599505fdd3cc49c61b150145f21044abb5f0e9a 100644 (file)
@@ -11,6 +11,7 @@ mbuiter
 mbuiterf
 mcel
 setlocale
+streq
 striconv
 getrusage
 gettimeofday
index b7bea5480546a93351605dcd8f2202115118a38c..3593c164e69c437d49d11b304521afbd5039530e 100644 (file)
 
 unsigned long long volatile result;
 
+#ifndef GNULIB_WCHAR_SINGLE_LOCALE
+# define GNULIB_WCHAR_SINGLE_LOCALE 0
+#endif
+
 static void
 do_test (char test, int repeat, const char *locale_name, const char *text)
 {
   printf ("Test %c\n", test);
-  if (setlocale (LC_ALL, locale_name) != NULL)
+
+  static char const *current_locale_name;
+  if (GNULIB_WCHAR_SINGLE_LOCALE && current_locale_name
+      && !streq (locale_name, current_locale_name))
+    printf ("Skipping test: earlier locale %s != test locale %s\n",
+            current_locale_name, locale_name);
+  else if (!setlocale (LC_ALL, locale_name))
+    printf ("Skipping test: locale %s not installed.\n", locale_name);
+  else
     {
+      current_locale_name = locale_name;
+
       struct timings_state ts;
       timing_start (&ts);
 
@@ -51,10 +65,6 @@ do_test (char test, int repeat, const char *locale_name, const char *text)
       timing_end (&ts);
       timing_output (&ts);
     }
-  else
-    {
-      printf ("Skipping test: locale %s not installed.\n", locale_name);
-    }
   printf ("\n");
 }
 
index 505e5fbc6a4b1c1cd593909d970ffc1b48e29e73..57564f526554cce94122f1bd7d3083f8c4982722 100644 (file)
 
 unsigned long long volatile result;
 
+#ifndef GNULIB_WCHAR_SINGLE_LOCALE
+# define GNULIB_WCHAR_SINGLE_LOCALE 0
+#endif
+
 static void
 do_test (char test, int repeat, const char *locale_name, const char *text)
 {
   printf ("Test %c\n", test);
-  if (setlocale (LC_ALL, locale_name) != NULL)
+
+  static char const *current_locale_name;
+  if (GNULIB_WCHAR_SINGLE_LOCALE && current_locale_name
+      && !streq (locale_name, current_locale_name))
+    printf ("Skipping test: earlier locale %s != test locale %s\n",
+            current_locale_name, locale_name);
+  else if (!setlocale (LC_ALL, locale_name))
+    printf ("Skipping test: locale %s not installed.\n", locale_name);
+  else
     {
+      current_locale_name = locale_name;
+
       struct timings_state ts;
       timing_start (&ts);
 
@@ -55,10 +69,6 @@ do_test (char test, int repeat, const char *locale_name, const char *text)
       timing_end (&ts);
       timing_output (&ts);
     }
-  else
-    {
-      printf ("Skipping test: locale %s not installed.\n", locale_name);
-    }
   printf ("\n");
 }
 
index 4facad04fc9104aca70713aca2300e036a4d3722..bad0adcf5c4801ca64522b4d7b5b10e94ec8058c 100644 (file)
 #include "bench-multibyte.h"
 #include "mbswidth.h"
 
+#ifndef GNULIB_WCHAR_SINGLE_LOCALE
+# define GNULIB_WCHAR_SINGLE_LOCALE 0
+#endif
+
 static void
 do_test (char test, int repeat, const char *locale_name, const char *text)
 {
   printf ("Test %c\n", test);
-  if (setlocale (LC_ALL, locale_name) != NULL)
+
+  static char const *current_locale_name;
+  if (GNULIB_WCHAR_SINGLE_LOCALE && current_locale_name
+      && !streq (locale_name, current_locale_name))
+    printf ("Skipping test: earlier locale %s != test locale %s\n",
+            current_locale_name, locale_name);
+  else if (!setlocale (LC_ALL, locale_name))
+    printf ("Skipping test: locale %s not installed.\n", locale_name);
+  else
     {
+      current_locale_name = locale_name;
+
       struct timings_state ts;
       timing_start (&ts);
 
@@ -42,10 +56,6 @@ do_test (char test, int repeat, const char *locale_name, const char *text)
       timing_end (&ts);
       timing_output (&ts);
     }
-  else
-    {
-      printf ("Skipping test: locale %s not installed.\n", locale_name);
-    }
   printf ("\n");
 }
 
index 2fda0506c96de819bc0ec81afa308d86bc6153f0..b1e4eccc6f58cada05d1f8499c590e75c575c34d 100644 (file)
 
 unsigned long long volatile result;
 
+#ifndef GNULIB_WCHAR_SINGLE_LOCALE
+# define GNULIB_WCHAR_SINGLE_LOCALE 0
+#endif
+
 static void
 do_test (char test, int repeat, const char *locale_name, const char *text)
 {
   printf ("Test %c\n", test);
-  if (setlocale (LC_ALL, locale_name) != NULL)
+
+  static char const *current_locale_name;
+  if (GNULIB_WCHAR_SINGLE_LOCALE && current_locale_name
+      && !streq (locale_name, current_locale_name))
+    printf ("Skipping test: earlier locale %s != test locale %s\n",
+            current_locale_name, locale_name);
+  else if (!setlocale (LC_ALL, locale_name))
+    printf ("Skipping test: locale %s not installed.\n", locale_name);
+  else
     {
+      current_locale_name = locale_name;
+
       struct timings_state ts;
       timing_start (&ts);
 
@@ -50,10 +64,6 @@ do_test (char test, int repeat, const char *locale_name, const char *text)
       timing_end (&ts);
       timing_output (&ts);
     }
-  else
-    {
-      printf ("Skipping test: locale %s not installed.\n", locale_name);
-    }
   printf ("\n");
 }
 
index 5f51c9b01aaafcc654edef69f01785f2d1be5eb9..92c3174599168fe33352c1bd2fbe849da0a1bff7 100644 (file)
 
 unsigned long long volatile result;
 
+#ifndef GNULIB_WCHAR_SINGLE_LOCALE
+# define GNULIB_WCHAR_SINGLE_LOCALE 0
+#endif
+
 static void
 do_test (char test, int repeat, const char *locale_name, const char *text)
 {
   printf ("Test %c\n", test);
-  if (setlocale (LC_ALL, locale_name) != NULL)
+
+  static char const *current_locale_name;
+  if (GNULIB_WCHAR_SINGLE_LOCALE && current_locale_name
+      && !streq (locale_name, current_locale_name))
+    printf ("Skipping test: earlier locale %s != test locale %s\n",
+            current_locale_name, locale_name);
+  else if (!setlocale (LC_ALL, locale_name))
+    printf ("Skipping test: locale %s not installed.\n", locale_name);
+  else
     {
+      current_locale_name = locale_name;
+
       struct timings_state ts;
       timing_start (&ts);
 
@@ -53,10 +67,6 @@ do_test (char test, int repeat, const char *locale_name, const char *text)
       timing_end (&ts);
       timing_output (&ts);
     }
-  else
-    {
-      printf ("Skipping test: locale %s not installed.\n", locale_name);
-    }
   printf ("\n");
 }
 
index d8f91a4b160ffce532a9fb20adfc15298999c1ff..f100a366c1c5f10515c90c3334a5e656e094f2a9 100644 (file)
@@ -191,12 +191,25 @@ do_1_test (test_function test, char const *text,
   return sum;
 }
 
+#ifndef GNULIB_WCHAR_SINGLE_LOCALE
+# define GNULIB_WCHAR_SINGLE_LOCALE 0
+#endif
+
 static void
 do_test (char test, int repeat, char const *locale_name,
          char const *text, size_t text_len)
 {
-  if (setlocale (LC_ALL, locale_name) != NULL)
+  static char const *current_locale_name;
+  if (GNULIB_WCHAR_SINGLE_LOCALE && current_locale_name
+      && !streq (locale_name, current_locale_name))
+    printf ("Skipping test: earlier locale %s != test locale %s\n",
+            current_locale_name, locale_name);
+  else if (!setlocale (LC_ALL, locale_name))
+    printf ("Skipping test: locale %s not installed.\n", locale_name);
+  else
     {
+      current_locale_name = locale_name;
+
       char const *text_end = text + text_len;
 
       static struct
@@ -220,8 +233,6 @@ do_test (char test, int repeat, char const *locale_name,
         testdesc[i].sum =
           do_1_test (testdesc[i].fn, text, text_end, repeat, &testdesc[i].ts);
 
-      setlocale (LC_ALL, "C");
-
       static bool header_printed;
       if (!header_printed)
         {
@@ -241,10 +252,6 @@ do_test (char test, int repeat, char const *locale_name,
         }
       printf ("\n");
     }
-  else
-    {
-      printf ("Skipping test: locale %s not installed.\n", locale_name);
-    }
 }
 
 /* Performs some or all of the following tests: