diff --git a/tests/lwip_sock_udp/main.c b/tests/lwip_sock_udp/main.c index 77416057ba..202b23627b 100644 --- a/tests/lwip_sock_udp/main.c +++ b/tests/lwip_sock_udp/main.c @@ -117,6 +117,21 @@ static void test_sock_udp_create4__only_local(void) assert(-ENOTCONN == sock_udp_get_remote(&_sock, &ep)); } +static void test_sock_udp_create4__only_local_port0(void) +{ + static const sock_udp_ep_t local = { .family = AF_INET, + .port = 0U }; + sock_udp_ep_t ep; + + assert(0 == sock_udp_create(&_sock, &local, NULL, SOCK_FLAGS_REUSE_EP)); + assert(0 == sock_udp_get_local(&_sock, &ep)); + assert(AF_INET == ep.family); + assert(0 == ep.addr.ipv4_u32); + assert(SOCK_ADDR_ANY_NETIF == ep.netif); + assert(0U != ep.port); + assert(-ENOTCONN == sock_udp_get_remote(&_sock, &ep)); +} + static void test_sock_udp_create4__only_local_reuse_ep(void) { static const sock_udp_ep_t local = { .family = AF_INET, @@ -694,6 +709,22 @@ static void test_sock_udp_create6__only_local(void) assert(-ENOTCONN == sock_udp_get_remote(&_sock, &ep)); } +static void test_sock_udp_create6__only_local_port0(void) +{ + static const sock_udp_ep_t local = { .family = AF_INET6, + .port = 0U }; + sock_udp_ep_t ep; + + assert(0 == sock_udp_create(&_sock, &local, NULL, SOCK_FLAGS_REUSE_EP)); + assert(0 == sock_udp_get_local(&_sock, &ep)); + assert(AF_INET6 == ep.family); + assert(memcmp(&ipv6_addr_unspecified, &ep.addr.ipv6, + sizeof(ipv6_addr_t)) == 0); + assert(SOCK_ADDR_ANY_NETIF == ep.netif); + assert(0U != ep.port); + assert(-ENOTCONN == sock_udp_get_remote(&_sock, &ep)); +} + static void test_sock_udp_create6__only_local_reuse_ep(void) { static const sock_udp_ep_t local = { .family = AF_INET6, @@ -1256,6 +1287,7 @@ int main(void) CALL(test_sock_udp_create4__EINVAL_netif()); CALL(test_sock_udp_create4__no_endpoints()); CALL(test_sock_udp_create4__only_local()); + CALL(test_sock_udp_create4__only_local_port0()); CALL(test_sock_udp_create4__only_local_reuse_ep()); CALL(test_sock_udp_create4__only_remote()); CALL(test_sock_udp_create4__full()); @@ -1301,6 +1333,7 @@ int main(void) CALL(test_sock_udp_create6__EINVAL_netif()); CALL(test_sock_udp_create6__no_endpoints()); CALL(test_sock_udp_create6__only_local()); + CALL(test_sock_udp_create6__only_local_port0()); CALL(test_sock_udp_create6__only_local_reuse_ep()); CALL(test_sock_udp_create6__only_remote()); CALL(test_sock_udp_create6__full());