mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
tests/lwip_sock_udp: Added test for sock_aux_local
This commit is contained in:
parent
77b39c5550
commit
1282ab1203
@ -1,6 +1,7 @@
|
||||
include ../Makefile.tests_common
|
||||
|
||||
LWIP_IPV4 ?= 0
|
||||
AUX_LOCAL ?= 1
|
||||
|
||||
ifneq (0, $(LWIP_IPV4))
|
||||
USEMODULE += ipv4_addr
|
||||
@ -17,6 +18,10 @@ ifneq (0, $(LWIP_IPV6))
|
||||
USEMODULE += lwip_ipv6_autoconfig
|
||||
endif
|
||||
|
||||
ifeq (1, $(AUX_LOCAL))
|
||||
USEMODULE += sock_aux_local
|
||||
endif
|
||||
|
||||
USEMODULE += inet_csum
|
||||
USEMODULE += l2util
|
||||
USEMODULE += lwip_netdev
|
||||
|
@ -394,6 +394,36 @@ static void test_sock_udp_recv4__non_blocking(void)
|
||||
expect(_check_net());
|
||||
}
|
||||
|
||||
static void test_sock_udp_recv4__aux(void)
|
||||
{
|
||||
static const sock_udp_ep_t local = { .family = AF_INET,
|
||||
.port = _TEST_PORT_LOCAL };
|
||||
sock_udp_ep_t result;
|
||||
sock_udp_aux_rx_t aux = { .flags = SOCK_AUX_GET_LOCAL };
|
||||
|
||||
expect(0 == sock_udp_create(&_sock, &local, NULL, SOCK_FLAGS_REUSE_EP));
|
||||
expect(_inject_4packet(_TEST_ADDR4_REMOTE, _TEST_ADDR4_LOCAL, _TEST_PORT_REMOTE,
|
||||
_TEST_PORT_LOCAL, "ABCD", sizeof("ABCD"),
|
||||
_TEST_NETIF));
|
||||
expect(sizeof("ABCD") == sock_udp_recv_aux(&_sock, _test_buffer,
|
||||
sizeof(_test_buffer), 0, &result,
|
||||
&aux));
|
||||
expect(AF_INET == result.family);
|
||||
expect(_TEST_ADDR4_REMOTE == result.addr.ipv4_u32);
|
||||
expect(_TEST_PORT_REMOTE == result.port);
|
||||
#if IS_USED(MODULE_SOCK_AUX_LOCAL)
|
||||
expect(_TEST_NETIF == result.netif);
|
||||
expect(!(aux.flags & SOCK_AUX_GET_LOCAL));
|
||||
expect(aux.local.addr.ipv4_u32 == _TEST_ADDR4_LOCAL);
|
||||
expect(aux.local.port == _TEST_PORT_LOCAL);
|
||||
expect(aux.local.family == AF_INET);
|
||||
#else
|
||||
expect(aux.flags & SOCK_AUX_GET_LOCAL);
|
||||
#endif /* MODULE_SOCK_AUX_LOCAL */
|
||||
expect(_check_net());
|
||||
}
|
||||
|
||||
|
||||
static void test_sock_udp_recv_buf4__success(void)
|
||||
{
|
||||
static const sock_udp_ep_t local = { .family = AF_INET,
|
||||
@ -1057,6 +1087,37 @@ static void test_sock_udp_recv6__non_blocking(void)
|
||||
expect(_check_net());
|
||||
}
|
||||
|
||||
static void test_sock_udp_recv6__aux(void)
|
||||
{
|
||||
static const ipv6_addr_t src_addr = { .u8 = _TEST_ADDR6_REMOTE };
|
||||
static const ipv6_addr_t dst_addr = { .u8 = _TEST_ADDR6_LOCAL };
|
||||
static const sock_udp_ep_t local = { .family = AF_INET6,
|
||||
.port = _TEST_PORT_LOCAL };
|
||||
sock_udp_ep_t result;
|
||||
sock_udp_aux_rx_t aux = { .flags = SOCK_AUX_GET_LOCAL };
|
||||
|
||||
expect(0 == sock_udp_create(&_sock, &local, NULL, SOCK_FLAGS_REUSE_EP));
|
||||
expect(_inject_6packet(&src_addr, &dst_addr, _TEST_PORT_REMOTE,
|
||||
_TEST_PORT_LOCAL, "ABCD", sizeof("ABCD"),
|
||||
_TEST_NETIF));
|
||||
expect(sizeof("ABCD") == sock_udp_recv_aux(&_sock, _test_buffer,
|
||||
sizeof(_test_buffer), 0, &result,
|
||||
&aux));
|
||||
expect(AF_INET6 == result.family);
|
||||
expect(memcmp(&result.addr, &src_addr, sizeof(result.addr)) == 0);
|
||||
expect(_TEST_PORT_REMOTE == result.port);
|
||||
#if IS_USED(MODULE_SOCK_AUX_LOCAL)
|
||||
expect(_TEST_NETIF == result.netif);
|
||||
expect(!(aux.flags & SOCK_AUX_GET_LOCAL));
|
||||
expect(memcmp(&aux.local.addr, &dst_addr, sizeof(dst_addr)) == 0);
|
||||
expect(aux.local.port == _TEST_PORT_LOCAL);
|
||||
expect(aux.local.family == AF_INET6);
|
||||
#else
|
||||
expect(aux.flags & SOCK_AUX_GET_LOCAL);
|
||||
#endif /* MODULE_SOCK_AUX_LOCAL */
|
||||
expect(_check_net());
|
||||
}
|
||||
|
||||
static void test_sock_udp_recv_buf6__success(void)
|
||||
{
|
||||
static const ipv6_addr_t src_addr = { .u8 = _TEST_ADDR6_REMOTE };
|
||||
@ -1409,6 +1470,7 @@ int main(void)
|
||||
CALL(test_sock_udp_recv4__unsocketed_with_remote());
|
||||
CALL(test_sock_udp_recv4__with_timeout());
|
||||
CALL(test_sock_udp_recv4__non_blocking());
|
||||
CALL(test_sock_udp_recv4__aux());
|
||||
CALL(test_sock_udp_recv_buf4__success());
|
||||
_prepare_send_checks();
|
||||
CALL(test_sock_udp_send4__EAFNOSUPPORT());
|
||||
@ -1457,6 +1519,7 @@ int main(void)
|
||||
CALL(test_sock_udp_recv6__unsocketed_with_remote());
|
||||
CALL(test_sock_udp_recv6__with_timeout());
|
||||
CALL(test_sock_udp_recv6__non_blocking());
|
||||
CALL(test_sock_udp_recv6__aux());
|
||||
CALL(test_sock_udp_recv_buf6__success());
|
||||
_prepare_send_checks();
|
||||
CALL(test_sock_udp_send6__EAFNOSUPPORT());
|
||||
|
Loading…
Reference in New Issue
Block a user