Hello Collin,

> The test environment documentation also
> looks useful. If there is any interest in GNU Hurd or Solaris then I
> could write them once I end up needing a virtual machine for them
> again.

This is not needed, since installing GNU Hurd and Solaris (on x86_64
systems) is easy enough: qemu is not needed, and the installation
program (from Debian and Solaris, respectively) is easy enough to use.

> "Solaris 11 OmniOS" instead of "Solaris 11 OmnioOS" [1].

Fixed; thanks.

> I've changed it to this:
> 
> #include <config.h>
> 
> #include "sig2str.h"
> 
> #include <string.h>
> 
> #include "macros.h"

Yes, that's the canonical way we like to have it in Gnulib.

I've applied your patch, and a small refactoring after it.

Bruno

>From bff01a69a35d368d54165d2340be55a46233917b Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Thu, 14 Mar 2024 03:16:15 +0100
Subject: [PATCH] sig2str tests: Refactor.

* tests/test-sig2str.c (test_sig2str, test_str2sig): New functions,
extracted from main.
(main): Invoke them.
---
 ChangeLog            |  7 +++++++
 tests/test-sig2str.c | 27 ++++++++++++++++++++-------
 2 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ff539332cb..ace9a034f3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-03-13  Bruno Haible  <[email protected]>
+
+	sig2str tests: Refactor.
+	* tests/test-sig2str.c (test_sig2str, test_str2sig): New functions,
+	extracted from main.
+	(main): Invoke them.
+
 2024-03-13  Collin Funk  <[email protected]>
 
 	sig2str: Add tests.
diff --git a/tests/test-sig2str.c b/tests/test-sig2str.c
index c7b65d50b3..0c78dde00e 100644
--- a/tests/test-sig2str.c
+++ b/tests/test-sig2str.c
@@ -18,17 +18,17 @@
 
 #include <config.h>
 
+/* Specification.  */
 #include "sig2str.h"
 
 #include <string.h>
 
 #include "macros.h"
 
-int
-main (void)
+static void
+test_sig2str (void)
 {
   char buffer[SIG2STR_MAX];
-  int signo;
 
   /* Test sig2str on signals specified by ISO C.  */
 
@@ -50,6 +50,16 @@ main (void)
   ASSERT (sig2str (SIGTERM, buffer) == 0);
   ASSERT (STREQ (buffer, "TERM"));
 
+  /* Check behavior of sig2str on invalid signals.  */
+
+  ASSERT (sig2str (-714, buffer) == -1);
+}
+
+static void
+test_str2sig (void)
+{
+  int signo;
+
   /* Test str2sig on signals specified by ISO C.  */
 
   ASSERT (str2sig ("ABRT", &signo) == 0);
@@ -70,13 +80,16 @@ main (void)
   ASSERT (str2sig ("TERM", &signo) == 0);
   ASSERT (signo == SIGTERM);
 
-  /* Check behavior of sig2str on invalid signals.  */
-
-  ASSERT (sig2str (-714, buffer) == -1);
-
   /* Check behavior of str2sig on invalid signals.  */
 
   ASSERT (str2sig ("Not a signal", &signo) == -1);
+}
+
+int
+main (void)
+{
+  test_sig2str ();
+  test_str2sig ();
 
   return 0;
 }
-- 
2.34.1

Reply via email to