diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/socket.c | 16 |
1 files changed, 14 insertions, 2 deletions
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); |