tests: skip some tests when network is unreachable

Do not hard-fail network tests when libuv is built on
an isolated host/container.

This is a backport of 5df06b3 (v1.x)

Signed-off-by: Luca Bruno <lucab@debian.org>

PR-URL: https://github.com/libuv/libuv/pull/441
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit is contained in:
Luca Bruno 2015-07-13 17:38:06 +02:00 committed by Saúl Ibarra Corretgé
parent 8af26a7b84
commit fa0fa2fac4
4 changed files with 14 additions and 2 deletions

View File

@ -60,12 +60,16 @@ TEST_IMPL(tcp_close_while_connecting) {
uv_connect_t connect_req;
struct sockaddr_in addr;
uv_loop_t* loop;
int r;
addr = uv_ip4_addr("1.2.3.4", TEST_PORT);
loop = uv_default_loop();
ASSERT(0 == uv_tcp_init(loop, &tcp_handle));
ASSERT(0 == uv_tcp_connect(&connect_req, &tcp_handle, addr, connect_cb));
r = uv_tcp_connect(&connect_req, &tcp_handle, addr, connect_cb);
if (r == -1 && uv_last_error(uv_default_loop()).code == UV_ENETUNREACH)
RETURN_SKIP("Network unreachable.");
ASSERT(r == 0);
ASSERT(0 == uv_timer_init(loop, &timer1_handle));
ASSERT(0 == uv_timer_start(&timer1_handle, timer1_cb, 50, 0));
ASSERT(0 == uv_timer_init(loop, &timer2_handle));

View File

@ -76,6 +76,8 @@ TEST_IMPL(tcp_connect_timeout) {
ASSERT(r == 0);
r = uv_tcp_connect(&connect_req, &conn, addr, connect_cb);
if (r == -1 && uv_last_error(uv_default_loop()).code == UV_ENETUNREACH)
RETURN_SKIP("Network unreachable.");
ASSERT(r == 0);
r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);

View File

@ -113,6 +113,8 @@ TEST_IMPL(udp_multicast_join) {
/* join the multicast channel */
r = uv_udp_set_membership(&client, "239.255.0.1", NULL, UV_JOIN_GROUP);
if (r == -1 && uv_last_error(uv_default_loop()).code == UV_ENODEV)
RETURN_SKIP("No multicast support.");
ASSERT(r == 0);
r = uv_udp_recv_start(&client, alloc_cb, cl_recv_cb);

View File

@ -44,7 +44,11 @@ static void close_cb(uv_handle_t* handle) {
static void sv_send_cb(uv_udp_send_t* req, int status) {
ASSERT(req != NULL);
ASSERT(status == 0);
if (status == -1) {
ASSERT(uv_last_error(uv_default_loop()).code == UV_ENETUNREACH);
} else {
ASSERT(status == 0);
}
CHECK_HANDLE(req->handle);
sv_send_cb_called++;