Commit 85e88fa0 authored by Dafydd Harries's avatar Dafydd Harries
Browse files

add extra test for BSD sockets

darcs-hash:20070205162552-c9803-ff0b7bcbce6668efaa473afeb0fc4f6882f81397.gz
parent ebc37d94
......@@ -21,16 +21,18 @@ udp_client_LDADD = $(COMMON_LDADD)
udp_echo_server_LDADD = $(COMMON_LDADD)
check_PROGRAMS = test-fake
check_PROGRAMS = test-fake test-bsd
test_fake_LDADD = $(COMMON_LDADD)
test_bsd_LDADD = $(COMMON_LDADD)
test-echo.sh::
chmod +x $(srcdir)/$@
EXTRA_DIST = test-echo.sh
TESTS = test-echo.sh test-fake
TESTS = test-echo.sh $(check_PROGRAMS)
pkginclude_HEADERS = udp.h udp-fake.h udp-bsd.h
#include <string.h>
#include "udp-bsd.h"
int
main (void)
{
NiceUDPSocketFactory factory;
NiceUDPSocket server;
NiceUDPSocket client;
NiceAddress tmp = {0,};
gchar buf[5];
nice_udp_bsd_socket_factory_init (&factory);
g_assert (nice_udp_socket_factory_make (&factory, &server, NULL));
// not bound to a particular interface
g_assert (server.addr.addr_ipv4 == 0);
// is bound to a particular port
g_assert (server.addr.port != 0);
g_assert (nice_udp_socket_factory_make (&factory, &client, NULL));
// not bound to a particular interface
g_assert (client.addr.addr_ipv4 == 0);
// is bound to a particular port
g_assert (client.addr.port != 0);
nice_udp_socket_send (&client, &server.addr, 5, "hello");
g_assert (5 == nice_udp_socket_recv (&server, &tmp, 5, buf));
g_assert (0 == strncmp (buf, "hello", 5));
g_assert (tmp.port == client.addr.port);
nice_udp_socket_send (&server, &client.addr, 5, "uryyb");
g_assert (5 == nice_udp_socket_recv (&client, &tmp, 5, buf));
g_assert (0 == strncmp (buf, "uryyb", 5));
g_assert (tmp.port == server.addr.port);
nice_udp_socket_close (&client);
nice_udp_socket_close (&server);
nice_udp_socket_factory_close (&factory);
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment