summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--macros/neon-test.m42
-rw-r--r--test/socket.c16
2 files changed, 15 insertions, 3 deletions
diff --git a/macros/neon-test.m4 b/macros/neon-test.m4
index 8957a6f..c4e3095 100644
--- a/macros/neon-test.m4
+++ b/macros/neon-test.m4
@@ -39,7 +39,7 @@ AC_BEFORE([$0], [NEON_XML_PARSER])
AC_CHECK_HEADERS(sys/time.h stdint.h locale.h)
-AC_CHECK_FUNCS(pipe isatty usleep shutdown setlocale)
+AC_CHECK_FUNCS(pipe isatty usleep shutdown setlocale gethostname)
AC_REQUIRE([NE_FIND_AR])
diff --git a/test/socket.c b/test/socket.c
index 7b7fb69..5dc256f 100644
--- a/test/socket.c
+++ b/test/socket.c
@@ -32,6 +32,9 @@
#ifdef HAVE_STRING_H
#include <string.h>
#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h> /* for gethostname() */
+#endif
#include <time.h> /* for time() */
#include "ne_socket.h"
@@ -370,7 +373,15 @@ static int addr_compare(void)
static int addr_reverse(void)
{
ne_inet_addr *ia = ne_iaddr_make(ne_iaddr_ipv4, raw_127);
- char buf[128];
+ char buf[128], *syshost = NULL;
+
+#ifdef HAVE_GETHOSTNAME
+ char host[128];
+
+ if (gethostname(host, sizeof host) == 0) {
+ syshost = host;
+ }
+#endif
ONN("ne_iaddr_make returned NULL", ia == NULL);
@@ -378,7 +389,8 @@ static int addr_reverse(void)
ne_iaddr_reverse(ia, buf, sizeof buf) != 0);
ONV(!(strcmp(buf, "localhost.localdomain") == 0
- || strcmp(buf, "localhost") == 0),
+ || strcmp(buf, "localhost") == 0
+ || (syshost && strcmp(buf, syshost) == 0)),
("reverse lookup for 127.0.0.1 got %s", buf));
ne_iaddr_free(ia);