Avoid test segfault on x86_64 due to lack of inet_ntop declaration.
[pspp] / tests / test-getaddrinfo.c
index 06245164f0888ec76a599248f406ae059977fbaf..8d487cb5bf48c90492710bee2c7ef01e4a2d9511 100644 (file)
@@ -1,6 +1,6 @@
 /* Test the getaddrinfo module.
 
-   Copyright (C) 2006-2007 Free Software Foundation, Inc.
+   Copyright (C) 2006-2008 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -17,9 +17,9 @@
 
 /* Written by Simon Josefsson.  */
 
-#include "config.h"
+#include <config.h>
 #include "getaddrinfo.h"
-#include "inet_ntop.h"
+#include <arpa/inet.h>
 #include <stdio.h>
 #include <string.h>
 
 # define AF_UNSPEC 0
 #endif
 
+#ifndef EAI_SERVICE
+# define EAI_SERVICE 0
+#endif
+
 int simple (char *host, char *service)
 {
   char buf[BUFSIZ];
@@ -49,7 +53,22 @@ int simple (char *host, char *service)
   printf ("res %d: %s\n", res, gai_strerror (res));
 
   if (res != 0)
-    return 1;
+    {
+      /* IRIX reports EAI_NONAME for "https".  Don't fail the test
+        merely because of this.  */
+      if (res == EAI_NONAME)
+       return 0;
+      /* Solaris reports EAI_SERVICE for "http" and "https".  Don't
+         fail the test merely because of this.  */
+      if (res == EAI_SERVICE)
+       return 0;
+      /* AIX reports EAI_NODATA for "https".  Don't fail the test
+        merely because of this.  */
+      if (res == EAI_NODATA)
+       return 0;
+
+      return 1;
+    }
 
   for (ai = ai0; ai; ai = ai->ai_next)
     {
@@ -89,15 +108,12 @@ int simple (char *host, char *service)
   return 0;
 }
 
-/* Use numbers for http and https services, rather than names, because
-   Solaris 8 /etc/services does not define these service names by
-   default.  */
 #define HOST1 "www.gnu.org"
-#define SERV1 "80"
+#define SERV1 "http"
 #define HOST2 "www.ibm.com"
-#define SERV2 "443"
+#define SERV2 "https"
 #define HOST3 "microsoft.com"
-#define SERV3 "80"
+#define SERV3 "http"
 #define HOST4 "google.org"
 #define SERV4 "ldap"