Skip to content

Commit

Permalink
tests/lwip_sock_udp: add test for sock_udp_sendv()
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed Jan 10, 2022
1 parent 2660706 commit eb8e7a2
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/lwip_sock_udp/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,38 @@ static void test_sock_udp_send6__socketed(void)
expect(_check_net());
}

static void test_sock_udp_sendv6__socketed(void)
{
static const ipv6_addr_t src_addr = { .u8 = _TEST_ADDR6_LOCAL };
static const ipv6_addr_t dst_addr = { .u8 = _TEST_ADDR6_REMOTE };
static const sock_udp_ep_t local = { .addr = { .ipv6 = _TEST_ADDR6_LOCAL },
.family = AF_INET6,
.netif = _TEST_NETIF,
.port = _TEST_PORT_LOCAL };
static const sock_udp_ep_t remote = { .addr = { .ipv6 = _TEST_ADDR6_REMOTE },
.family = AF_INET6,
.port = _TEST_PORT_REMOTE };

const sock_tx_snip_t tail = {
.data = "EFGH",
.len = sizeof("EFGH"),
};

const sock_tx_snip_t head = {
.next = (void *)&tail,
.data = "ABCD",
.len = sizeof("ABCD") - 1,
};

expect(0 == sock_udp_create(&_sock, &local, &remote, SOCK_FLAGS_REUSE_EP));
expect(sizeof("ABCDEFGH") == sock_udp_sendv(&_sock, &head, NULL));
expect(_check_6packet(&src_addr, &dst_addr, _TEST_PORT_LOCAL,
_TEST_PORT_REMOTE, "ABCDEFGH", sizeof("ABCDEFGH"),
_TEST_NETIF, false));
xtimer_usleep(1000); /* let GNRC stack finish */
expect(_check_net());
}

static void test_sock_udp_send6__socketed_other_remote(void)
{
static const ipv6_addr_t src_addr = { .u8 = _TEST_ADDR6_LOCAL };
Expand Down Expand Up @@ -1531,6 +1563,7 @@ int main(void)
CALL(test_sock_udp_send6__socketed_no_netif());
CALL(test_sock_udp_send6__socketed_no_local());
CALL(test_sock_udp_send6__socketed());
CALL(test_sock_udp_sendv6__socketed());
CALL(test_sock_udp_send6__socketed_other_remote());
CALL(test_sock_udp_send6__unsocketed_no_local_no_netif());
CALL(test_sock_udp_send6__unsocketed_no_netif());
Expand Down

0 comments on commit eb8e7a2

Please sign in to comment.