@@ -102,29 +102,31 @@ void TLSSOCKET_ECHOTEST()
102
102
103
103
void tlssocket_echotest_nonblock_receive ()
104
104
{
105
- int recvd = sock->recv (&(tls_global::rx_buffer[bytes2recv_total - bytes2recv]), bytes2recv);
106
- if (recvd == NSAPI_ERROR_WOULD_BLOCK) {
107
- if (tc_exec_time.read () >= time_allotted) {
105
+ while (bytes2recv > 0 ) {
106
+ int recvd = sock->recv (&(tls_global::rx_buffer[bytes2recv_total - bytes2recv]), bytes2recv);
107
+ if (recvd == NSAPI_ERROR_WOULD_BLOCK) {
108
+ if (tc_exec_time.read () >= time_allotted) {
109
+ TEST_FAIL_MESSAGE (" time_allotted exceeded" );
110
+ receive_error = true ;
111
+ }
112
+ return ;
113
+ } else if (recvd < 0 ) {
114
+ printf (" sock.recv returned an error %d" , recvd);
115
+ TEST_FAIL ();
108
116
receive_error = true ;
117
+ } else {
118
+ bytes2recv -= recvd;
109
119
}
110
- return ;
111
- } else if (recvd < 0 ) {
112
- receive_error = true ;
113
- } else {
114
- bytes2recv -= recvd;
115
- }
116
120
117
- if (bytes2recv == 0 ) {
118
- TEST_ASSERT_EQUAL (0 , memcmp (tls_global::tx_buffer, tls_global::rx_buffer, bytes2recv_total));
119
-
120
- static int round = 0 ;
121
- printf (" [Recevr#%02d] bytes received: %d\n " , round++, bytes2recv_total);
122
- tx_sem.release ();
123
- } else if (receive_error || bytes2recv < 0 ) {
124
- TEST_FAIL ();
125
- tx_sem.release ();
121
+ if (bytes2recv == 0 ) {
122
+ TEST_ASSERT_EQUAL (0 , memcmp (tls_global::tx_buffer, tls_global::rx_buffer, bytes2recv_total));
123
+ tx_sem.release ();
124
+ } else if (receive_error || bytes2recv < 0 ) {
125
+ TEST_FAIL ();
126
+ tx_sem.release ();
127
+ }
128
+ // else - no error, not all bytes were received yet.
126
129
}
127
- // else - no error, not all bytes were received yet.
128
130
}
129
131
130
132
void TLSSOCKET_ECHOTEST_NONBLOCK ()
@@ -177,13 +179,11 @@ void TLSSOCKET_ECHOTEST_NONBLOCK()
177
179
continue ;
178
180
} else if (sent <= 0 ) {
179
181
printf (" [Sender#%02d] network error %d\n " , s_idx, sent);
180
-
181
182
TEST_FAIL ();
182
183
goto END;
183
184
}
184
185
bytes2send -= sent;
185
186
}
186
- printf (" [Sender#%02d] bytes sent: %d\n " , s_idx, pkt_s);
187
187
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
188
188
count = fetch_stats ();
189
189
for (j = 0 ; j < count; j++) {
0 commit comments