mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #9794 from michalpasztamobica/greentea_tcpsocket_sigio
Refactor tcpsocket tests to use sigio and not to waitpull/9849/head
commit
b08ddaad8b
|
@ -100,27 +100,26 @@ void tcpsocket_echotest_nonblock_receive()
|
|||
int recvd = sock.recv(&(tcp_global::rx_buffer[bytes2recv_total - bytes2recv]), bytes2recv);
|
||||
if (recvd == NSAPI_ERROR_WOULD_BLOCK) {
|
||||
if (tc_exec_time.read() >= time_allotted) {
|
||||
TEST_FAIL();
|
||||
TEST_FAIL_MESSAGE("time_allotted exceeded");
|
||||
receive_error = true;
|
||||
tx_sem.release();
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
return;
|
||||
} else if (recvd < 0) {
|
||||
printf("sock.recv returned an error %d", recvd);
|
||||
TEST_FAIL();
|
||||
receive_error = true;
|
||||
tx_sem.release();
|
||||
return;
|
||||
} else {
|
||||
bytes2recv -= recvd;
|
||||
}
|
||||
|
||||
bytes2recv -= recvd;
|
||||
if (!bytes2recv) {
|
||||
if (bytes2recv == 0) {
|
||||
TEST_ASSERT_EQUAL(0, memcmp(tcp_global::tx_buffer, tcp_global::rx_buffer, bytes2recv_total));
|
||||
static int round = 0;
|
||||
printf("[Recevr#%02d] bytes received: %d\n", round++, bytes2recv_total);
|
||||
tx_sem.release();
|
||||
break;
|
||||
} else if (receive_error || bytes2recv < 0) {
|
||||
TEST_FAIL();
|
||||
tx_sem.release();
|
||||
}
|
||||
// else - no error, not all bytes were received yet.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -180,7 +179,6 @@ void TCPSOCKET_ECHOTEST_NONBLOCK()
|
|||
}
|
||||
bytes2send -= sent;
|
||||
}
|
||||
printf("[Sender#%02d] bytes sent: %d\n", s_idx, pkt_s);
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
count = fetch_stats();
|
||||
for (j = 0; j < count; j++) {
|
||||
|
|
|
@ -102,29 +102,31 @@ void TLSSOCKET_ECHOTEST()
|
|||
|
||||
void tlssocket_echotest_nonblock_receive()
|
||||
{
|
||||
int recvd = sock->recv(&(tls_global::rx_buffer[bytes2recv_total - bytes2recv]), bytes2recv);
|
||||
if (recvd == NSAPI_ERROR_WOULD_BLOCK) {
|
||||
if (tc_exec_time.read() >= time_allotted) {
|
||||
while (bytes2recv > 0) {
|
||||
int recvd = sock->recv(&(tls_global::rx_buffer[bytes2recv_total - bytes2recv]), bytes2recv);
|
||||
if (recvd == NSAPI_ERROR_WOULD_BLOCK) {
|
||||
if (tc_exec_time.read() >= time_allotted) {
|
||||
TEST_FAIL_MESSAGE("time_allotted exceeded");
|
||||
receive_error = true;
|
||||
}
|
||||
return;
|
||||
} else if (recvd < 0) {
|
||||
printf("sock.recv returned an error %d", recvd);
|
||||
TEST_FAIL();
|
||||
receive_error = true;
|
||||
} else {
|
||||
bytes2recv -= recvd;
|
||||
}
|
||||
return;
|
||||
} else if (recvd < 0) {
|
||||
receive_error = true;
|
||||
} else {
|
||||
bytes2recv -= recvd;
|
||||
}
|
||||
|
||||
if (bytes2recv == 0) {
|
||||
TEST_ASSERT_EQUAL(0, memcmp(tls_global::tx_buffer, tls_global::rx_buffer, bytes2recv_total));
|
||||
|
||||
static int round = 0;
|
||||
printf("[Recevr#%02d] bytes received: %d\n", round++, bytes2recv_total);
|
||||
tx_sem.release();
|
||||
} else if (receive_error || bytes2recv < 0) {
|
||||
TEST_FAIL();
|
||||
tx_sem.release();
|
||||
if (bytes2recv == 0) {
|
||||
TEST_ASSERT_EQUAL(0, memcmp(tls_global::tx_buffer, tls_global::rx_buffer, bytes2recv_total));
|
||||
tx_sem.release();
|
||||
} else if (receive_error || bytes2recv < 0) {
|
||||
TEST_FAIL();
|
||||
tx_sem.release();
|
||||
}
|
||||
// else - no error, not all bytes were received yet.
|
||||
}
|
||||
// else - no error, not all bytes were received yet.
|
||||
}
|
||||
|
||||
void TLSSOCKET_ECHOTEST_NONBLOCK()
|
||||
|
@ -177,13 +179,11 @@ void TLSSOCKET_ECHOTEST_NONBLOCK()
|
|||
continue;
|
||||
} else if (sent <= 0) {
|
||||
printf("[Sender#%02d] network error %d\n", s_idx, sent);
|
||||
|
||||
TEST_FAIL();
|
||||
goto END;
|
||||
}
|
||||
bytes2send -= sent;
|
||||
}
|
||||
printf("[Sender#%02d] bytes sent: %d\n", s_idx, pkt_s);
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
count = fetch_stats();
|
||||
for (j = 0; j < count; j++) {
|
||||
|
|
Loading…
Reference in New Issue