Skip to content

Commit

Permalink
net: sockets: udp: test FIONREAD with ipv4 and ipv6 sockets
Browse files Browse the repository at this point in the history
The FIONREAD ioctl (or rather ZFD_IOCTL_FIONREAD) returns the
number of bytes available on the socket that can be read
immediately.

Test that the ioctl behaves according to the expectation.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
  • Loading branch information
cfriedt committed Jul 29, 2023
1 parent 168eb2a commit c73beb6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/net/socket/udp/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ static void comm_sendto_recvfrom(int client_sock,
struct sockaddr *server_addr,
socklen_t server_addrlen)
{
int avail;
ssize_t sent = 0;
ssize_t recved = 0;
struct sockaddr addr;
Expand All @@ -76,6 +77,12 @@ static void comm_sendto_recvfrom(int client_sock,
0, server_addr, server_addrlen);
zassert_equal(sent, strlen(TEST_STR_SMALL), "sendto failed");

k_msleep(100);

avail = 42;
zassert_ok(ioctl(server_sock, ZFD_IOCTL_FIONREAD, &avail));
zassert_equal(avail, strlen(TEST_STR_SMALL));

/* Test recvfrom(MSG_PEEK) */
addrlen = sizeof(addr);
clear_buf(rx_buf);
Expand Down

0 comments on commit c73beb6

Please sign in to comment.