Browse Source

net: fix tests for systems without IPv6 entries in /etc/hosts.

We fake up a dual IPv4/IPv6 response to localhost for testing, but it
assumed localhost6 or ip6-localhost entries.  Fall back to "::1" which
should always work.
Rusty Russell 14 years ago
parent
commit
5b189c748d
1 changed files with 4 additions and 0 deletions
  1. 4 0
      ccan/net/test/run.c

+ 4 - 0
ccan/net/test/run.c

@@ -69,6 +69,10 @@ static struct addrinfo* double_addr_lookup(char* buf)
 				addr2 = net_client_lookup("localhost6", buf,
 				addr2 = net_client_lookup("localhost6", buf,
 							  AF_UNSPEC,
 							  AF_UNSPEC,
 							  SOCK_STREAM);
 							  SOCK_STREAM);
+			if (!addr2)
+				addr2 = net_client_lookup("::1", buf,
+							  AF_UNSPEC,
+							  SOCK_STREAM);
 		} else if (addr->ai_family == AF_INET6)
 		} else if (addr->ai_family == AF_INET6)
 			/* IPv6 only?  This is a guess... */
 			/* IPv6 only?  This is a guess... */
 			addr2 = net_client_lookup("ip4-localhost", buf,
 			addr2 = net_client_lookup("ip4-localhost", buf,