Skip to content

Commit 72281a5

Browse files
author
Ari Parkkila
committed
Fix UDPSOCKET_ECHOTEST to handle oversized packets
1 parent 1234b3f commit 72281a5

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

TESTS/netsocket/udp/udpsocket_echotest.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ void UDPSOCKET_ECHOTEST_impl(bool use_sendto)
8686

8787
fill_tx_buffer_ascii(tx_buffer, BUFF_SIZE);
8888
int packets_sent_prev = packets_sent;
89+
bool is_oversized;
8990

9091
for (int retry_cnt = 0; retry_cnt <= 2; retry_cnt++) {
9192
memset(rx_buffer, 0, BUFF_SIZE);
@@ -94,8 +95,10 @@ void UDPSOCKET_ECHOTEST_impl(bool use_sendto)
9495
} else {
9596
sent = sock.send(tx_buffer, pkt_s);
9697
}
97-
if (check_oversized_packets(sent, pkt_s)) {
98+
is_oversized = check_oversized_packets(sent, pkt_s);
99+
if (is_oversized) {
98100
TEST_IGNORE_MESSAGE("This device does not handle oversized packets");
101+
break;
99102
} else if (sent == pkt_s) {
100103
packets_sent++;
101104
} else {
@@ -127,6 +130,9 @@ void UDPSOCKET_ECHOTEST_impl(bool use_sendto)
127130
}
128131
}
129132

133+
if (is_oversized) {
134+
continue;
135+
}
130136
if (use_sendto) {
131137
// Verify received address is correct
132138
TEST_ASSERT(udp_addr == recv_addr);
@@ -188,6 +194,8 @@ void UDPSOCKET_ECHOTEST_NONBLOCK_impl(bool use_sendto)
188194
for (unsigned int s_idx = 0; s_idx < sizeof(pkt_sizes) / sizeof(*pkt_sizes); ++s_idx) {
189195
int pkt_s = pkt_sizes[s_idx];
190196
int packets_sent_prev = packets_sent;
197+
bool is_oversized;
198+
191199
for (int retry_cnt = 0; retry_cnt <= RETRIES; retry_cnt++) {
192200
fill_tx_buffer_ascii(tx_buffer, pkt_s);
193201

@@ -197,7 +205,11 @@ void UDPSOCKET_ECHOTEST_NONBLOCK_impl(bool use_sendto)
197205
sent = sock->send(tx_buffer, pkt_s);
198206
}
199207

200-
if (sent == pkt_s) {
208+
is_oversized = check_oversized_packets(sent, pkt_s);
209+
if (is_oversized) {
210+
TEST_IGNORE_MESSAGE("This device does not handle oversized packets");
211+
break;
212+
} else if (sent == pkt_s) {
201213
packets_sent++;
202214
} else if (sent == NSAPI_ERROR_WOULD_BLOCK) {
203215
if (tc_exec_time.read() >= time_allotted ||
@@ -239,6 +251,10 @@ void UDPSOCKET_ECHOTEST_NONBLOCK_impl(bool use_sendto)
239251
break;
240252
}
241253
}
254+
255+
if (is_oversized) {
256+
continue;
257+
}
242258
// Make sure that at least one packet of every size was sent.
243259
TEST_ASSERT_TRUE(packets_sent > packets_sent_prev);
244260
if (memcmp(tx_buffer, rx_buffer, pkt_s) == 0) {

0 commit comments

Comments
 (0)