Skip to content

Commit 1aacaf3

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

File tree

4 files changed

+44
-4
lines changed

4 files changed

+44
-4
lines changed

TESTS/netsocket/dns/main.cpp

Lines changed: 11 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,16 @@ 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+
#define MESH 3
168+
#if MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == MESH
169+
printf("Waiting for GLOBAL_UP\n");
170+
while (net->get_connection_status() != NSAPI_STATUS_GLOBAL_UP) {
171+
ThisThread::sleep_for(500);
172+
}
173+
#endif
174+
printf("MBED: IP address is '%s'\n", address ? address : "null");
165175
}
166176

167177
static void net_bringdown()

TESTS/netsocket/tcp/main.cpp

Lines changed: 11 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,16 @@ 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+
#define MESH 3
79+
#if MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == MESH
80+
printf("Waiting for GLOBAL_UP\n");
81+
while (net->get_connection_status() != NSAPI_STATUS_GLOBAL_UP) {
82+
ThisThread::sleep_for(500);
83+
}
84+
#endif
85+
printf("MBED: TCPClient IP address is '%s'\n", address ? address : "null");
7686
}
7787

7888
static void _ifdown()

TESTS/netsocket/tls/main.cpp

Lines changed: 11 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,16 @@ 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+
#define MESH 3
74+
#if MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == MESH
75+
printf("Waiting for GLOBAL_UP\n");
76+
while (net->get_connection_status() != NSAPI_STATUS_GLOBAL_UP) {
77+
ThisThread::sleep_for(500);
78+
}
79+
#endif
80+
printf("MBED: TLSClient address is '%s'\n", address ? address : "null");
7181
}
7282

7383
static void _ifdown()

TESTS/netsocket/udp/main.cpp

Lines changed: 11 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,16 @@ 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+
#define MESH 3
66+
#if MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == MESH
67+
printf("Waiting for GLOBAL_UP\n");
68+
while (net->get_connection_status() != NSAPI_STATUS_GLOBAL_UP) {
69+
ThisThread::sleep_for(500);
70+
}
71+
#endif
72+
printf("MBED: UDPClient IP address is '%s'\n", address ? address : "null");
6373
}
6474

6575
static void _ifdown()

0 commit comments

Comments
 (0)