> @@ -187,9 +192,13 @@ int main (void)
>    (void) gl_sockets_startup (SOCKETS_1_1);
>  
>    return (  simple (1, HOST1, SERV1)
> +          + simple (1, HOST1, "80")
>            + simple (1, HOST2, SERV2)
> +          + simple (1, HOST2, "443")
>            + simple (1, HOST3, SERV3)
> +          + simple (1, HOST3, "80")
>            + simple (1, HOST4, SERV4)
> +          + simple (1, HOST4, "389")
>            + simple (2, HOST1, SERV1)
>            + simple (2, HOST2, SERV2)
>            + simple (2, HOST3, SERV3)
> @@ -203,5 +212,13 @@ int main (void)
>            + simple (3, HOST1, SERV1)
>            + simple (3, HOST2, SERV2)
>            + simple (3, HOST3, SERV3)
> -          + simple (3, HOST4, SERV4));
> +          + simple (3, HOST4, SERV4)
> +          + simple (4, HOST1, SERV1)
> +          + simple (4, HOST1, "80")
> +          + simple (4, HOST2, SERV2)
> +          + simple (4, HOST2, "443")
> +          + simple (4, HOST3, SERV3)
> +          + simple (4, HOST3, "80")
> +          + simple (4, HOST4, SERV4)
> +          + simple (4, HOST4, "389"));
>  }

The CI reports a failure like this:


FAIL: test-getaddrinfo
======================

FAIL test-getaddrinfo (exit status: 4)


"exit status: 4" only tells us that 4 among the added tests failed, but not
which ones. Let me add more info, for the next run.


2025-02-17  Bruno Haible  <br...@clisp.org>

        getaddrinfo tests: Make failures more verbose.
        * tests/test-getaddrinfo.c (simple): Print some info before returning 1.

diff --git a/tests/test-getaddrinfo.c b/tests/test-getaddrinfo.c
index 31e999cb0e..4485d7dd10 100644
--- a/tests/test-getaddrinfo.c
+++ b/tests/test-getaddrinfo.c
@@ -95,11 +95,19 @@ simple (int pass, char const *host, char const *service)
 
   dbgprintf ("res %d: %s\n", res, gai_strerror (res));
 
-  if (pass == 3 && ! isdigit (host[0]))
-    return res != EAI_NONAME;
-
-  if (pass == 4 && ! isdigit (service[0]))
-    return res != EAI_NONAME;
+  if ((pass == 3 && ! isdigit (host[0]))
+      || (pass == 4 && ! isdigit (service[0])))
+    {
+      if (res != EAI_NONAME)
+        {
+          fprintf (stderr,
+                   "Test case pass=%d, host=%s, service=%s failed: "
+                   "expected EAI_NONAME, got %d\n",
+                   pass, host, service, res);
+          return 1;
+        }
+      return 0;
+    }
 
   if (res != 0)
     {
@@ -130,6 +138,10 @@ simple (int pass, char const *host, char const *service)
       if (res == EAI_SYSTEM)
         fprintf (stderr, "system error: %s\n", strerror (err));
 
+      fprintf (stderr,
+               "Test case pass=%d, host=%s, service=%s failed: "
+               "expected 0, got %d\n",
+               pass, host, service, res);
       return 1;
     }
 




Reply via email to