test: skip ipv6 tests when ipv6 is not supported
To verify on Linux, run `sudo sysctl net.ipv6.conf.all.disable_ipv6=1` before the test suite. Fixes: https://github.com/libuv/libuv/issues/10 PR-URL: https://github.com/libuv/libuv/pull/92 Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit is contained in:
parent
9141f48ea5
commit
a09e77e180
17
test/task.h
17
test/task.h
@ -234,4 +234,21 @@ UNUSED static void close_loop(uv_loop_t* loop) {
|
||||
uv_run(loop, UV_RUN_DEFAULT);
|
||||
}
|
||||
|
||||
UNUSED static int can_ipv6(void) {
|
||||
uv_interface_address_t* addr;
|
||||
int supported;
|
||||
int count;
|
||||
int i;
|
||||
|
||||
if (uv_interface_addresses(&addr, &count))
|
||||
return 1; /* Assume IPv6 support on failure. */
|
||||
|
||||
supported = 0;
|
||||
for (i = 0; supported == 0 && i < count; i += 1)
|
||||
supported = (AF_INET6 == addr[i].address.address6.sin6_family);
|
||||
|
||||
uv_free_interface_addresses(addr, count);
|
||||
return supported;
|
||||
}
|
||||
|
||||
#endif /* TASK_H_ */
|
||||
|
||||
@ -246,6 +246,9 @@ TEST_IMPL(tcp_ping_pong) {
|
||||
|
||||
|
||||
TEST_IMPL(tcp_ping_pong_v6) {
|
||||
if (!can_ipv6())
|
||||
RETURN_SKIP("IPv6 not supported");
|
||||
|
||||
tcp_pinger_v6_new();
|
||||
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
||||
|
||||
|
||||
@ -39,6 +39,9 @@ TEST_IMPL(tcp_bind6_error_addrinuse) {
|
||||
uv_tcp_t server1, server2;
|
||||
int r;
|
||||
|
||||
if (!can_ipv6())
|
||||
RETURN_SKIP("IPv6 not supported");
|
||||
|
||||
ASSERT(0 == uv_ip6_addr("::", TEST_PORT, &addr));
|
||||
|
||||
r = uv_tcp_init(uv_default_loop(), &server1);
|
||||
@ -73,6 +76,9 @@ TEST_IMPL(tcp_bind6_error_addrnotavail) {
|
||||
uv_tcp_t server;
|
||||
int r;
|
||||
|
||||
if (!can_ipv6())
|
||||
RETURN_SKIP("IPv6 not supported");
|
||||
|
||||
ASSERT(0 == uv_ip6_addr("4:4:4:4:4:4:4:4", TEST_PORT, &addr));
|
||||
|
||||
r = uv_tcp_init(uv_default_loop(), &server);
|
||||
@ -98,6 +104,9 @@ TEST_IMPL(tcp_bind6_error_fault) {
|
||||
uv_tcp_t server;
|
||||
int r;
|
||||
|
||||
if (!can_ipv6())
|
||||
RETURN_SKIP("IPv6 not supported");
|
||||
|
||||
garbage_addr = (struct sockaddr_in6*) &garbage;
|
||||
|
||||
r = uv_tcp_init(uv_default_loop(), &server);
|
||||
@ -123,6 +132,9 @@ TEST_IMPL(tcp_bind6_error_inval) {
|
||||
uv_tcp_t server;
|
||||
int r;
|
||||
|
||||
if (!can_ipv6())
|
||||
RETURN_SKIP("IPv6 not supported");
|
||||
|
||||
ASSERT(0 == uv_ip6_addr("::", TEST_PORT, &addr1));
|
||||
ASSERT(0 == uv_ip6_addr("::", TEST_PORT_2, &addr2));
|
||||
|
||||
@ -149,6 +161,9 @@ TEST_IMPL(tcp_bind6_localhost_ok) {
|
||||
uv_tcp_t server;
|
||||
int r;
|
||||
|
||||
if (!can_ipv6())
|
||||
RETURN_SKIP("IPv6 not supported");
|
||||
|
||||
ASSERT(0 == uv_ip6_addr("::1", TEST_PORT, &addr));
|
||||
|
||||
r = uv_tcp_init(uv_default_loop(), &server);
|
||||
|
||||
@ -147,23 +147,22 @@ static void do_test(uv_udp_recv_cb recv_cb, int bind_flags) {
|
||||
|
||||
|
||||
TEST_IMPL(udp_dual_stack) {
|
||||
#if defined(__DragonFly__) || \
|
||||
defined(__FreeBSD__) || \
|
||||
defined(__OpenBSD__) || \
|
||||
defined(__NetBSD__)
|
||||
RETURN_SKIP("dual stack not enabled by default in this OS.");
|
||||
#else
|
||||
if (!can_ipv6())
|
||||
RETURN_SKIP("IPv6 not supported");
|
||||
|
||||
do_test(ipv6_recv_ok, 0);
|
||||
|
||||
ASSERT(recv_cb_called == 1);
|
||||
ASSERT(send_cb_called == 1);
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
TEST_IMPL(udp_ipv6_only) {
|
||||
if (!can_ipv6())
|
||||
RETURN_SKIP("IPv6 not supported");
|
||||
|
||||
do_test(ipv6_recv_fail, UV_UDP_IPV6ONLY);
|
||||
|
||||
ASSERT(recv_cb_called == 0);
|
||||
|
||||
@ -60,6 +60,9 @@ TEST_IMPL(udp_multicast_interface6) {
|
||||
struct sockaddr_in6 addr;
|
||||
struct sockaddr_in6 baddr;
|
||||
|
||||
if (!can_ipv6())
|
||||
RETURN_SKIP("IPv6 not supported");
|
||||
|
||||
ASSERT(0 == uv_ip6_addr("::1", TEST_PORT, &addr));
|
||||
|
||||
r = uv_udp_init(uv_default_loop(), &server);
|
||||
|
||||
@ -103,6 +103,9 @@ TEST_IMPL(udp_multicast_join6) {
|
||||
uv_buf_t buf;
|
||||
struct sockaddr_in6 addr;
|
||||
|
||||
if (!can_ipv6())
|
||||
RETURN_SKIP("IPv6 not supported");
|
||||
|
||||
ASSERT(0 == uv_ip6_addr("::1", TEST_PORT, &addr));
|
||||
|
||||
r = uv_udp_init(uv_default_loop(), &server);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user