I'm encountering a failure of test-getaddrinfo when running the coreutils testsuite on cygwin 1.7. Cygwin 1.7 is not a formal release yet, and cygwin 1.5 lacked getaddrinfo altogether (and I have verified that the gnulib replacement getaddrinfo works just fine in cygwin 1.5). So if I can pinpoint the failure to a cygwin bug and get it fixed before the formal release of 1.7, then gnulib does not have to worry about working around anything.
For more details, the Cygwin 1.7 addition of getaddrinfo depends on the capabilities of the underlying Windows socket library (ie. Windows Vista implements more of what POSIX requires than what Windows XP did, so cygwin has different code paths to try to make up the difference between OS versions). I'm not sure if all Windows platforms have the same behavior, but at least Windows XP coupled with cygwin's getaddrinfo wrapper is failing with EFAULT (invalid memory access). To make things easier to debug, I'd like to commit this patch. When test-getaddrinfo is compiled with ENABLE_DEBUGGING, running the test on cygwin now results in: Finding www.gnu.org service http... res 11: System error returned in errno system error: Bad address ... OK to apply this patch? From: Eric Blake <e...@byu.net> Date: Fri, 27 Mar 2009 08:16:39 -0600 Subject: [PATCH] test-strerror: make debugging EAI_SYSTEM easier * modules/getaddrinfo-tests (Depends-on): Add strerror. * testdir91336/gltests/test-getaddrinfo.c (simple) [ENABLE_DEBUGGING]: Report errno if failure was EAI_SYSTEM. Signed-off-by: Eric Blake <e...@byu.net> --- ChangeLog | 7 +++++++ modules/getaddrinfo-tests | 1 + tests/test-getaddrinfo.c | 7 +++++++ 3 files changed, 15 insertions(+), 0 deletions(-) diff --git a/ChangeLog b/ChangeLog index 47dba3d..76a8055 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-03-27 Eric Blake <e...@byu.net> + + test-strerror: make debugging EAI_SYSTEM easier + * modules/getaddrinfo-tests (Depends-on): Add strerror. + * testdir91336/gltests/test-getaddrinfo.c (simple) + [ENABLE_DEBUGGING]: Report errno if failure was EAI_SYSTEM. + 2009-03-25 Bruno Haible <br...@clisp.org> Fix a problem with --enable-relocatable on Solaris 7. diff --git a/modules/getaddrinfo-tests b/modules/getaddrinfo-tests index 5f80523..a21fe6f 100644 --- a/modules/getaddrinfo-tests +++ b/modules/getaddrinfo-tests @@ -3,6 +3,7 @@ tests/test-getaddrinfo.c Depends-on: inet_ntop +strerror configure.ac: diff --git a/tests/test-getaddrinfo.c b/tests/test-getaddrinfo.c index 5e33bb2..4816920 100644 --- a/tests/test-getaddrinfo.c +++ b/tests/test-getaddrinfo.c @@ -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; } -- 1.6.1.2