mirror of https://github.com/ARMmbed/mbed-os.git
Refactor socket stats to reduce bioler plate
Add a proper test case setup and teardown which does the socket stats checks in tcp, udp and tls.pull/9959/head
parent
83d70199d1
commit
b7ed4b5d9e
|
@ -149,6 +149,38 @@ void greentea_teardown(const size_t passed, const size_t failed, const failure_t
|
|||
return greentea_test_teardown_handler(passed, failed, failure);
|
||||
}
|
||||
|
||||
utest::v1::status_t greentea_case_setup_handler_tcp(const Case *const source, const size_t index_of_case)
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
return greentea_case_setup_handler(source, index_of_case);
|
||||
}
|
||||
|
||||
utest::v1::status_t greentea_case_teardown_handler_tcp(const Case *const source, const size_t passed, const size_t failed, const failure_t failure)
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
return greentea_case_teardown_handler(source, passed, failed, failure);
|
||||
}
|
||||
|
||||
static void test_failure_handler(const failure_t failure)
|
||||
{
|
||||
UTEST_LOG_FUNCTION();
|
||||
if (failure.location == LOCATION_TEST_SETUP || failure.location == LOCATION_TEST_TEARDOWN) {
|
||||
verbose_test_failure_handler(failure);
|
||||
GREENTEA_TESTSUITE_RESULT(false);
|
||||
while (1) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Case cases[] = {
|
||||
Case("TCPSOCKET_ECHOTEST", TCPSOCKET_ECHOTEST),
|
||||
|
@ -178,7 +210,16 @@ Case cases[] = {
|
|||
Case("TCPSOCKET_ENDPOINT_CLOSE", TCPSOCKET_ENDPOINT_CLOSE),
|
||||
};
|
||||
|
||||
Specification specification(greentea_setup, cases, greentea_teardown, greentea_continue_handlers);
|
||||
handlers_t tcp_test_case_handlers = {
|
||||
default_greentea_test_setup_handler,
|
||||
greentea_test_teardown_handler,
|
||||
test_failure_handler,
|
||||
greentea_case_setup_handler_tcp,
|
||||
greentea_case_teardown_handler_tcp,
|
||||
greentea_case_failure_continue_handler
|
||||
};
|
||||
|
||||
Specification specification(greentea_setup, cases, greentea_teardown, tcp_test_case_handlers);
|
||||
|
||||
int main()
|
||||
{
|
||||
|
|
|
@ -26,13 +26,6 @@ using namespace utest::v1;
|
|||
|
||||
void TCPSOCKET_BIND_ADDRESS()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
TCPSocket *sock = new TCPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
|
@ -48,11 +41,4 @@ void TCPSOCKET_BIND_ADDRESS()
|
|||
}
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -26,13 +26,6 @@ using namespace utest::v1;
|
|||
|
||||
void TCPSOCKET_BIND_ADDRESS_INVALID()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
TCPSocket *sock = new TCPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
|
@ -54,11 +47,4 @@ void TCPSOCKET_BIND_ADDRESS_INVALID()
|
|||
}
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -26,13 +26,6 @@ using namespace utest::v1;
|
|||
|
||||
void TCPSOCKET_BIND_ADDRESS_NULL()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
TCPSocket *sock = new TCPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
|
@ -47,11 +40,4 @@ void TCPSOCKET_BIND_ADDRESS_NULL()
|
|||
}
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -26,13 +26,6 @@ using namespace utest::v1;
|
|||
|
||||
void TCPSOCKET_BIND_ADDRESS_PORT()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
TCPSocket *sock = new TCPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
|
@ -47,11 +40,4 @@ void TCPSOCKET_BIND_ADDRESS_PORT()
|
|||
}
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -26,13 +26,6 @@ using namespace utest::v1;
|
|||
|
||||
void TCPSOCKET_BIND_PORT()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
TCPSocket *sock = new TCPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
|
@ -47,11 +40,4 @@ void TCPSOCKET_BIND_PORT()
|
|||
}
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -26,13 +26,6 @@ using namespace utest::v1;
|
|||
|
||||
void TCPSOCKET_BIND_PORT_FAIL()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
TCPSocket *sock = new TCPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
|
@ -57,11 +50,4 @@ void TCPSOCKET_BIND_PORT_FAIL()
|
|||
|
||||
delete sock;
|
||||
delete sock2;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -26,13 +26,6 @@ using namespace utest::v1;
|
|||
|
||||
void TCPSOCKET_BIND_UNOPENED()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
TCPSocket *sock = new TCPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
|
@ -46,11 +39,4 @@ void TCPSOCKET_BIND_UNOPENED()
|
|||
}
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -26,13 +26,6 @@ using namespace utest::v1;
|
|||
|
||||
void TCPSOCKET_BIND_WRONG_TYPE()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
TCPSocket *sock = new TCPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
|
@ -56,11 +49,4 @@ void TCPSOCKET_BIND_WRONG_TYPE()
|
|||
}
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -125,13 +125,6 @@ void tcpsocket_echotest_nonblock_receive()
|
|||
|
||||
void TCPSOCKET_ECHOTEST_NONBLOCK()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int j = 0;
|
||||
int count = fetch_stats();
|
||||
for (; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
tc_exec_time.start();
|
||||
time_allotted = split2half_rmng_tcp_test_time(); // [s]
|
||||
|
||||
|
@ -180,7 +173,8 @@ void TCPSOCKET_ECHOTEST_NONBLOCK()
|
|||
bytes2send -= sent;
|
||||
}
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
count = fetch_stats();
|
||||
int count = fetch_stats();
|
||||
int j;
|
||||
for (j = 0; j < count; j++) {
|
||||
if ((tcp_stats[j].state == SOCK_OPEN) && (tcp_stats[j].proto == NSAPI_TCP)) {
|
||||
break;
|
||||
|
|
|
@ -26,12 +26,6 @@ using namespace utest::v1;
|
|||
|
||||
void TCPSOCKET_OPEN_CLOSE_REPEAT()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
TCPSocket *sock = new TCPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
|
@ -42,10 +36,4 @@ void TCPSOCKET_OPEN_CLOSE_REPEAT()
|
|||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->close());
|
||||
}
|
||||
delete sock;
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -26,13 +26,6 @@ using namespace utest::v1;
|
|||
|
||||
void TCPSOCKET_OPEN_DESTRUCT()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < 100; i++) {
|
||||
TCPSocket *sock = new TCPSocket;
|
||||
if (!sock) {
|
||||
|
@ -41,10 +34,4 @@ void TCPSOCKET_OPEN_DESTRUCT()
|
|||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(NetworkInterface::get_default_instance()));
|
||||
delete sock;
|
||||
}
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -26,12 +26,6 @@ using namespace utest::v1;
|
|||
|
||||
void TCPSOCKET_OPEN_TWICE()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
TCPSocket *sock = new TCPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
|
@ -41,10 +35,4 @@ void TCPSOCKET_OPEN_TWICE()
|
|||
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, sock->open(NetworkInterface::get_default_instance()));
|
||||
|
||||
delete sock;
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -177,6 +177,38 @@ void greentea_teardown(const size_t passed, const size_t failed, const failure_t
|
|||
return greentea_test_teardown_handler(passed, failed, failure);
|
||||
}
|
||||
|
||||
utest::v1::status_t greentea_case_setup_handler_tls(const Case *const source, const size_t index_of_case)
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tls_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
return greentea_case_setup_handler(source, index_of_case);
|
||||
}
|
||||
|
||||
utest::v1::status_t greentea_case_teardown_handler_tls(const Case *const source, const size_t passed, const size_t failed, const failure_t failure)
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tls_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
return greentea_case_teardown_handler(source, passed, failed, failure);
|
||||
}
|
||||
|
||||
static void test_failure_handler(const failure_t failure)
|
||||
{
|
||||
UTEST_LOG_FUNCTION();
|
||||
if (failure.location == LOCATION_TEST_SETUP || failure.location == LOCATION_TEST_TEARDOWN) {
|
||||
verbose_test_failure_handler(failure);
|
||||
GREENTEA_TESTSUITE_RESULT(false);
|
||||
while (1) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Case cases[] = {
|
||||
Case("TLSSOCKET_ECHOTEST", TLSSOCKET_ECHOTEST),
|
||||
|
@ -203,7 +235,16 @@ Case cases[] = {
|
|||
// Case("TLSSOCKET_SIMULTANEOUS", TLSSOCKET_SIMULTANEOUS)
|
||||
};
|
||||
|
||||
Specification specification(greentea_setup, cases, greentea_teardown, greentea_continue_handlers);
|
||||
const handlers_t tls_test_case_handlers = {
|
||||
default_greentea_test_setup_handler,
|
||||
greentea_test_teardown_handler,
|
||||
test_failure_handler,
|
||||
greentea_case_setup_handler_tls,
|
||||
greentea_case_teardown_handler_tls,
|
||||
greentea_case_failure_continue_handler
|
||||
};
|
||||
|
||||
Specification specification(greentea_setup, cases, greentea_teardown, tls_test_case_handlers);
|
||||
|
||||
int retval;
|
||||
void run_test(void)
|
||||
|
|
|
@ -131,13 +131,6 @@ void tlssocket_echotest_nonblock_receive()
|
|||
|
||||
void TLSSOCKET_ECHOTEST_NONBLOCK()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int j = 0;
|
||||
int count = fetch_stats();
|
||||
for (; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tls_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
sock = new TLSSocket;
|
||||
tc_exec_time.start();
|
||||
time_allotted = split2half_rmng_tls_test_time(); // [s]
|
||||
|
@ -185,9 +178,10 @@ void TLSSOCKET_ECHOTEST_NONBLOCK()
|
|||
bytes2send -= sent;
|
||||
}
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
count = fetch_stats();
|
||||
for (j = 0; j < count; j++) {
|
||||
if ((tls_stats[j].state == SOCK_OPEN) && (tls_stats[j].proto == NSAPI_TLS)) {
|
||||
int count = fetch_stats();
|
||||
int j = 0;
|
||||
for (; j < count; j++) {
|
||||
if ((tls_stats[j].state == SOCK_OPEN) && (tls_stats[j].proto == NSAPI_TCP)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,13 +28,6 @@ using namespace utest::v1;
|
|||
|
||||
void TLSSOCKET_OPEN_DESTRUCT()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tls_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < 100; i++) {
|
||||
TLSSocket *sock = new TLSSocket;
|
||||
if (!sock) {
|
||||
|
@ -43,12 +36,6 @@ void TLSSOCKET_OPEN_DESTRUCT()
|
|||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(NetworkInterface::get_default_instance()));
|
||||
delete sock;
|
||||
}
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tls_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // defined(MBEDTLS_SSL_CLI_C)
|
||||
|
|
|
@ -76,7 +76,7 @@ void TLSSOCKET_OPEN_LIMIT()
|
|||
int count = fetch_stats();
|
||||
int open_count = 0;
|
||||
for (int j = 0; j < count; j++) {
|
||||
if ((tls_stats[j].state == SOCK_OPEN) && (tls_stats[j].proto == NSAPI_TLS)) {
|
||||
if ((tls_stats[j].state == SOCK_OPEN) && (tls_stats[j].proto == NSAPI_TCP)) {
|
||||
open_count++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,12 +28,6 @@ using namespace utest::v1;
|
|||
|
||||
void TLSSOCKET_OPEN_TWICE()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tls_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
TLSSocket *sock = new TLSSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
|
@ -43,12 +37,6 @@ void TLSSOCKET_OPEN_TWICE()
|
|||
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, sock->open(NetworkInterface::get_default_instance()));
|
||||
|
||||
delete sock;
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tls_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // defined(MBEDTLS_SSL_CLI_C)
|
||||
|
|
|
@ -112,6 +112,38 @@ void greentea_teardown(const size_t passed, const size_t failed, const failure_t
|
|||
return greentea_test_teardown_handler(passed, failed, failure);
|
||||
}
|
||||
|
||||
utest::v1::status_t greentea_case_setup_handler_udp(const Case *const source, const size_t index_of_case)
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
return greentea_case_setup_handler(source, index_of_case);
|
||||
}
|
||||
|
||||
utest::v1::status_t greentea_case_teardown_handler_udp(const Case *const source, const size_t passed, const size_t failed, const failure_t failure)
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
return greentea_case_teardown_handler(source, passed, failed, failure);
|
||||
}
|
||||
|
||||
static void test_failure_handler(const failure_t failure)
|
||||
{
|
||||
UTEST_LOG_FUNCTION();
|
||||
if (failure.location == LOCATION_TEST_SETUP || failure.location == LOCATION_TEST_TEARDOWN) {
|
||||
verbose_test_failure_handler(failure);
|
||||
GREENTEA_TESTSUITE_RESULT(false);
|
||||
while (1) ;
|
||||
}
|
||||
}
|
||||
|
||||
Case cases[] = {
|
||||
Case("UDPSOCKET_OPEN_CLOSE_REPEAT", UDPSOCKET_OPEN_CLOSE_REPEAT),
|
||||
Case("UDPSOCKET_OPEN_LIMIT", UDPSOCKET_OPEN_LIMIT),
|
||||
|
@ -135,7 +167,16 @@ Case cases[] = {
|
|||
Case("UDPSOCKET_ECHOTEST_BURST", UDPSOCKET_ECHOTEST_BURST),
|
||||
};
|
||||
|
||||
Specification specification(greentea_setup, cases, greentea_teardown, greentea_continue_handlers);
|
||||
handlers_t udp_test_case_handlers = {
|
||||
default_greentea_test_setup_handler,
|
||||
greentea_test_teardown_handler,
|
||||
test_failure_handler,
|
||||
greentea_case_setup_handler_udp,
|
||||
greentea_case_teardown_handler_udp,
|
||||
greentea_case_failure_continue_handler
|
||||
};
|
||||
|
||||
Specification specification(greentea_setup, cases, greentea_teardown, udp_test_case_handlers);
|
||||
|
||||
int main()
|
||||
{
|
||||
|
|
|
@ -26,13 +26,6 @@ using namespace utest::v1;
|
|||
|
||||
void UDPSOCKET_BIND_ADDRESS()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
UDPSocket *sock = new UDPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
|
@ -47,11 +40,4 @@ void UDPSOCKET_BIND_ADDRESS()
|
|||
}
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -26,13 +26,6 @@ using namespace utest::v1;
|
|||
|
||||
void UDPSOCKET_BIND_ADDRESS_INVALID()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
UDPSocket *sock = new UDPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
|
@ -55,11 +48,4 @@ void UDPSOCKET_BIND_ADDRESS_INVALID()
|
|||
}
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -26,13 +26,6 @@ using namespace utest::v1;
|
|||
|
||||
void UDPSOCKET_BIND_ADDRESS_NULL()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
UDPSocket *sock = new UDPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
|
@ -46,11 +39,4 @@ void UDPSOCKET_BIND_ADDRESS_NULL()
|
|||
}
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -26,13 +26,6 @@ using namespace utest::v1;
|
|||
|
||||
void UDPSOCKET_BIND_ADDRESS_PORT()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
UDPSocket *sock = new UDPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
|
@ -46,11 +39,4 @@ void UDPSOCKET_BIND_ADDRESS_PORT()
|
|||
}
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -26,13 +26,6 @@ using namespace utest::v1;
|
|||
|
||||
void UDPSOCKET_BIND_PORT()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
UDPSocket *sock = new UDPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
|
@ -46,11 +39,4 @@ void UDPSOCKET_BIND_PORT()
|
|||
}
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -26,13 +26,6 @@ using namespace utest::v1;
|
|||
|
||||
void UDPSOCKET_BIND_PORT_FAIL()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
UDPSocket *sock = new UDPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
|
@ -56,11 +49,4 @@ void UDPSOCKET_BIND_PORT_FAIL()
|
|||
|
||||
delete sock;
|
||||
delete sock2;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -26,13 +26,6 @@ using namespace utest::v1;
|
|||
|
||||
void UDPSOCKET_BIND_UNOPENED()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
UDPSocket *sock = new UDPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
|
@ -45,11 +38,4 @@ void UDPSOCKET_BIND_UNOPENED()
|
|||
}
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -26,13 +26,6 @@ using namespace utest::v1;
|
|||
|
||||
void UDPSOCKET_BIND_WRONG_TYPE()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
UDPSocket *sock = new UDPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
|
@ -55,11 +48,4 @@ void UDPSOCKET_BIND_WRONG_TYPE()
|
|||
}
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -133,13 +133,6 @@ void udpsocket_echotest_nonblock_receiver(void *receive_bytes)
|
|||
|
||||
void UDPSOCKET_ECHOTEST_NONBLOCK()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int j = 0;
|
||||
int count = fetch_stats();
|
||||
for (; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
tc_exec_time.start();
|
||||
time_allotted = split2half_rmng_udp_test_time(); // [s]
|
||||
|
||||
|
@ -205,8 +198,9 @@ void UDPSOCKET_ECHOTEST_NONBLOCK()
|
|||
TEST_ASSERT_DOUBLE_WITHIN(TOLERATED_LOSS_RATIO, EXPECTED_LOSS_RATIO, loss_ratio);
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
count = fetch_stats();
|
||||
for (j = 0; j < count; j++) {
|
||||
int count = fetch_stats();
|
||||
int j = 0;
|
||||
for (; j < count; j++) {
|
||||
if ((NSAPI_UDP == udp_stats[j].proto) && (SOCK_OPEN == udp_stats[j].state)) {
|
||||
TEST_ASSERT(udp_stats[j].sent_bytes != 0);
|
||||
TEST_ASSERT(udp_stats[j].recv_bytes != 0);
|
||||
|
|
|
@ -26,12 +26,6 @@ using namespace utest::v1;
|
|||
|
||||
void UDPSOCKET_OPEN_CLOSE_REPEAT()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
UDPSocket *sock = new UDPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
|
@ -42,10 +36,4 @@ void UDPSOCKET_OPEN_CLOSE_REPEAT()
|
|||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->close());
|
||||
}
|
||||
delete sock;
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -26,13 +26,6 @@ using namespace utest::v1;
|
|||
|
||||
void UDPSOCKET_OPEN_DESTRUCT()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < 100; i++) {
|
||||
UDPSocket *sock = new UDPSocket;
|
||||
if (!sock) {
|
||||
|
@ -41,10 +34,4 @@ void UDPSOCKET_OPEN_DESTRUCT()
|
|||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(NetworkInterface::get_default_instance()));
|
||||
delete sock;
|
||||
}
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -26,12 +26,6 @@ using namespace utest::v1;
|
|||
|
||||
void UDPSOCKET_OPEN_TWICE()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
UDPSocket *sock = new UDPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
|
@ -41,10 +35,4 @@ void UDPSOCKET_OPEN_TWICE()
|
|||
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, sock->open(NetworkInterface::get_default_instance()));
|
||||
|
||||
delete sock;
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue