Adds TCP and UDP test cases

tcpsocket_open_close_repeat
	udpsocket_open_close_repeat
pull/6665/head
Veijo Pesonen 2018-05-07 09:28:47 +03:00 committed by Seppo Takalo
parent c86bf1acd0
commit 38b8865bcc
6 changed files with 80 additions and 0 deletions

View File

@ -93,6 +93,7 @@ void greentea_teardown(const size_t passed, const size_t failed, const failure_t
Case cases[] = {
Case("Echo burst", test_tcpsocket_echotest_burst),
Case("Echo burst non-block", test_tcpsocket_echotest_burst_nonblock),
Case("Reuse a socket", test_tcpsocket_open_close_repeat),
Case("Open at least 4 sockets", test_tcpsocket_open_limit),
Case("Receive 100k from CHARGEN service", test_tcpsocket_recv_100k),
Case("Receive 100k from CHARGEN service non-block", test_tcpsocket_recv_100k_nonblock),

View File

@ -28,6 +28,7 @@ void fill_tx_buffer_ascii(char *buff, size_t len);
void test_tcpsocket_echotest_burst();
void test_tcpsocket_echotest_burst_nonblock();
void test_tcpsocket_endpoint_close();
void test_tcpsocket_open_close_repeat();
void test_tcpsocket_open_limit();
void test_tcpsocket_recv_100k();
void test_tcpsocket_recv_100k_nonblock();

View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 2018, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "greentea-client/test_env.h"
#include "mbed.h"
#include MBED_CONF_APP_HEADER_FILE
#include "tcp_tests.h"
#include "TCPSocket.h"
#include "unity/unity.h"
#include "utest.h"
void test_tcpsocket_open_close_repeat()
{
TCPSocket *sock = new TCPSocket;
if (!sock) {
TEST_FAIL();
}
for (int i = 0; i < 2; i++) {
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(get_interface()));
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->close());
}
delete sock;
}

View File

@ -80,6 +80,7 @@ void greentea_teardown(const size_t passed, const size_t failed, const failure_t
Case cases[] = {
Case("Echo burst", test_udpsocket_echotest_burst),
Case("Echo burst non-block", test_udpsocket_echotest_burst_nonblock),
Case("Reuse a socket", test_udpsocket_open_close_repeat),
Case("Open at least 3 sockets", test_udpsocket_open_limit),
Case("Receive in given time", test_udpsocket_recv_timeout),
Case("Send in given time", test_udpsocket_sendto_timeout),

View File

@ -26,6 +26,7 @@ void fill_tx_buffer_ascii(char *buff, size_t len);
*/
void test_udpsocket_echotest_burst();
void test_udpsocket_echotest_burst_nonblock();
void test_udpsocket_open_close_repeat();
void test_udpsocket_open_limit();
void test_udpsocket_recv_timeout();
void test_udpsocket_sendto_timeout();

View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 2018, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "greentea-client/test_env.h"
#include "mbed.h"
#include MBED_CONF_APP_HEADER_FILE
#include "udp_tests.h"
#include "UDPSocket.h"
#include "unity/unity.h"
#include "utest.h"
void test_udpsocket_open_close_repeat()
{
UDPSocket *sock = new UDPSocket;
if (!sock) {
TEST_FAIL();
}
for (int i = 0; i < 2; i++) {
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(get_interface()));
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->close());
}
delete sock;
}