@@ -84,7 +84,7 @@ void MULTIHOMING_UDPSOCKET_ECHOTEST()
8484 packets_sent++;
8585 }
8686 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);
8888 continue ;
8989 }
9090 recvd = sock.recvfrom (NULL , rx_buffer, pkt_s);
@@ -99,8 +99,10 @@ void MULTIHOMING_UDPSOCKET_ECHOTEST()
9999 // Packet loss up to 30% tolerated
100100 if (packets_sent > 0 ) {
101101 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);
103103 TEST_ASSERT_DOUBLE_WITHIN (TOLERATED_LOSS_RATIO, EXPECTED_LOSS_RATIO, loss_ratio);
104+ } else {
105+ TEST_FAIL ();
104106 }
105107 }
106108 TEST_ASSERT_EQUAL (NSAPI_ERROR_OK, sock.close ());
@@ -177,7 +179,7 @@ void MULTIHOMING_UDPSOCKET_ECHOTEST_NONBLOCK()
177179 }
178180 --retry_cnt;
179181 } 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);
181183 continue ;
182184 }
183185 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()
196198 // Packet loss up to 30% tolerated
197199 if (packets_sent > 0 ) {
198200 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);
200202 TEST_ASSERT_DOUBLE_WITHIN (TOLERATED_LOSS_RATIO, EXPECTED_LOSS_RATIO, loss_ratio);
201203
202204#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
@@ -209,10 +211,12 @@ void MULTIHOMING_UDPSOCKET_ECHOTEST_NONBLOCK()
209211 }
210212 }
211213 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);
213215 TEST_ASSERT_DOUBLE_WITHIN (TOLERATED_LOSS_RATIO, EXPECTED_LOSS_RATIO, loss_ratio);
214216
215217#endif
218+ } else {
219+ TEST_FAIL ();
216220 }
217221 }
218222 TEST_ASSERT_EQUAL (NSAPI_ERROR_OK, sock.close ());
0 commit comments