Replace TEST_ASSERT_INT_WITHIN usage in netsocket tests

IPCore's netsocket tests are expected to run all tests even if some of them fail. The TEST_ASSERT_INT_WITHIN macro sets a global variable Unity.CurrentTestFailed which prevents further checks and gives incorrect failure count. Other assertion macros in Unity do not do that.
pull/11289/head
Michal Paszta 2019-08-22 14:32:59 +03:00
parent 0c18a7721e
commit 05e94afca3
3 changed files with 14 additions and 5 deletions

View File

@ -67,8 +67,13 @@ void TCPSOCKET_RECV_TIMEOUT()
TEST_FAIL();
goto CLEANUP;
}
printf("MBED: recv() took: %dus\n", timer.read_us());
TEST_ASSERT_INT_WITHIN(51, 150, (timer.read_us() + 500) / 1000);
int recv_time_ms = (timer.read_us() + 500) / 1000;
printf("MBED: recv() took: %dus\n", recv_time_ms);
if (recv_time_ms > 150) {
TEST_ASSERT(150 - recv_time_ms < 51);
} else {
TEST_ASSERT(recv_time_ms - 150 < 51);
}
continue;
} else if (recvd < 0) {
printf("[pkt#%02d] network error %d\n", i, recvd);

View File

@ -146,7 +146,7 @@ void UDPSOCKET_ECHOTEST_BURST()
// Packet loss up to 30% tolerated
TEST_ASSERT_DOUBLE_WITHIN(TOLERATED_LOSS_RATIO, EXPECTED_LOSS_RATIO, loss_ratio);
// 70% of the bursts need to be successful
TEST_ASSERT_INT_WITHIN(3 * (BURST_CNT / 10), BURST_CNT, ok_bursts);
TEST_ASSERT(BURST_CNT - ok_bursts < 3 * (BURST_CNT / 10));
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.close());
}
@ -229,7 +229,7 @@ PKT_OK:
// Packet loss up to 30% tolerated
TEST_ASSERT_DOUBLE_WITHIN(TOLERATED_LOSS_RATIO, EXPECTED_LOSS_RATIO, loss_ratio);
// 70% of the bursts need to be successful
TEST_ASSERT_INT_WITHIN(3 * (BURST_CNT / 10), BURST_CNT, ok_bursts);
TEST_ASSERT(BURST_CNT - ok_bursts < 3 * (BURST_CNT / 10));
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.close());
}

View File

@ -63,7 +63,11 @@ void UDPSOCKET_RECV_TIMEOUT()
if (recvd == NSAPI_ERROR_WOULD_BLOCK) {
osSignalWait(SIGNAL_SIGIO, SIGIO_TIMEOUT);
printf("MBED: recvfrom() took: %dms\n", timer.read_ms());
TEST_ASSERT_INT_WITHIN(51, 150, timer.read_ms());
if (timer.read_ms() > 150) {
TEST_ASSERT(150 - timer.read_ms() < 51);
} else {
TEST_ASSERT(timer.read_ms() - 150 < 51);
}
continue;
} else if (recvd < 0) {
printf("[bt#%02d] network error %d\n", i, recvd);