Skip to content
Permalink
Browse files

tests: net: udp: Add tests for SO_PRIORITY and setsockopt

Verify that user is able to set SO_PRIORITY socket option.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
  • Loading branch information...
jukkar committed May 30, 2019
1 parent c3bb0a6 commit 194893d52dc5486e48dca2e688f0e7be034c7f8a
Showing with 39 additions and 3 deletions.
  1. +1 −0 tests/net/socket/udp/prj.conf
  2. +37 −1 tests/net/socket/udp/src/main.c
  3. +1 −2 tests/net/socket/udp/testcase.yaml
@@ -21,3 +21,4 @@ CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::1"
CONFIG_MAIN_STACK_SIZE=2048

CONFIG_ZTEST=y
CONFIG_NET_CONTEXT_PRIORITY=y
@@ -301,14 +301,50 @@ void test_send_recv_2_sock(void)
zassert_equal(rv, 0, "close failed");
}

void test_so_priority(void)
{
struct sockaddr_in bind_addr4;
struct sockaddr_in6 bind_addr6;
int sock1, sock2, rv;
u8_t optval;

prepare_sock_udp_v4(CONFIG_NET_CONFIG_MY_IPV4_ADDR, 55555,
&sock1, &bind_addr4);
prepare_sock_udp_v6(CONFIG_NET_CONFIG_MY_IPV6_ADDR, 55555,
&sock2, &bind_addr6);

rv = bind(sock1, (struct sockaddr *)&bind_addr4, sizeof(bind_addr4));
zassert_equal(rv, 0, "bind failed");

rv = bind(sock2, (struct sockaddr *)&bind_addr6, sizeof(bind_addr6));
zassert_equal(rv, 0, "bind failed");

optval = 2;
rv = setsockopt(sock1, SOL_SOCKET, SO_PRIORITY, &optval,
sizeof(optval));
zassert_equal(rv, 0, "setsockopt failed (%d)", errno);

optval = 8;
rv = setsockopt(sock2, SOL_SOCKET, SO_PRIORITY, &optval,
sizeof(optval));
zassert_equal(rv, 0, "setsockopt failed");

rv = close(sock1);
zassert_equal(rv, 0, "close failed");
rv = close(sock2);
zassert_equal(rv, 0, "close failed");
}

void test_main(void)
{
ztest_test_suite(socket_udp,
ztest_unit_test(test_send_recv_2_sock),
ztest_unit_test(test_v4_sendto_recvfrom),
ztest_unit_test(test_v6_sendto_recvfrom),
ztest_unit_test(test_v4_bind_sendto),
ztest_unit_test(test_v6_bind_sendto));
ztest_unit_test(test_v6_bind_sendto),
ztest_unit_test(test_so_priority)
);

ztest_run_test_suite(socket_udp);
}
@@ -1,10 +1,9 @@
common:
depends_on: netif
platform_whitelist: native_posix qemu_x86 qemu_cortex_m3
tags: net socket udp
tests:
net.socket.udp:
extra_configs:
- CONFIG_NET_TEST=y
- CONFIG_NET_LOOPBACK=y
min_ram: 21
tags: net socket

0 comments on commit 194893d

Please sign in to comment.
You can’t perform that action at this time.