test,freebsd: skip udp_dual_stack if not supported

By default, FreeBSD has net.inet6.ip6.v6only set to 1 (i.e., no dual stack
support). A new function can_ipv6_ipv4_dual is added to check its value and
decide whether `udp_dual_stack` test must be skipped or not.

PR-URL: https://github.com/libuv/libuv/pull/614
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit is contained in:
Santiago Gimeno 2015-11-11 10:10:19 +01:00 committed by Saúl Ibarra Corretgé
parent 81072b98f5
commit 4052c74797

View File

@ -26,6 +26,10 @@
#include <stdlib.h>
#include <string.h>
#ifdef __FreeBSD__
#include <sys/sysctl.h>
#endif
#define CHECK_HANDLE(handle) \
ASSERT((uv_udp_t*)(handle) == &server \
|| (uv_udp_t*)(handle) == &client \
@ -43,6 +47,18 @@ static int send_cb_called;
static int recv_cb_called;
static int close_cb_called;
#ifdef __FreeBSD__
static int can_ipv6_ipv4_dual() {
int v6only;
size_t size = sizeof(int);
if (sysctlbyname("net.inet6.ip6.v6only", &v6only, &size, NULL, 0))
return 0;
return v6only != 1;
}
#endif
static void alloc_cb(uv_handle_t* handle,
size_t suggested_size,
@ -150,6 +166,11 @@ TEST_IMPL(udp_dual_stack) {
if (!can_ipv6())
RETURN_SKIP("IPv6 not supported");
#ifdef __FreeBSD__
if (!can_ipv6_ipv4_dual())
RETURN_SKIP("IPv6-IPv4 dual stack not supported");
#endif
do_test(ipv6_recv_ok, 0);
ASSERT(recv_cb_called == 1);