Merge pull request #9905 from michalpasztamobica/test_recv_return_less_or_equal

Tests: check if recv returned too much data
pull/10086/head
Martin Kojtal 2019-03-15 14:57:01 +01:00 committed by GitHub
commit 91b81c65fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 0 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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) {

View File

@ -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;
}

View File

@ -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;
}