mirror of https://github.com/ARMmbed/mbed-os.git
UDPSOCKET_ECHOTEST fails if a packet of any given size was not sent at least once
parent
0b7d9af4dd
commit
d1017ea274
|
@ -785,9 +785,9 @@ Verify working of different packet sizes.
|
||||||
|
|
||||||
**Expected result:**
|
**Expected result:**
|
||||||
|
|
||||||
All sendto() calls should return the packet size. All recvfrom() calls
|
At least one sendto() call of every size should return the packet size.
|
||||||
should return the same sized packet that was send with same content.
|
Errors returned from recvfrom() calls are tolerated.
|
||||||
Calculate packet loss rate, maximum tolerated packet loss rate is 30%
|
Calculate packet loss rate, maximum tolerated packet loss rate is 30%.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -819,11 +819,9 @@ mode
|
||||||
|
|
||||||
**Expected result:**
|
**Expected result:**
|
||||||
|
|
||||||
All sendto() calls should return the packet size. All recvfrom() calls
|
At least one sendto() call of every size should return the packet size.
|
||||||
should return the same sized packet that was send with same content or
|
Errors returned from recvfrom() calls are tolerated.
|
||||||
NSAPI_ERROR_WOULD_BLOCK.
|
Calculate packet loss rate, maximum tolerated packet loss rate is 30%.
|
||||||
|
|
||||||
Calculate packet loss rate, maximum tolerated packet loss rate is 30%
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -74,28 +74,33 @@ void UDPSOCKET_ECHOTEST()
|
||||||
int pkt_s = pkt_sizes[s_idx];
|
int pkt_s = pkt_sizes[s_idx];
|
||||||
|
|
||||||
fill_tx_buffer_ascii(tx_buffer, BUFF_SIZE);
|
fill_tx_buffer_ascii(tx_buffer, BUFF_SIZE);
|
||||||
|
int packets_sent_prev = packets_sent;
|
||||||
|
|
||||||
for (int retry_cnt = 0; retry_cnt <= 2; retry_cnt++) {
|
for (int retry_cnt = 0; retry_cnt <= 2; retry_cnt++) {
|
||||||
memset(rx_buffer, 0, BUFF_SIZE);
|
memset(rx_buffer, 0, BUFF_SIZE);
|
||||||
sent = sock.sendto(udp_addr, tx_buffer, pkt_s);
|
sent = sock.sendto(udp_addr, tx_buffer, pkt_s);
|
||||||
if (check_oversized_packets(sent, pkt_s)) {
|
if (check_oversized_packets(sent, pkt_s)) {
|
||||||
TEST_IGNORE_MESSAGE("This device does not handle oversized packets");
|
TEST_IGNORE_MESSAGE("This device does not handle oversized packets");
|
||||||
} else if (sent > 0) {
|
} else if (sent == pkt_s) {
|
||||||
packets_sent++;
|
packets_sent++;
|
||||||
}
|
} else {
|
||||||
if (sent != pkt_s) {
|
|
||||||
printf("[Round#%02d - Sender] error, returned %d\n", s_idx, sent);
|
printf("[Round#%02d - Sender] error, returned %d\n", s_idx, sent);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
recvd = sock.recvfrom(NULL, rx_buffer, pkt_s);
|
recvd = sock.recvfrom(NULL, rx_buffer, pkt_s);
|
||||||
if (recvd == pkt_s) {
|
if (recvd == pkt_s) {
|
||||||
break;
|
break;
|
||||||
|
} else {
|
||||||
|
printf("[Round#%02d - Receiver] error, returned %d\n", s_idx, recvd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (memcmp(tx_buffer, rx_buffer, pkt_s) == 0) {
|
if (memcmp(tx_buffer, rx_buffer, pkt_s) == 0) {
|
||||||
packets_recv++;
|
packets_recv++;
|
||||||
}
|
}
|
||||||
|
// Make sure that at least one packet of every size was sent.
|
||||||
|
TEST_ASSERT_TRUE(packets_sent > packets_sent_prev);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Packet loss up to 30% tolerated
|
// Packet loss up to 30% tolerated
|
||||||
if (packets_sent > 0) {
|
if (packets_sent > 0) {
|
||||||
double loss_ratio = 1 - ((double)packets_recv / (double)packets_sent);
|
double loss_ratio = 1 - ((double)packets_recv / (double)packets_sent);
|
||||||
|
@ -154,6 +159,7 @@ void UDPSOCKET_ECHOTEST_NONBLOCK()
|
||||||
|
|
||||||
for (int s_idx = 0; s_idx < sizeof(pkt_sizes) / sizeof(*pkt_sizes); ++s_idx) {
|
for (int s_idx = 0; s_idx < sizeof(pkt_sizes) / sizeof(*pkt_sizes); ++s_idx) {
|
||||||
int pkt_s = pkt_sizes[s_idx];
|
int pkt_s = pkt_sizes[s_idx];
|
||||||
|
int packets_sent_prev = packets_sent;
|
||||||
|
|
||||||
thread = new Thread(osPriorityNormal,
|
thread = new Thread(osPriorityNormal,
|
||||||
OS_STACK_SIZE,
|
OS_STACK_SIZE,
|
||||||
|
@ -165,16 +171,15 @@ void UDPSOCKET_ECHOTEST_NONBLOCK()
|
||||||
fill_tx_buffer_ascii(tx_buffer, pkt_s);
|
fill_tx_buffer_ascii(tx_buffer, pkt_s);
|
||||||
|
|
||||||
sent = sock.sendto(udp_addr, tx_buffer, pkt_s);
|
sent = sock.sendto(udp_addr, tx_buffer, pkt_s);
|
||||||
if (sent > 0) {
|
if (sent == pkt_s) {
|
||||||
packets_sent++;
|
packets_sent++;
|
||||||
}
|
} else if (sent == NSAPI_ERROR_WOULD_BLOCK) {
|
||||||
if (sent == NSAPI_ERROR_WOULD_BLOCK) {
|
|
||||||
if (tc_exec_time.read() >= time_allotted ||
|
if (tc_exec_time.read() >= time_allotted ||
|
||||||
osSignalWait(SIGNAL_SIGIO_TX, SIGIO_TIMEOUT).status == osEventTimeout) {
|
osSignalWait(SIGNAL_SIGIO_TX, SIGIO_TIMEOUT).status == osEventTimeout) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
--retry_cnt;
|
--retry_cnt;
|
||||||
} else if (sent != pkt_s) {
|
} else {
|
||||||
printf("[Round#%02d - Sender] error, returned %d\n", s_idx, sent);
|
printf("[Round#%02d - Sender] error, returned %d\n", s_idx, sent);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -183,6 +188,8 @@ void UDPSOCKET_ECHOTEST_NONBLOCK()
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// Make sure that at least one packet of every size was sent.
|
||||||
|
TEST_ASSERT_TRUE(packets_sent > packets_sent_prev);
|
||||||
thread->join();
|
thread->join();
|
||||||
delete thread;
|
delete thread;
|
||||||
if (memcmp(tx_buffer, rx_buffer, pkt_s) == 0) {
|
if (memcmp(tx_buffer, rx_buffer, pkt_s) == 0) {
|
||||||
|
|
Loading…
Reference in New Issue