Skip to content

Commit

Permalink
tests/gnrc_sock_ip: Added test for sock_aux_local
Browse files Browse the repository at this point in the history
  • Loading branch information
maribu committed Aug 5, 2020
1 parent 5264b04 commit 12e9a48
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/gnrc_sock_ip/Makefile
Expand Up @@ -3,6 +3,7 @@ include ../Makefile.tests_common
USEMODULE += gnrc_sock_ip
USEMODULE += gnrc_ipv6
USEMODULE += ps
USEMODULE += sock_aux_local

# Set GNRC_PKTBUF_SIZE via CFLAGS if not being set via Kconfig.
ifndef CONFIG_GNRC_PKTBUF_SIZE
Expand Down
26 changes: 26 additions & 0 deletions tests/gnrc_sock_ip/main.c
Expand Up @@ -343,6 +343,31 @@ static void test_sock_ip_recv__non_blocking(void)
expect(_check_net());
}

static void test_sock_ip_recv__aux(void)
{
static const ipv6_addr_t src_addr = { .u8 = _TEST_ADDR_REMOTE };
static const ipv6_addr_t dst_addr = { .u8 = _TEST_ADDR_LOCAL };
static const sock_ip_ep_t local = { .family = AF_INET6 };
sock_ip_ep_t result;
sock_ip_aux_rx_t aux;

expect(0 == sock_ip_create(&_sock, &local, NULL, _TEST_PROTO,
SOCK_FLAGS_REUSE_EP));
expect(_inject_packet(&src_addr, &dst_addr, _TEST_PROTO, "ABCD",
sizeof("ABCD"), _TEST_NETIF));
expect(sizeof("ABCD") == sock_ip_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_NETIF == result.netif);
#ifdef MODULE_SOCK_AUX_LOCAL
expect(aux.flags & SOCK_AUX_HAS_LOCAL);
expect(memcmp(&aux.local.addr, &dst_addr, sizeof(dst_addr)) == 0);
#endif
expect(_check_net());
}

static void test_sock_ip_recv_buf__success(void)
{
static const ipv6_addr_t src_addr = { .u8 = _TEST_ADDR_REMOTE };
Expand Down Expand Up @@ -639,6 +664,7 @@ int main(void)
CALL(test_sock_ip_recv__unsocketed_with_remote());
CALL(test_sock_ip_recv__with_timeout());
CALL(test_sock_ip_recv__non_blocking());
CALL(test_sock_ip_recv__aux());
CALL(test_sock_ip_recv_buf__success());
_prepare_send_checks();
CALL(test_sock_ip_send__EAFNOSUPPORT());
Expand Down

0 comments on commit 12e9a48

Please sign in to comment.