1
0
mirror of https://github.com/libuv/libuv synced 2025-03-28 21:13:16 +00:00

test: fix udp multicast interface test

This commit is contained in:
Saúl Ibarra Corretgé 2014-02-10 08:56:39 +01:00
parent a3c0e48faa
commit 419c2ffae7
2 changed files with 13 additions and 3 deletions

View File

@ -196,6 +196,7 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/test-tty.c \
test/test-udp-dgram-too-big.c \
test/test-udp-ipv6.c \
test/test-udp-multicast-interface.c \
test/test-udp-multicast-join.c \
test/test-udp-multicast-ttl.c \
test/test-udp-open.c \

View File

@ -57,12 +57,16 @@ TEST_IMPL(udp_multicast_interface) {
int r;
uv_udp_send_t req;
uv_buf_t buf;
struct sockaddr_in addr = uv_ip4_addr("239.255.0.1", TEST_PORT);
struct sockaddr_in addr;
struct sockaddr_in baddr;
ASSERT(0 == uv_ip4_addr("239.255.0.1", TEST_PORT, &addr));
r = uv_udp_init(uv_default_loop(), &server);
ASSERT(r == 0);
r = uv_udp_bind(&server, uv_ip4_addr("0.0.0.0", 0), 0);
ASSERT(0 == uv_ip4_addr("0.0.0.0", 0, &baddr));
r = uv_udp_bind(&server, (const struct sockaddr*)&baddr, 0);
ASSERT(r == 0);
r = uv_udp_set_multicast_interface(&server, "0.0.0.0");
@ -70,7 +74,12 @@ TEST_IMPL(udp_multicast_interface) {
/* server sends "PING" */
buf = uv_buf_init("PING", 4);
r = uv_udp_send(&req, &server, &buf, 1, addr, sv_send_cb);
r = uv_udp_send(&req,
&server,
&buf,
1,
(const struct sockaddr*)&addr,
sv_send_cb);
ASSERT(r == 0);
ASSERT(close_cb_called == 0);