Paul Eggert wrote:
> +     (test_function): Test for the bug, if RUN_EXPENSIVE_TESTS=yes
> +     in the environment; this the coreutils tradition and I
> +     didn’t see any Gnulib tradition so I just used it.

The Gnulib tradition for expensive tests is to create a separate
tests module marked as 'longrunning-test'. So that at gnulib-tool
invocation time, one can decide whether to include such longrunning
tests (by passing the option '--with-longrunning-tests').

The coreutils tradition is not bad. But in Gnulib we don't need two
different ways for doing the same thing. I'm therefore converting
your test cases to the Gnulib tradition.


2026-07-13  Bruno Haible  <[email protected]>

        vaszprintf-extra-tests: New module.
        * tests/test-vaszprintf-big.c: New file, extracted from
        tests/test-vaszprintf-posix.c.
        * tests/test-vaszprintf-posix.c (test_function): Revert last change.
        * modules/vaszprintf-extra-tests: New file.
        * modules/vaszprintf-tests: New file.

        vasprintf-extra-tests: New module.
        * tests/test-vasprintf-big.c: New file, extracted from
        tests/test-vasprintf-posix.c.
        * tests/test-vasprintf-posix.c (test_function): Revert last change.
        * modules/vasprintf-extra-tests: New file.
        * modules/vasprintf-tests (Depends-on): Add vasprintf-extra-tests.

        vasnprintf-extra-tests: Move new expensive test to here.
        * tests/test-vasnprintf-big.c (main): Move INT_MAX test case to here.
        * tests/test-vasnprintf-posix.c (test_function): Revert last change.

>From 514a21675ce28d401711cb2df6b4243f618bd8f8 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Mon, 13 Jul 2026 22:27:16 +0200
Subject: [PATCH 1/3] vasnprintf-extra-tests: Move new expensive test to here.

* tests/test-vasnprintf-big.c (main): Move INT_MAX test case to here.
* tests/test-vasnprintf-posix.c (test_function): Revert last change.
---
 ChangeLog                     |  6 ++++++
 tests/test-vasnprintf-big.c   | 19 +++++++++++++++++++
 tests/test-vasnprintf-posix.c | 20 --------------------
 3 files changed, 25 insertions(+), 20 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c4843bea64..b476f126fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2026-07-13  Bruno Haible  <[email protected]>
+
+	vasnprintf-extra-tests: Move new expensive test to here.
+	* tests/test-vasnprintf-big.c (main): Move INT_MAX test case to here.
+	* tests/test-vasnprintf-posix.c (test_function): Revert last change.
+
 2026-07-13  Bruno Haible  <[email protected]>
 
 	vasnprintf: Fix compilation error on FreeBSD, OpenBSD (regr. today).
diff --git a/tests/test-vasnprintf-big.c b/tests/test-vasnprintf-big.c
index fc11a6e775..a9969e18c7 100644
--- a/tests/test-vasnprintf-big.c
+++ b/tests/test-vasnprintf-big.c
@@ -44,6 +44,25 @@
 int
 main ()
 {
+  /* Large width given as argument.  */
+  {
+    size_t length;
+    char *result =
+      asnprintf (NULL, &length, "%*d", INT_MAX, INT_MIN);
+    if (!result)
+      ASSERT (errno == ENOMEM);
+    else
+      {
+        ASSERT (atoi (result) == INT_MIN);
+        ASSERT (length == INT_MAX);
+        ASSERT (length == strlen (result));
+        free (result);
+      }
+  }
+
+  if (test_exit_status != EXIT_SUCCESS)
+    return test_exit_status;
+
 #if PTRDIFF_MAX == INT_MAX
   fputs ("Skipping test: ptrdiff_t is not 64-bits wide\n", stderr);
   return 77;
diff --git a/tests/test-vasnprintf-posix.c b/tests/test-vasnprintf-posix.c
index 98e3319920..fe0a59d647 100644
--- a/tests/test-vasnprintf-posix.c
+++ b/tests/test-vasnprintf-posix.c
@@ -22,7 +22,6 @@
 
 #include <errno.h>
 #include <float.h>
-#include <limits.h>
 #include <stdarg.h>
 #include <stdcountof.h>
 #include <stddef.h>
@@ -168,25 +167,6 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
     free (result);
   }
 
-  {
-    char *expensive = getenv ("RUN_EXPENSIVE_TESTS");
-    if (expensive && streq (expensive, "yes"))
-      { /* Large width given as argument.  */
-        size_t length;
-        char *result =
-          my_asnprintf (NULL, &length, "%*d", INT_MAX, INT_MIN);
-        if (!result)
-          ASSERT (errno == ENOMEM);
-        else
-          {
-            ASSERT (atoi (result) == INT_MIN);
-            ASSERT (length == INT_MAX);
-            ASSERT (length == strlen (result));
-            free (result);
-          }
-      }
-  }
-
   /* Test the support of the 'a' and 'A' conversion specifier for hexadecimal
      output of floating-point numbers.  */
 
-- 
2.53.0

