test-strerror: make debugging EAI_SYSTEM easier
authorEric Blake <ebb9@byu.net>
Fri, 27 Mar 2009 14:16:39 +0000 (08:16 -0600)
committerEric Blake <ebb9@byu.net>
Fri, 27 Mar 2009 19:03:06 +0000 (13:03 -0600)
* modules/getaddrinfo-tests (Depends-on): Add strerror.
* test-getaddrinfo.c (simple) [ENABLE_DEBUGGING]: Report errno if
failure was EAI_SYSTEM.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
modules/getaddrinfo-tests
tests/test-getaddrinfo.c

index 47dba3d884e15a31c63c079fde1f4e35656d0f9d..ccc0e4ec64373743b590bc44e984b3b32b7ef6b5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-03-27  Eric Blake  <ebb9@byu.net>
+
+       test-strerror: make debugging EAI_SYSTEM easier
+       * modules/getaddrinfo-tests (Depends-on): Add strerror.
+       * test-getaddrinfo.c (simple) [ENABLE_DEBUGGING]: Report errno if
+       failure was EAI_SYSTEM.
+
 2009-03-25  Bruno Haible  <bruno@clisp.org>
 
        Fix a problem with --enable-relocatable on Solaris 7.
index 5f80523b6883af30fb0de008dde4303c813529f7..a21fe6fa0f5296477e0bbe6b8ff3bc13e48c38b1 100644 (file)
@@ -3,6 +3,7 @@ tests/test-getaddrinfo.c
 
 Depends-on:
 inet_ntop
+strerror
 
 configure.ac:
 
index 5e33bb24f18260be25736c15bcf034e14e8ccb49..4816920a95ec3d6ed340b6c250e85b56e9ee8f5e 100644 (file)
@@ -19,7 +19,9 @@
 
 #include <config.h>
 #include <netdb.h>
+
 #include <arpa/inet.h>
+#include <errno.h>
 #include <netinet/in.h>
 #include <stdio.h>
 #include <string.h>
@@ -49,6 +51,7 @@ int simple (char *host, char *service)
   struct addrinfo hints;
   struct addrinfo *ai0, *ai;
   int res;
+  int err;
 
   /* Once we skipped the test, do not try anything else */
   if (skip)
@@ -64,6 +67,7 @@ int simple (char *host, char *service)
   hints.ai_socktype = SOCK_STREAM;
 
   res = getaddrinfo (host, service, 0, &ai0);
+  err = errno;
 
   dbgprintf ("res %d: %s\n", res, gai_strerror (res));
 
@@ -90,6 +94,9 @@ int simple (char *host, char *service)
         merely because of this.  */
       if (res == EAI_NODATA)
        return 0;
+      /* Provide details if errno was set.  */
+      if (res == EAI_SYSTEM)
+         dbgprintf ("system error: %s\n", strerror (err));
 
       return 1;
     }