1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-01 04:10:18 +02:00

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 <fang@csl.cornell.edu>,
  see <http://bugs.gnu.org/10684>.
This commit is contained in:
Ludovic Courtès 2012-02-03 10:30:52 +01:00
parent 6f63f118ef
commit 1ba05158eb
3 changed files with 22 additions and 13 deletions

View file

@ -1,7 +1,7 @@
@c -*-texinfo-*- @c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual. @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 Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2006, 2007,
@c Free Software Foundation, Inc. @c 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions. @c See the file guile.texi for copying conditions.
@node POSIX @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. or neither @var{name} nor @var{service} were supplied.
@item EAI_NODATA @item EAI_NODATA
This non-POSIX error code can be returned on GNU systems when a This non-POSIX error code can be returned on some systems (GNU
request was actually made but returned no data, meaning and Darwin, at least), for example when @var{name} is known
that no address is associated with @var{name}. Error handling but requests that were made turned out no data. Error handling
code should be prepared to handle it when it is defined. code should be prepared to handle it when it is defined.
@item EAI_SERVICE @item EAI_SERVICE

View file

@ -1,5 +1,6 @@
/* "net_db.c" network database support /* "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 * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
@ -590,10 +591,14 @@ SCM_DEFINE (scm_getaddrinfo, "getaddrinfo", 1, 5, 0,
"@item EAI_NONAME\n" "@item EAI_NONAME\n"
"Either @var{name} does not resolve for the supplied parameters, " "Either @var{name} does not resolve for the supplied parameters, "
"or neither @var{name} nor @var{service} were supplied.\n\n" "or neither @var{name} nor @var{service} were supplied.\n\n"
/* See `sysdeps/posix/getaddrinfo.c' in the GNU libc, and
<http://www.opensource.apple.com/source/Libinfo/Libinfo-324.1/lookup.subproj/netdb.h>,
for details on EAI_NODATA. */
"@item EAI_NODATA\n" "@item EAI_NODATA\n"
"This non-POSIX error code can be returned on GNU systems when a\n" "This non-POSIX error code can be returned on some systems (GNU "
"request was actually made but returned no data, meaning\n" "and Darwin, at least), for example when @var{name} is known "
"that no address is associated with @var{name}. Error handling\n" "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" "code should be prepared to handle it when it is defined.\n\n"
"@item EAI_SERVICE\n" "@item EAI_SERVICE\n"
"@var{service} was not recognized for the specified socket type.\n\n" "@var{service} was not recognized for the specified socket type.\n\n"

View file

@ -1,7 +1,7 @@
;;;; net-db.test --- Test suite for `net-db' -*- mode: scheme; coding: utf-8; -*- ;;;; net-db.test --- Test suite for `net-db' -*- mode: scheme; coding: utf-8; -*-
;;;; Ludovic Courtès <ludo@gnu.org> ;;;; Ludovic Courtès <ludo@gnu.org>
;;;; ;;;;
;;;; 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 ;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public ;;;; modify it under the terms of the GNU Lesser General Public
@ -100,7 +100,11 @@
#f)) #f))
(lambda (key errcode) (lambda (key errcode)
;; According to POSIX, both error codes are valid (glibc 2.11 ;; 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) (and (or (= errcode EAI_SERVICE)
(= errcode EAI_NONAME)) (= errcode EAI_NONAME)
(and (defined? 'EAI_NODATA)
(= errcode EAI_NODATA)))
(string? (gai-strerror errcode)))))))) (string? (gai-strerror errcode))))))))