>From 2215652faab1ed0932ac6c4d7d52b19094a3b4f8 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Mon, 13 Jul 2026 22:50:31 +0200
Subject: [PATCH 2/3] vasprintf-extra-tests: New module.

* tests/test-vasprintf-big.c: New file, extracted from
tests/test-vasprintf-posix.c.
* tests/test-vasprintf-posix.c (test_function): Revert last change.
* modules/vasprintf-extra-tests: New file.
* modules/vasprintf-tests (Depends-on): Add vasprintf-extra-tests.
---
 ChangeLog                     |  7 +++++
 modules/vasprintf-extra-tests | 14 ++++++++++
 modules/vasprintf-tests       |  1 +
 tests/test-vasprintf-big.c    | 50 +++++++++++++++++++++++++++++++++++
 tests/test-vasprintf-posix.c  | 21 ---------------
 5 files changed, 72 insertions(+), 21 deletions(-)
 create mode 100644 modules/vasprintf-extra-tests
 create mode 100644 tests/test-vasprintf-big.c

diff --git a/ChangeLog b/ChangeLog
index b476f126fa..f13318e5f3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2026-07-13  Bruno Haible  <[email protected]>
 
+	vasprintf-extra-tests: New module.
+	* tests/test-vasprintf-big.c: New file, extracted from
+	tests/test-vasprintf-posix.c.
+	* tests/test-vasprintf-posix.c (test_function): Revert last change.
+	* modules/vasprintf-extra-tests: New file.
+	* modules/vasprintf-tests (Depends-on): Add vasprintf-extra-tests.
+
 	vasnprintf-extra-tests: Move new expensive test to here.
 	* tests/test-vasnprintf-big.c (main): Move INT_MAX test case to here.
 	* tests/test-vasnprintf-posix.c (test_function): Revert last change.
diff --git a/modules/vasprintf-extra-tests b/modules/vasprintf-extra-tests
new file mode 100644
index 0000000000..5a99516681
--- /dev/null
+++ b/modules/vasprintf-extra-tests
@@ -0,0 +1,14 @@
+Status:
+longrunning-test
+
+Files:
+tests/test-vasprintf-big.c
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-vasprintf-big
+check_PROGRAMS += test-vasprintf-big
diff --git a/modules/vasprintf-tests b/modules/vasprintf-tests
index d452d66429..bca08bfe02 100644
--- a/modules/vasprintf-tests
+++ b/modules/vasprintf-tests
@@ -4,6 +4,7 @@ tests/signature.h
 tests/macros.h
 
 Depends-on:
+vasprintf-extra-tests
 streq
 
 configure.ac:
diff --git a/tests/test-vasprintf-big.c b/tests/test-vasprintf-big.c
new file mode 100644
index 0000000000..81d8a56539
--- /dev/null
+++ b/tests/test-vasprintf-big.c
@@ -0,0 +1,50 @@
+/* Test of [v]asprintf() with big results.
+   Copyright (C) 2026 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program 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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include <stdio.h>
+
+/* Get INT_MAX.  */
+#include <limits.h>
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "macros.h"
+
+int
+main ()
+{
+  /* Large width given as argument.  */
+  {
+    char *result;
+    int retval =
+      asprintf (&result, "%*d", INT_MAX, INT_MIN);
+    if (retval < 0)
+      ASSERT (errno == ENOMEM);
+    else
+      {
+        ASSERT (atoi (result) == INT_MIN);
+        ASSERT (retval == INT_MAX);
+        ASSERT (retval == strlen (result));
+        free (result);
+      }
+  }
+
+  return test_exit_status;
+}
diff --git a/tests/test-vasprintf-posix.c b/tests/test-vasprintf-posix.c
index 86ae5c12a7..6d62468cce 100644
--- a/tests/test-vasprintf-posix.c
+++ b/tests/test-vasprintf-posix.c
@@ -20,9 +20,7 @@
 
 #include <stdio.h>
 
-#include <errno.h>
 #include <float.h>
-#include <limits.h>
 #include <stdarg.h>
 #include <stdcountof.h>
 #include <stddef.h>
@@ -148,25 +146,6 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
     free (result);
   }
 
-  {
-    char *expensive = getenv ("RUN_EXPENSIVE_TESTS");
-    if (expensive && streq (expensive, "yes"))
-      { /* Large width given as argument.  */
-        char *result;
-        int retval =
-          my_asprintf (&result, "%*d", INT_MAX, INT_MIN);
-        if (retval < 0)
-          ASSERT (errno == ENOMEM);
-        else
-          {
-            ASSERT (atoi (result) == INT_MIN);
-            ASSERT (retval == INT_MAX);
-            ASSERT (retval == strlen (result));
-            free (result);
-          }
-      }
-  }
-
   /* Test the support of the 'a' and 'A' conversion specifier for hexadecimal
      output of floating-point numbers.  */
 
-- 
2.53.0

>From 2d74c2f3a16cd8c3e00675d7e226e245e743e1c4 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Mon, 13 Jul 2026 23:06:33 +0200
Subject: [PATCH 3/3] vaszprintf-extra-tests: New module.

