Skip to content

Commit 0f6a835

Browse files
authored
Merge pull request #10037 from michalpasztamobica/tcp_skip_if_unsupported
TCP/TLS Socket tests will skip if TCP is not supported
2 parents 8e819de + 09183c9 commit 0f6a835

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+76
-0
lines changed

TESTS/netsocket/tcp/main.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,17 @@ nsapi_error_t tcpsocket_connect_to_discard_srv(TCPSocket &sock)
114114
return tcpsocket_connect_to_srv(sock, MBED_CONF_APP_ECHO_SERVER_DISCARD_PORT);
115115
}
116116

117+
bool is_tcp_supported()
118+
{
119+
static bool supported;
120+
static bool tested = false;
121+
if (!tested) {
122+
TCPSocket socket;
123+
supported = socket.open(NetworkInterface::get_default_instance()) == NSAPI_ERROR_OK;
124+
}
125+
return supported;
126+
}
127+
117128
void fill_tx_buffer_ascii(char *buff, size_t len)
118129
{
119130
for (size_t i = 0; i < len; ++i) {

TESTS/netsocket/tcp/tcp_tests.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ nsapi_version_t get_ip_version();
2424
void fill_tx_buffer_ascii(char *buff, size_t len);
2525
nsapi_error_t tcpsocket_connect_to_echo_srv(TCPSocket &sock);
2626
nsapi_error_t tcpsocket_connect_to_discard_srv(TCPSocket &sock);
27+
bool is_tcp_supported();
28+
29+
#define SKIP_IF_TCP_UNSUPPORTED() \
30+
if (!is_tcp_supported()) { \
31+
TEST_SKIP_MESSAGE("TCP not supported"); \
32+
}
2733

2834
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
2935
extern mbed_stats_socket_t tcp_stats[MBED_CONF_NSAPI_SOCKET_STATS_MAX_COUNT];

TESTS/netsocket/tcp/tcpsocket_bind_address.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ using namespace utest::v1;
2626

2727
void TCPSOCKET_BIND_ADDRESS()
2828
{
29+
SKIP_IF_TCP_UNSUPPORTED();
2930
TCPSocket *sock = new TCPSocket;
3031
if (!sock) {
3132
TEST_FAIL();

TESTS/netsocket/tcp/tcpsocket_bind_address_invalid.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ using namespace utest::v1;
2626

2727
void TCPSOCKET_BIND_ADDRESS_INVALID()
2828
{
29+
SKIP_IF_TCP_UNSUPPORTED();
2930
TCPSocket *sock = new TCPSocket;
3031
if (!sock) {
3132
TEST_FAIL();

TESTS/netsocket/tcp/tcpsocket_bind_address_null.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ using namespace utest::v1;
2626

2727
void TCPSOCKET_BIND_ADDRESS_NULL()
2828
{
29+
SKIP_IF_TCP_UNSUPPORTED();
2930
TCPSocket *sock = new TCPSocket;
3031
if (!sock) {
3132
TEST_FAIL();

TESTS/netsocket/tcp/tcpsocket_bind_address_port.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ using namespace utest::v1;
2626

2727
void TCPSOCKET_BIND_ADDRESS_PORT()
2828
{
29+
SKIP_IF_TCP_UNSUPPORTED();
2930
TCPSocket *sock = new TCPSocket;
3031
if (!sock) {
3132
TEST_FAIL();

TESTS/netsocket/tcp/tcpsocket_bind_port.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ using namespace utest::v1;
2626

2727
void TCPSOCKET_BIND_PORT()
2828
{
29+
SKIP_IF_TCP_UNSUPPORTED();
2930
TCPSocket *sock = new TCPSocket;
3031
if (!sock) {
3132
TEST_FAIL();

TESTS/netsocket/tcp/tcpsocket_bind_port_fail.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ using namespace utest::v1;
2626

2727
void TCPSOCKET_BIND_PORT_FAIL()
2828
{
29+
SKIP_IF_TCP_UNSUPPORTED();
2930
TCPSocket *sock = new TCPSocket;
3031
if (!sock) {
3132
TEST_FAIL();

TESTS/netsocket/tcp/tcpsocket_bind_unopened.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ using namespace utest::v1;
2626

2727
void TCPSOCKET_BIND_UNOPENED()
2828
{
29+
SKIP_IF_TCP_UNSUPPORTED();
2930
TCPSocket *sock = new TCPSocket;
3031
if (!sock) {
3132
TEST_FAIL();

TESTS/netsocket/tcp/tcpsocket_bind_wrong_type.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ using namespace utest::v1;
2626

2727
void TCPSOCKET_BIND_WRONG_TYPE()
2828
{
29+
SKIP_IF_TCP_UNSUPPORTED();
2930
TCPSocket *sock = new TCPSocket;
3031
if (!sock) {
3132
TEST_FAIL();

0 commit comments

Comments
 (0)