mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #9905 from michalpasztamobica/test_recv_return_less_or_equal
Tests: check if recv returned too much datapull/10086/head
commit
91b81c65fb
|
@ -86,6 +86,8 @@ void TCPSOCKET_ECHOTEST()
|
|||
TEST_FAIL();
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.close());
|
||||
return;
|
||||
} else if (recvd > bytes2recv) {
|
||||
TEST_FAIL_MESSAGE("sock.recv returned more bytes than requested");
|
||||
}
|
||||
bytes2recv -= recvd;
|
||||
}
|
||||
|
|
|
@ -73,6 +73,8 @@ void TCPSOCKET_ECHOTEST_BURST()
|
|||
if (recvd < 0) {
|
||||
printf("[%02d] network error %d\n", i, recvd);
|
||||
break;
|
||||
} else if (recvd > bt_left) {
|
||||
TEST_FAIL_MESSAGE("sock.recv returned more bytes than requested");
|
||||
}
|
||||
bt_left -= recvd;
|
||||
}
|
||||
|
|
|
@ -145,6 +145,9 @@ void rcv_n_chk_against_rfc864_pattern_nonblock(TCPSocket &sock)
|
|||
int rd = sock.recv(buff, buff_size);
|
||||
TEST_ASSERT(rd > 0 || rd == NSAPI_ERROR_WOULD_BLOCK);
|
||||
if (rd > 0) {
|
||||
if (rd > buff_size) {
|
||||
TEST_FAIL_MESSAGE("sock.recv returned more than requested.");
|
||||
}
|
||||
check_RFC_864_pattern(buff, rd, recvd_size);
|
||||
recvd_size += rd;
|
||||
} else if (rd == NSAPI_ERROR_WOULD_BLOCK) {
|
||||
|
|
|
@ -91,6 +91,8 @@ void TLSSOCKET_ECHOTEST()
|
|||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->close());
|
||||
delete sock;
|
||||
return;
|
||||
} else if (recvd > bytes2recv) {
|
||||
TEST_FAIL_MESSAGE("sock.recv returned more bytes than requested");
|
||||
}
|
||||
bytes2recv -= recvd;
|
||||
}
|
||||
|
|
|
@ -75,6 +75,8 @@ void TLSSOCKET_ECHOTEST_BURST()
|
|||
if (recvd < 0) {
|
||||
printf("[%02d] network error %d\n", i, recvd);
|
||||
break;
|
||||
} else if (recvd > bt_left) {
|
||||
TEST_FAIL_MESSAGE("sock.recv returned more bytes than requested");
|
||||
}
|
||||
bt_left -= recvd;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue