Skip to content

Commit b6b4519

Browse files
Adjustment of netsocket tests to the lossy mesh network limitation.
1 parent 0d26be4 commit b6b4519

File tree

4 files changed

+49
-4
lines changed

4 files changed

+49
-4
lines changed

TESTS/netsocket/dns/main.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "nsapi_dns.h"
2929
#include "events/EventQueue.h"
3030
#include "dns_tests.h"
31+
#include "ip6string.h"
3132

3233
using namespace utest::v1;
3334

@@ -161,7 +162,18 @@ static void net_bringup()
161162
net = NetworkInterface::get_default_instance();
162163
nsapi_error_t err = net->connect();
163164
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, err);
164-
printf("MBED: IP address is '%s'\n", net->get_ip_address() ? net->get_ip_address() : "null");
165+
const char *address = net->get_ip_address();
166+
167+
printf("MBED: IP address is '%s'\n", address ? address : "null");
168+
#define MESH 3
169+
#if MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == MESH
170+
uint8_t addr_hex[16];
171+
stoip6(address, strlen(address), addr_hex);
172+
if ((addr_hex[0] & 0xe0) != 0x20) {
173+
TEST_SKIP_MESSAGE("Mesh not working");
174+
}
175+
#endif
176+
165177
}
166178

167179
static void net_bringdown()

TESTS/netsocket/tcp/main.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "utest.h"
2828
#include "utest/utest_stack_trace.h"
2929
#include "tcp_tests.h"
30+
#include "ip6string.h"
3031

3132
#ifndef ECHO_SERVER_ADDR
3233
#error [NOT_SUPPORTED] Requires parameters for echo server
@@ -72,7 +73,17 @@ static void _ifup()
7273
NetworkInterface *net = NetworkInterface::get_default_instance();
7374
nsapi_error_t err = net->connect();
7475
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, err);
75-
printf("MBED: TCPClient IP address is '%s'\n", net->get_ip_address() ? net->get_ip_address() : "null");
76+
const char *address = net->get_ip_address();
77+
78+
printf("MBED: TCPClient IP address is '%s'\n", address ? address : "null");
79+
#define MESH 3
80+
#if MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == MESH
81+
uint8_t addr_hex[16];
82+
stoip6(address, strlen(address), addr_hex);
83+
if ((addr_hex[0] & 0xe0) != 0x20) {
84+
TEST_SKIP_MESSAGE("Mesh not working");
85+
}
86+
#endif
7687
}
7788

7889
static void _ifdown()

TESTS/netsocket/tls/main.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "tls_tests.h"
3030
#include "cert.h"
3131
#include "CellularDevice.h"
32+
#include "ip6string.h"
3233

3334
#ifndef ECHO_SERVER_ADDR
3435
#error [NOT_SUPPORTED] Requires parameters for echo server
@@ -67,7 +68,17 @@ static void _ifup()
6768
NetworkInterface *net = NetworkInterface::get_default_instance();
6869
nsapi_error_t err = net->connect();
6970
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, err);
70-
printf("MBED: TLSClient IP address is '%s'\n", net->get_ip_address() ? net->get_ip_address() : "null");
71+
const char *address = net->get_ip_address();
72+
73+
printf("MBED: TLSClient IP address is '%s'\n", address ? address : "null");
74+
#define MESH 3
75+
#if MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == MESH
76+
uint8_t addr_hex[16];
77+
stoip6(address, strlen(address), addr_hex);
78+
if ((addr_hex[0] & 0xe0) != 0x20) {
79+
TEST_SKIP_MESSAGE("Mesh not working");
80+
}
81+
#endif
7182
}
7283

7384
static void _ifdown()

TESTS/netsocket/udp/main.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "utest.h"
2828
#include "utest/utest_stack_trace.h"
2929
#include "udp_tests.h"
30+
#include "ip6string.h"
3031

3132
#ifndef ECHO_SERVER_ADDR
3233
#error [NOT_SUPPORTED] Requires parameters for echo server
@@ -59,7 +60,17 @@ static void _ifup()
5960
NetworkInterface *net = NetworkInterface::get_default_instance();
6061
nsapi_error_t err = net->connect();
6162
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, err);
62-
printf("MBED: UDPClient IP address is '%s'\n", net->get_ip_address() ? net->get_ip_address() : "null");
63+
const char *address = net->get_ip_address();
64+
65+
printf("MBED: UDPClient IP address is '%s'\n", address ? address : "null");
66+
#define MESH 3
67+
#if MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == MESH
68+
uint8_t addr_hex[16];
69+
stoip6(address, strlen(address), addr_hex);
70+
if ((addr_hex[0] & 0xe0) != 0x20) {
71+
TEST_SKIP_MESSAGE("Mesh not working");
72+
}
73+
#endif
6374
}
6475

6576
static void _ifdown()

0 commit comments

Comments
 (0)