Skip to content

Commit 1d6985b

Browse files
Adjustment of netsocket tests to the lossy mesh network limitation.
1 parent ef4fe98 commit 1d6985b

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+
#if MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == MESH
169+
uint8_t addr_hex[16];
170+
stoip6(address, strlen(address), addr_hex);
171+
if ((addr_hex[0] & 0xe0) != 0x20) {
172+
printf("Address is not global Please check Border Router TEST SKIP \n");
173+
GREENTEA_TESTSUITE_RESULT(false);
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+
#if MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == MESH
80+
uint8_t addr_hex[16];
81+
stoip6(address, strlen(address), addr_hex);
82+
if ((addr_hex[0] & 0xe0) != 0x20) {
83+
printf("Address is not global Please check Border Router TEST SKIP \n");
84+
GREENTEA_TESTSUITE_RESULT(false);
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
@@ -28,6 +28,7 @@
2828
#include "utest/utest_stack_trace.h"
2929
#include "tls_tests.h"
3030
#include "cert.h"
31+
#include "ip6string.h"
3132

3233
#ifndef ECHO_SERVER_ADDR
3334
#error [NOT_SUPPORTED] Requires parameters for echo server
@@ -66,7 +67,17 @@ static void _ifup()
6667
NetworkInterface *net = NetworkInterface::get_default_instance();
6768
nsapi_error_t err = net->connect();
6869
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, err);
69-
printf("MBED: TLSClient IP address is '%s'\n", net->get_ip_address() ? net->get_ip_address() : "null");
70+
const char *address = net->get_ip_address();
71+
72+
printf("MBED: TLSClient IP address is '%s'\n", address ? address : "null");
73+
#if MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == MESH
74+
uint8_t addr_hex[16];
75+
stoip6(address, strlen(address), addr_hex);
76+
if ((addr_hex[0] & 0xe0) != 0x20) {
77+
printf("Address is not global Please check Border Router TEST SKIP \n");
78+
GREENTEA_TESTSUITE_RESULT(false);
79+
}
80+
#endif
7081
}
7182

7283
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+
#if MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == MESH
67+
uint8_t addr_hex[16];
68+
stoip6(address, strlen(address), addr_hex);
69+
if ((addr_hex[0] & 0xe0) != 0x20) {
70+
printf("Address is not global Please check Border Router TEST SKIP \n");
71+
GREENTEA_TESTSUITE_RESULT(false);
72+
}
73+
#endif
6374
}
6475

6576
static void _ifdown()

0 commit comments

Comments
 (0)