@@ -84,7 +84,7 @@ void MULTIHOMING_UDPSOCKET_ECHOTEST()
84
84
packets_sent++;
85
85
}
86
86
if (sent != pkt_s) {
87
- printf (" [Round#%02d - Sender] error, returned %d\n " , s_idx, sent);
87
+ tr_warn (" [Round#%02d - Sender] error, returned %d\n " , s_idx, sent);
88
88
continue ;
89
89
}
90
90
recvd = sock.recvfrom (NULL , rx_buffer, pkt_s);
@@ -99,8 +99,10 @@ void MULTIHOMING_UDPSOCKET_ECHOTEST()
99
99
// Packet loss up to 30% tolerated
100
100
if (packets_sent > 0 ) {
101
101
double loss_ratio = 1 - ((double )packets_recv / (double )packets_sent);
102
- printf (" Interface %s, packets sent: %d, packets received %d, loss ratio %.2lf\r\n " , interface_name[j], packets_sent, packets_recv, loss_ratio);
102
+ tr_warn (" Interface %s, packets sent: %d, packets received %d, loss ratio %.2lf\r\n " , interface_name[j], packets_sent, packets_recv, loss_ratio);
103
103
TEST_ASSERT_DOUBLE_WITHIN (TOLERATED_LOSS_RATIO, EXPECTED_LOSS_RATIO, loss_ratio);
104
+ } else {
105
+ TEST_FAIL ();
104
106
}
105
107
}
106
108
TEST_ASSERT_EQUAL (NSAPI_ERROR_OK, sock.close ());
@@ -177,7 +179,7 @@ void MULTIHOMING_UDPSOCKET_ECHOTEST_NONBLOCK()
177
179
}
178
180
--retry_cnt;
179
181
} else if (sent != pkt_s) {
180
- printf (" [Round#%02d - Sender] error, returned %d\n " , s_idx, sent);
182
+ tr_warn (" [Round#%02d - Sender] error, returned %d\n " , s_idx, sent);
181
183
continue ;
182
184
}
183
185
if (!tx_sem.try_acquire_for (WAIT2RECV_TIMEOUT * 2 )) { // RX might wait up to WAIT2RECV_TIMEOUT before recvfrom
@@ -196,7 +198,7 @@ void MULTIHOMING_UDPSOCKET_ECHOTEST_NONBLOCK()
196
198
// Packet loss up to 30% tolerated
197
199
if (packets_sent > 0 ) {
198
200
double loss_ratio = 1 - ((double )packets_recv / (double )packets_sent);
199
- printf (" Interface %s, Packets sent: %d, packets received %d, loss ratio %.2lf\r\n " , interface_name[j], packets_sent, packets_recv, loss_ratio);
201
+ tr_info (" Interface %s, Packets sent: %d, packets received %d, loss ratio %.2lf\r\n " , interface_name[j], packets_sent, packets_recv, loss_ratio);
200
202
TEST_ASSERT_DOUBLE_WITHIN (TOLERATED_LOSS_RATIO, EXPECTED_LOSS_RATIO, loss_ratio);
201
203
202
204
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
@@ -209,10 +211,12 @@ void MULTIHOMING_UDPSOCKET_ECHOTEST_NONBLOCK()
209
211
}
210
212
}
211
213
loss_ratio = 1 - ((double )udp_stats[j].recv_bytes / (double )udp_stats[j].sent_bytes );
212
- printf (" Bytes sent: %d, bytes received %d, loss ratio %.2lf\r\n " , udp_stats[j].sent_bytes , udp_stats[j].recv_bytes , loss_ratio);
214
+ tr_info (" Bytes sent: %d, bytes received %d, loss ratio %.2lf\r\n " , udp_stats[j].sent_bytes , udp_stats[j].recv_bytes , loss_ratio);
213
215
TEST_ASSERT_DOUBLE_WITHIN (TOLERATED_LOSS_RATIO, EXPECTED_LOSS_RATIO, loss_ratio);
214
216
215
217
#endif
218
+ } else {
219
+ TEST_FAIL ();
216
220
}
217
221
}
218
222
TEST_ASSERT_EQUAL (NSAPI_ERROR_OK, sock.close ());
0 commit comments