Skip to content

Missing socket greentea tests implementation #9001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions TESTS/netsocket/tcp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,17 @@ Case cases[] = {
Case("TCPSOCKET_CONNECT_INVALID", TCPSOCKET_CONNECT_INVALID),
Case("TCPSOCKET_ECHOTEST_BURST", TCPSOCKET_ECHOTEST_BURST),
Case("TCPSOCKET_ECHOTEST_BURST_NONBLOCK", TCPSOCKET_ECHOTEST_BURST_NONBLOCK),
Case("TCPSOCKET_OPEN_DESTRUCT", TCPSOCKET_OPEN_DESTRUCT),
Case("TCPSOCKET_OPEN_TWICE", TCPSOCKET_OPEN_TWICE),
Case("TCPSOCKET_BIND_PORT", TCPSOCKET_BIND_PORT),
Case("TCPSOCKET_BIND_PORT_FAIL", TCPSOCKET_BIND_PORT_FAIL),
Case("TCPSOCKET_BIND_ADDRESS_PORT", TCPSOCKET_BIND_ADDRESS_PORT),
Case("TCPSOCKET_BIND_ADDRESS_NULL", TCPSOCKET_BIND_ADDRESS_NULL),
Case("TCPSOCKET_BIND_ADDRESS_INVALID", TCPSOCKET_BIND_ADDRESS_INVALID),
Case("TCPSOCKET_BIND_ADDRESS", TCPSOCKET_BIND_ADDRESS),
Case("TCPSOCKET_BIND_WRONG_TYPE", TCPSOCKET_BIND_WRONG_TYPE),
Case("TCPSOCKET_BIND_UNOPENED", TCPSOCKET_BIND_UNOPENED),
Case("TCPSOCKET_SETSOCKOPT_KEEPALIVE_VALID", TCPSOCKET_SETSOCKOPT_KEEPALIVE_VALID)
Case("TCPSOCKET_RECV_100K", TCPSOCKET_RECV_100K),
Case("TCPSOCKET_RECV_100K_NONBLOCK", TCPSOCKET_RECV_100K_NONBLOCK),
Case("TCPSOCKET_RECV_TIMEOUT", TCPSOCKET_RECV_TIMEOUT),
Expand Down
11 changes: 11 additions & 0 deletions TESTS/netsocket/tcp/tcp_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,24 @@ void TCPSOCKET_ECHOTEST_NONBLOCK();
void TCPSOCKET_ECHOTEST_BURST();
void TCPSOCKET_ECHOTEST_BURST_NONBLOCK();
void TCPSOCKET_ENDPOINT_CLOSE();
void TCPSOCKET_OPEN_DESTRUCT();
void TCPSOCKET_OPEN_CLOSE_REPEAT();
void TCPSOCKET_OPEN_LIMIT();
void TCPSOCKET_OPEN_TWICE();
void TCPSOCKET_BIND_PORT();
void TCPSOCKET_BIND_PORT_FAIL();
void TCPSOCKET_BIND_ADDRESS_PORT();
void TCPSOCKET_BIND_ADDRESS_NULL();
void TCPSOCKET_BIND_ADDRESS_INVALID();
void TCPSOCKET_BIND_ADDRESS();
void TCPSOCKET_BIND_WRONG_TYPE();
void TCPSOCKET_BIND_UNOPENED();
void TCPSOCKET_RECV_100K();
void TCPSOCKET_RECV_100K_NONBLOCK();
void TCPSOCKET_RECV_TIMEOUT();
void TCPSOCKET_SEND_REPEAT();
void TCPSOCKET_SEND_TIMEOUT();
void TCPSOCKET_THREAD_PER_SOCKET_SAFETY();
void TCPSOCKET_SETSOCKOPT_KEEPALIVE_VALID();

#endif //TCP_TESTS_H
52 changes: 52 additions & 0 deletions TESTS/netsocket/tcp/tcpsocket_bind_address.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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 "tcp_tests.h"
#include "TCPSocket.h"
#include "unity/unity.h"
#include "utest.h"

using namespace utest::v1;

void TCPSOCKET_BIND_ADDRESS()
{
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
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();
}
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(get_interface()));
SocketAddress sockAddr = SocketAddress(get_interface()->get_ip_address(), 80);
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->bind(sockAddr));

delete sock;

#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
count = fetch_stats();
for (int j = 0; j < count; j++) {
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
}
#endif
}
51 changes: 51 additions & 0 deletions TESTS/netsocket/tcp/tcpsocket_bind_address_invalid.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* 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 "tcp_tests.h"
#include "TCPSocket.h"
#include "unity/unity.h"
#include "utest.h"

using namespace utest::v1;

void TCPSOCKET_BIND_ADDRESS_INVALID()
{
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
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();
}
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(get_interface()));
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, sock->bind("190.2.3.4", 1024));

delete sock;

#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
count = fetch_stats();
for (int j = 0; j < count; j++) {
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
}
#endif
}
51 changes: 51 additions & 0 deletions TESTS/netsocket/tcp/tcpsocket_bind_address_null.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* 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 "tcp_tests.h"
#include "TCPSocket.h"
#include "unity/unity.h"
#include "utest.h"

using namespace utest::v1;

void TCPSOCKET_BIND_ADDRESS_NULL()
{
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
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();
}
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(get_interface()));
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->bind(NULL, 1024));

delete sock;

#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
count = fetch_stats();
for (int j = 0; j < count; j++) {
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
}
#endif
}
51 changes: 51 additions & 0 deletions TESTS/netsocket/tcp/tcpsocket_bind_address_port.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* 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 "tcp_tests.h"
#include "TCPSocket.h"
#include "unity/unity.h"
#include "utest.h"

using namespace utest::v1;

void TCPSOCKET_BIND_ADDRESS_PORT()
{
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
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();
}
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(get_interface()));
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->bind(get_interface()->get_ip_address(), 80));

delete sock;

#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
count = fetch_stats();
for (int j = 0; j < count; j++) {
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
}
#endif
}
51 changes: 51 additions & 0 deletions TESTS/netsocket/tcp/tcpsocket_bind_port.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* 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 "tcp_tests.h"
#include "TCPSocket.h"
#include "unity/unity.h"
#include "utest.h"

using namespace utest::v1;

void TCPSOCKET_BIND_PORT()
{
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
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();
}
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(get_interface()));
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->bind(1024));

delete sock;

#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
count = fetch_stats();
for (int j = 0; j < count; j++) {
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
}
#endif
}
59 changes: 59 additions & 0 deletions TESTS/netsocket/tcp/tcpsocket_bind_port_fail.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* 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 "tcp_tests.h"
#include "TCPSocket.h"
#include "unity/unity.h"
#include "utest.h"

using namespace utest::v1;

void TCPSOCKET_BIND_PORT_FAIL()
{
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
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();
}
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(get_interface()));
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->bind(1024));

TCPSocket *sock2 = new TCPSocket;
if (!sock2) {
TEST_FAIL();
}
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock2->open(get_interface()));
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, sock2->bind(1024));

delete sock;
delete sock2;

#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
count = fetch_stats();
for (int j = 0; j < count; j++) {
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
}
#endif
}
Loading