Skip to content

Commit 12e9a48

Browse files
committed
tests/gnrc_sock_ip: Added test for sock_aux_local
1 parent 5264b04 commit 12e9a48

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

tests/gnrc_sock_ip/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ include ../Makefile.tests_common
33
USEMODULE += gnrc_sock_ip
44
USEMODULE += gnrc_ipv6
55
USEMODULE += ps
6+
USEMODULE += sock_aux_local
67

78
# Set GNRC_PKTBUF_SIZE via CFLAGS if not being set via Kconfig.
89
ifndef CONFIG_GNRC_PKTBUF_SIZE

tests/gnrc_sock_ip/main.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,31 @@ static void test_sock_ip_recv__non_blocking(void)
343343
expect(_check_net());
344344
}
345345

346+
static void test_sock_ip_recv__aux(void)
347+
{
348+
static const ipv6_addr_t src_addr = { .u8 = _TEST_ADDR_REMOTE };
349+
static const ipv6_addr_t dst_addr = { .u8 = _TEST_ADDR_LOCAL };
350+
static const sock_ip_ep_t local = { .family = AF_INET6 };
351+
sock_ip_ep_t result;
352+
sock_ip_aux_rx_t aux;
353+
354+
expect(0 == sock_ip_create(&_sock, &local, NULL, _TEST_PROTO,
355+
SOCK_FLAGS_REUSE_EP));
356+
expect(_inject_packet(&src_addr, &dst_addr, _TEST_PROTO, "ABCD",
357+
sizeof("ABCD"), _TEST_NETIF));
358+
expect(sizeof("ABCD") == sock_ip_recv_aux(&_sock, _test_buffer,
359+
sizeof(_test_buffer), 0, &result,
360+
&aux));
361+
expect(AF_INET6 == result.family);
362+
expect(memcmp(&result.addr, &src_addr, sizeof(result.addr)) == 0);
363+
expect(_TEST_NETIF == result.netif);
364+
#ifdef MODULE_SOCK_AUX_LOCAL
365+
expect(aux.flags & SOCK_AUX_HAS_LOCAL);
366+
expect(memcmp(&aux.local.addr, &dst_addr, sizeof(dst_addr)) == 0);
367+
#endif
368+
expect(_check_net());
369+
}
370+
346371
static void test_sock_ip_recv_buf__success(void)
347372
{
348373
static const ipv6_addr_t src_addr = { .u8 = _TEST_ADDR_REMOTE };
@@ -639,6 +664,7 @@ int main(void)
639664
CALL(test_sock_ip_recv__unsocketed_with_remote());
640665
CALL(test_sock_ip_recv__with_timeout());
641666
CALL(test_sock_ip_recv__non_blocking());
667+
CALL(test_sock_ip_recv__aux());
642668
CALL(test_sock_ip_recv_buf__success());
643669
_prepare_send_checks();
644670
CALL(test_sock_ip_send__EAFNOSUPPORT());

0 commit comments

Comments
 (0)