tests: net: sockets: af_packet: Fix recvfrom DGRAM test

The recvfrom test case for DGRAM packet socket specified wrong socket
type, so RAW sockets were tested twice instead. Also, for the DGRAM
variant, the offset was not taken into account for the expected packet
length.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
Robert Lubos 2025-04-25 15:53:44 +02:00 committed by Benjamin Cabé
parent 29a2b5c8c6
commit cd50608f24

View File

@ -894,6 +894,8 @@ static void test_recvfrom_common(int sock_type, int proto)
offset = sizeof(struct net_eth_hdr);
}
pkt_len -= offset;
ret = zsock_recvfrom(packet_sock_2, rx_buf, sizeof(rx_buf), 0,
(struct sockaddr *)&ll_rx, &addrlen);
zassert_not_equal(ret, -1, "Failed to receive packet (%d)", errno);
@ -927,7 +929,7 @@ ZTEST(socket_packet, test_dgram_sock_recv_proto_wildcard)
ZTEST(socket_packet, test_dgram_sock_recvfrom_proto_wildcard)
{
test_recvfrom_common(SOCK_RAW, ETH_P_ALL);
test_recvfrom_common(SOCK_DGRAM, ETH_P_ALL);
}
ZTEST(socket_packet, test_raw_dgram_udp_socks_recv)