* tests/test-vaszprintf-big.c: New file, extracted from
tests/test-vaszprintf-posix.c.
* tests/test-vaszprintf-posix.c (test_function): Revert last change.
* modules/vaszprintf-extra-tests: New file.
* modules/vaszprintf-tests: New file.
---
 ChangeLog                      |  7 +++++
 modules/vaszprintf-extra-tests | 14 ++++++++++
 modules/vaszprintf-tests       |  8 ++++++
 tests/test-vaszprintf-big.c    | 51 ++++++++++++++++++++++++++++++++++
 tests/test-vaszprintf-posix.c  | 22 ---------------
 5 files changed, 80 insertions(+), 22 deletions(-)
 create mode 100644 modules/vaszprintf-extra-tests
 create mode 100644 modules/vaszprintf-tests
 create mode 100644 tests/test-vaszprintf-big.c

diff --git a/ChangeLog b/ChangeLog
index f13318e5f3..b9dffc6ac2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2026-07-13  Bruno Haible  <[email protected]>
 
+	vaszprintf-extra-tests: New module.
+	* tests/test-vaszprintf-big.c: New file, extracted from
+	tests/test-vaszprintf-posix.c.
+	* tests/test-vaszprintf-posix.c (test_function): Revert last change.
+	* modules/vaszprintf-extra-tests: New file.
+	* modules/vaszprintf-tests: New file.
+
 	vasprintf-extra-tests: New module.
 	* tests/test-vasprintf-big.c: New file, extracted from
 	tests/test-vasprintf-posix.c.
diff --git a/modules/vaszprintf-extra-tests b/modules/vaszprintf-extra-tests
new file mode 100644
index 0000000000..b0d0faa542
--- /dev/null
+++ b/modules/vaszprintf-extra-tests
@@ -0,0 +1,14 @@
+Status:
+longrunning-test
+
+Files:
+tests/test-vaszprintf-big.c
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-vaszprintf-big
+check_PROGRAMS += test-vaszprintf-big
diff --git a/modules/vaszprintf-tests b/modules/vaszprintf-tests
new file mode 100644
index 0000000000..0b50473872
--- /dev/null
+++ b/modules/vaszprintf-tests
@@ -0,0 +1,8 @@
+Files:
+
+Depends-on:
+vaszprintf-extra-tests
+
+configure.ac:
+
+Makefile.am:
diff --git a/tests/test-vaszprintf-big.c b/tests/test-vaszprintf-big.c
new file mode 100644
index 0000000000..1c5cb3d1f6
--- /dev/null
+++ b/tests/test-vaszprintf-big.c
@@ -0,0 +1,51 @@
+/* Test of [v]aszprintf() with big results.
+   Copyright (C) 2026 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program 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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include <stdio.h>
+
+/* Get INT_MAX.  */
+#include <limits.h>
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "macros.h"
+
+int
+main ()
+{
+  /* Large width given as argument.  */
+  {
+    char *result;
+    ptrdiff_t retval =
+      aszprintf (&result, "%.*d %d", INT_MAX, 1234567, 99);
+    if (retval < 0)
+      ASSERT (errno == ENOMEM);
+    else
+      {
+        for (int i = 0; i < INT_MAX - 7; i++)
+          ASSERT (result[i] == '0');
+        ASSERT (streq (result + INT_MAX - 7, "1234567 99"));
+        ASSERT (retval == strlen (result));
+        free (result);
+      }
+  }
+
+  return test_exit_status;
+}
diff --git a/tests/test-vaszprintf-posix.c b/tests/test-vaszprintf-posix.c
index 319480371d..a5b8be275c 100644
--- a/tests/test-vaszprintf-posix.c
+++ b/tests/test-vaszprintf-posix.c
@@ -24,8 +24,6 @@
 
 #include <stdio.h>
 
-#include <errno.h>
-#include <limits.h>
 #include <stdarg.h>
 #include <stddef.h>
 #include <stdlib.h>
@@ -215,26 +213,6 @@ test_function (ptrdiff_t (*my_aszprintf) (char **, const char *, ...))
     free (result);
   }
 
-  {
-    char *expensive = getenv ("RUN_EXPENSIVE_TESTS");
-    if (expensive && streq (expensive, "yes"))
-      { /* Large width given as argument.  */
-        char *result;
-        ptrdiff_t retval =
-          my_aszprintf (&result, "%.*d %d", INT_MAX, 1234567, 99);
-        if (retval < 0)
-          ASSERT (errno == ENOMEM);
-        else
-          {
-            for (int i = 0; i < INT_MAX - 7; i++)
-              ASSERT (result[i] == '0');
-            ASSERT (streq (result + INT_MAX - 7, "1234567 99"));
-            ASSERT (retval == strlen (result));
-            free (result);
-          }
-      }
-  }
-
   /* Test the support of the 'b' conversion specifier for binary output of
      integers.  */
 
-- 
2.53.0

Reply via email to