From 1ba05158ebe033d7d0bdfcfef686eae2c9ea0103 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ludovic=20Court=C3=A8s?= Date: Fri, 3 Feb 2012 10:30:52 +0100 Subject: [PATCH] tests: Have `getaddrinfo' test work for Darwin 8. * doc/ref/posix.texi (Network Databases): Update description of `EAI_NODATA' to mention that Darwin provides it. * libguile/net_db.c (scm_getaddrinfo): Likewise. * test-suite/tests/net-db.test ("getaddrinfo")["wrong service name"]: Accept `EAI_NODATA' too. Reported by David Fang , see . --- doc/ref/posix.texi | 10 +++++----- libguile/net_db.c | 15 ++++++++++----- test-suite/tests/net-db.test | 10 +++++++--- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/doc/ref/posix.texi b/doc/ref/posix.texi index 0defc3f23..993349583 100644 --- a/doc/ref/posix.texi +++ b/doc/ref/posix.texi @@ -1,7 +1,7 @@ @c -*-texinfo-*- @c This is part of the GNU Guile Reference Manual. -@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 -@c Free Software Foundation, Inc. +@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2006, 2007, +@c 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. @c See the file guile.texi for copying conditions. @node POSIX @@ -2502,9 +2502,9 @@ Either @var{name} does not resolve for the supplied parameters, or neither @var{name} nor @var{service} were supplied. @item EAI_NODATA -This non-POSIX error code can be returned on GNU systems when a -request was actually made but returned no data, meaning -that no address is associated with @var{name}. Error handling +This non-POSIX error code can be returned on some systems (GNU +and Darwin, at least), for example when @var{name} is known +but requests that were made turned out no data. Error handling code should be prepared to handle it when it is defined. @item EAI_SERVICE diff --git a/libguile/net_db.c b/libguile/net_db.c index 61dd2f386..4d63aabcc 100644 --- a/libguile/net_db.c +++ b/libguile/net_db.c @@ -1,6 +1,7 @@ /* "net_db.c" network database support - * Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. - * + * Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2006, 2009, + * 2010, 2011, 2012 Free Software Foundation, Inc. + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 3 of @@ -590,10 +591,14 @@ SCM_DEFINE (scm_getaddrinfo, "getaddrinfo", 1, 5, 0, "@item EAI_NONAME\n" "Either @var{name} does not resolve for the supplied parameters, " "or neither @var{name} nor @var{service} were supplied.\n\n" + + /* See `sysdeps/posix/getaddrinfo.c' in the GNU libc, and + , + for details on EAI_NODATA. */ "@item EAI_NODATA\n" - "This non-POSIX error code can be returned on GNU systems when a\n" - "request was actually made but returned no data, meaning\n" - "that no address is associated with @var{name}. Error handling\n" + "This non-POSIX error code can be returned on some systems (GNU " + "and Darwin, at least), for example when @var{name} is known " + "but requests that were made turned out no data. Error handling\n" "code should be prepared to handle it when it is defined.\n\n" "@item EAI_SERVICE\n" "@var{service} was not recognized for the specified socket type.\n\n" diff --git a/test-suite/tests/net-db.test b/test-suite/tests/net-db.test index 89ebb1b1c..edd87cef8 100644 --- a/test-suite/tests/net-db.test +++ b/test-suite/tests/net-db.test @@ -1,7 +1,7 @@ ;;;; net-db.test --- Test suite for `net-db' -*- mode: scheme; coding: utf-8; -*- ;;;; Ludovic Courtès ;;;; -;;;; Copyright (C) 2010, 2011 Free Software Foundation, Inc. +;;;; Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc. ;;;; ;;;; This library is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU Lesser General Public @@ -100,7 +100,11 @@ #f)) (lambda (key errcode) ;; According to POSIX, both error codes are valid (glibc 2.11 - ;; chooses `EAI_SERVICE'; Darwin chooses `EAI_NONAME'.) + ;; chooses `EAI_SERVICE'; Darwin 8.11.0 chooses the non-POSIX + ;; `EAI_NODATA', and more recent Darwin versions choose + ;; `EAI_NONAME'.) (and (or (= errcode EAI_SERVICE) - (= errcode EAI_NONAME)) + (= errcode EAI_NONAME) + (and (defined? 'EAI_NODATA) + (= errcode EAI_NODATA))) (string? (gai-strerror errcode)))))))) -- 2.20.1