Skip to content

Commit 5ffcc01

Browse files
author
Cruz Monrreal
authored
Merge pull request #7812 from mikaleppanen/greentea_def_interf
Update greentea tests to use default interface
2 parents 7531b31 + 93eb0c2 commit 5ffcc01

Some content is hidden

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

58 files changed

+161
-473
lines changed

TESTS/netsocket/dns/main.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
* limitations under the License.
1616
*/
1717

18-
#ifndef MBED_CONF_APP_CONNECT_STATEMENT
18+
#define WIFI 2
19+
#if !defined(MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE) || \
20+
(MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == WIFI && !defined(MBED_CONF_NSAPI_DEFAULT_WIFI_SSID))
1921
#error [NOT_SUPPORTED] No network configuration found for this target.
2022
#endif
2123

@@ -27,8 +29,6 @@
2729
#include "EventQueue.h"
2830
#include "dns_tests.h"
2931

30-
#include MBED_CONF_APP_HEADER_FILE
31-
3232
using namespace utest::v1;
3333

3434
namespace {
@@ -116,12 +116,10 @@ static void net_bringup()
116116
{
117117
MBED_ASSERT(MBED_CONF_APP_DNS_TEST_HOSTS_NUM >= MBED_CONF_NSAPI_DNS_CACHE_SIZE && MBED_CONF_APP_DNS_TEST_HOSTS_NUM >= MBED_CONF_APP_DNS_SIMULT_QUERIES + 1);
118118

119-
net = MBED_CONF_APP_OBJECT_CONSTRUCTION;
120-
int err = MBED_CONF_APP_CONNECT_STATEMENT;
121-
TEST_ASSERT_EQUAL(0, err);
122-
123-
printf("MBED: Connected to network\n");
124-
printf("MBED: IP Address: %s\n", net->get_ip_address());
119+
net = NetworkInterface::get_default_instance();
120+
nsapi_error_t err = net->connect();
121+
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, err);
122+
printf("MBED: IP address is '%s'\n", net->get_ip_address());
125123
}
126124

127125
// Test setup

TESTS/netsocket/tcp/main.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515
* limitations under the License.
1616
*/
1717

18-
#ifndef MBED_CONF_APP_CONNECT_STATEMENT
18+
#define WIFI 2
19+
#if !defined(MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE) || \
20+
(MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == WIFI && !defined(MBED_CONF_NSAPI_DEFAULT_WIFI_SSID))
1921
#error [NOT_SUPPORTED] No network configuration found for this target.
2022
#endif
23+
#ifndef MBED_CONF_APP_ECHO_SERVER_ADDR
24+
#error [NOT_SUPPORTED] Requires parameters from mbed_app.json
25+
#endif
2126

2227
#include "mbed.h"
23-
#include MBED_CONF_APP_HEADER_FILE
2428
#include "greentea-client/test_env.h"
2529
#include "unity/unity.h"
2630
#include "utest.h"
@@ -57,8 +61,8 @@ void drop_bad_packets(TCPSocket &sock, int orig_timeout)
5761

5862
static void _ifup()
5963
{
60-
net = MBED_CONF_APP_OBJECT_CONSTRUCTION;
61-
nsapi_error_t err = MBED_CONF_APP_CONNECT_STATEMENT;
64+
net = NetworkInterface::get_default_instance();
65+
nsapi_error_t err = net->connect();
6266
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, err);
6367
printf("MBED: TCPClient IP address is '%s'\n", net->get_ip_address());
6468
}

TESTS/netsocket/tcp/tcpsocket_connect_invalid.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717

1818
#include "mbed.h"
19-
#include MBED_CONF_APP_HEADER_FILE
2019
#include "TCPSocket.h"
2120
#include "greentea-client/test_env.h"
2221
#include "unity/unity.h"

TESTS/netsocket/tcp/tcpsocket_echotest.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717

1818
#include "mbed.h"
19-
#include MBED_CONF_APP_HEADER_FILE
2019
#include "TCPSocket.h"
2120
#include "greentea-client/test_env.h"
2221
#include "unity/unity.h"

TESTS/netsocket/tcp/tcpsocket_echotest_burst.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717

1818
#include "mbed.h"
19-
#include MBED_CONF_APP_HEADER_FILE
2019
#include "TCPSocket.h"
2120
#include "greentea-client/test_env.h"
2221
#include "unity/unity.h"

TESTS/netsocket/tcp/tcpsocket_endpoint_close.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717

1818
#include "mbed.h"
19-
#include MBED_CONF_APP_HEADER_FILE
2019
#include "TCPSocket.h"
2120
#include "greentea-client/test_env.h"
2221
#include "unity/unity.h"

TESTS/netsocket/tcp/tcpsocket_open_close_repeat.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
#include "greentea-client/test_env.h"
1919
#include "mbed.h"
20-
#include MBED_CONF_APP_HEADER_FILE
2120
#include "tcp_tests.h"
2221
#include "TCPSocket.h"
2322
#include "unity/unity.h"

TESTS/netsocket/tcp/tcpsocket_open_limit.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
#include "greentea-client/test_env.h"
1919
#include "mbed.h"
20-
#include MBED_CONF_APP_HEADER_FILE
2120
#include "tcp_tests.h"
2221
#include "TCPSocket.h"
2322
#include "unity/unity.h"

TESTS/netsocket/tcp/tcpsocket_recv_100k.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717

1818
#include "mbed.h"
19-
#include MBED_CONF_APP_HEADER_FILE
2019
#include "TCPSocket.h"
2120
#include "greentea-client/test_env.h"
2221
#include "unity/unity.h"

TESTS/netsocket/tcp/tcpsocket_recv_timeout.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717

1818
#include "mbed.h"
19-
#include MBED_CONF_APP_HEADER_FILE
2019
#include "TCPSocket.h"
2120
#include "greentea-client/test_env.h"
2221
#include "unity/unity.h"

TESTS/netsocket/tcp/tcpsocket_send_repeat.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717

1818
#include "mbed.h"
19-
#include MBED_CONF_APP_HEADER_FILE
2019
#include "TCPSocket.h"
2120
#include "greentea-client/test_env.h"
2221
#include "unity/unity.h"

TESTS/netsocket/tcp/tcpsocket_send_timeout.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717

1818
#include "mbed.h"
19-
#include MBED_CONF_APP_HEADER_FILE
2019
#include "TCPSocket.h"
2120
#include "greentea-client/test_env.h"
2221
#include "unity/unity.h"

TESTS/netsocket/tcp/tcpsocket_thread_per_socket_safety.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717

1818
#include "mbed.h"
19-
#include MBED_CONF_APP_HEADER_FILE
2019
#include "TCPSocket.h"
2120
#include "greentea-client/test_env.h"
2221
#include "unity/unity.h"

TESTS/netsocket/udp/main.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515
* limitations under the License.
1616
*/
1717

18-
#ifndef MBED_CONF_APP_CONNECT_STATEMENT
18+
#define WIFI 2
19+
#if !defined(MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE) || \
20+
(MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == WIFI && !defined(MBED_CONF_NSAPI_DEFAULT_WIFI_SSID))
1921
#error [NOT_SUPPORTED] No network configuration found for this target.
2022
#endif
23+
#ifndef MBED_CONF_APP_ECHO_SERVER_ADDR
24+
#error [NOT_SUPPORTED] Requires parameters from mbed_app.json
25+
#endif
2126

2227
#include "mbed.h"
23-
#include MBED_CONF_APP_HEADER_FILE
2428
#include "greentea-client/test_env.h"
2529
#include "unity/unity.h"
2630
#include "utest.h"
@@ -40,8 +44,8 @@ NetworkInterface *get_interface()
4044

4145
static void _ifup()
4246
{
43-
net = MBED_CONF_APP_OBJECT_CONSTRUCTION;
44-
nsapi_error_t err = MBED_CONF_APP_CONNECT_STATEMENT;
47+
net = NetworkInterface::get_default_instance();
48+
nsapi_error_t err = net->connect();
4549
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, err);
4650
printf("MBED: UDPClient IP address is '%s'\n", net->get_ip_address());
4751
}

TESTS/netsocket/udp/udpsocket_echotest.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717

1818
#include "mbed.h"
19-
#include MBED_CONF_APP_HEADER_FILE
2019
#include "UDPSocket.h"
2120
#include "greentea-client/test_env.h"
2221
#include "unity/unity.h"

TESTS/netsocket/udp/udpsocket_echotest_burst.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717

1818
#include "mbed.h"
19-
#include MBED_CONF_APP_HEADER_FILE
2019
#include "UDPSocket.h"
2120
#include "greentea-client/test_env.h"
2221
#include "unity/unity.h"

TESTS/netsocket/udp/udpsocket_open_close_repeat.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
#include "greentea-client/test_env.h"
1919
#include "mbed.h"
20-
#include MBED_CONF_APP_HEADER_FILE
2120
#include "udp_tests.h"
2221
#include "UDPSocket.h"
2322
#include "unity/unity.h"

TESTS/netsocket/udp/udpsocket_open_limit.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
#include "greentea-client/test_env.h"
1919
#include "mbed.h"
20-
#include MBED_CONF_APP_HEADER_FILE
2120
#include "udp_tests.h"
2221
#include "UDPSocket.h"
2322
#include "unity/unity.h"

TESTS/netsocket/udp/udpsocket_recv_timeout.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717

1818
#include "mbed.h"
19-
#include MBED_CONF_APP_HEADER_FILE
2019
#include "UDPSocket.h"
2120
#include "greentea-client/test_env.h"
2221
#include "unity/unity.h"

TESTS/netsocket/udp/udpsocket_sendto_invalid.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717

1818
#include "mbed.h"
19-
#include MBED_CONF_APP_HEADER_FILE
2019
#include "UDPSocket.h"
2120
#include "greentea-client/test_env.h"
2221
#include "unity/unity.h"

TESTS/netsocket/udp/udpsocket_sendto_repeat.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717

1818
#include "mbed.h"
19-
#include MBED_CONF_APP_HEADER_FILE
2019
#include "UDPSocket.h"
2120
#include "greentea-client/test_env.h"
2221
#include "unity/unity.h"

TESTS/netsocket/udp/udpsocket_sendto_timeout.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717

1818
#include "mbed.h"
19-
#include MBED_CONF_APP_HEADER_FILE
2019
#include "UDPSocket.h"
2120
#include "greentea-client/test_env.h"
2221
#include "unity/unity.h"

TESTS/network/emac/README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,34 @@ To configure a device to be a CTP echo server, you need to enable the `echo-serv
88

99
## Other configuration options
1010

11-
Default configuration files included with tests are configured for ethernet. For Wi-Fi, set `test-ethernet` to 0 and `test-wifi` to 1. You also need to configure Wi-Fi SSID and security options to the configuration file.
11+
Targets with connectivity set the target.network-default-interface-type configuration variable appropriately, either to their only interface or their most-commonly-used one. For targets that provide more than one type of connectivity, you may choose the default by overriding the target.network-default-interface-type configuration variable.
12+
13+
For Ethernet, if you want to overrride the default, set the `json` configuration to:
14+
15+
```
16+
"target_overrides": {
17+
"*": {
18+
"target.network-default-interface-type": "ETHERNET",
19+
"nsapi.default-stack": "TEST"
20+
}
21+
}
22+
```
23+
24+
For Wi-Fi set the `json` configuration to:
25+
26+
```
27+
"target_overrides": {
28+
"*": {
29+
"target.network-default-interface-type": "WIFI",
30+
"nsapi.default-wifi-ssid": "\"WIFI_SSID\"",
31+
"nsapi.default-wifi-password": "\"WIFI_PASSWORD\"",
32+
"nsapi.default-wifi-security": "WIFI_SECURITY",
33+
"nsapi.default-stack": "TEST"
34+
}
35+
}
36+
```
37+
38+
For Wi-Fi you also need to configure Wi-Fi SSID and security options to the configuration file.
1239

1340
## Example commands
1441

TESTS/network/emac/emac_TestMemoryManager.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
* limitations under the License.
1616
*/
1717

18-
#if MBED_CONF_APP_TEST_WIFI || MBED_CONF_APP_TEST_ETHERNET
19-
2018
#include <stdio.h>
2119
#include <stdarg.h>
2220
#include <string.h>
@@ -556,4 +554,3 @@ EmacTestMemoryManager &EmacTestMemoryManager::get_instance()
556554
return test_memory_manager;
557555
}
558556

559-
#endif

TESTS/network/emac/emac_TestMemoryManager.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
* limitations under the License.
1616
*/
1717

18-
#if MBED_CONF_APP_TEST_WIFI || MBED_CONF_APP_TEST_ETHERNET
19-
2018
#ifndef EMAC_TEST_MEMORY_MANAGER_H
2119
#define EMAC_TEST_MEMORY_MANAGER_H
2220

@@ -115,7 +113,7 @@ class EmacTestMemoryManager : public EMACMemoryManager {
115113
* If memory buffer is chained must point to the start of the chain. Frees all buffers
116114
* from the chained list.
117115
*
118-
* @param mem Memory buffer chain to be freed.
116+
* @param buf Memory buffer chain to be freed.
119117
*/
120118
virtual void free(emac_mem_buf_t *buf);
121119

@@ -124,7 +122,7 @@ class EmacTestMemoryManager : public EMACMemoryManager {
124122
*
125123
* Returns a total length of this buffer and any following buffers in the chain.
126124
*
127-
* @param mem Memory buffer chain
125+
* @param buf Memory buffer chain
128126
* @return Total length in bytes
129127
*/
130128
virtual uint32_t get_total_len(const emac_mem_buf_t *buf) const;
@@ -157,23 +155,23 @@ class EmacTestMemoryManager : public EMACMemoryManager {
157155
*
158156
* Returns the next buffer from the memory buffer chain.
159157
*
160-
* @param mem Memory buffer
158+
* @param buf Memory buffer
161159
* @return The next memory buffer, or NULL if last
162160
*/
163161
virtual emac_mem_buf_t *get_next(const emac_mem_buf_t *buf) const;
164162

165163
/**
166164
* Return pointer to the payload of the buffer
167165
*
168-
* @param mem Memory buffer
166+
* @param buf Memory buffer
169167
* @return Pointer to the payload
170168
*/
171169
virtual void *get_ptr(const emac_mem_buf_t *buf) const;
172170

173171
/**
174172
* Return payload size of the buffer
175173
*
176-
* @param mem Memory buffer
174+
* @param buf Memory buffer
177175
* @return Size in bytes
178176
*/
179177
virtual uint32_t get_len(const emac_mem_buf_t *buf) const;
@@ -184,7 +182,7 @@ class EmacTestMemoryManager : public EMACMemoryManager {
184182
* The allocated payload size will not change. It is not permitted
185183
* to change the length of a buffer that is not the first (or only) in a chain.
186184
*
187-
* @param mem Memory buffer
185+
* @param buf Memory buffer
188186
* @param len Payload size, must be less or equal allocated size
189187
*/
190188
virtual void set_len(emac_mem_buf_t *buf, uint32_t len);
@@ -229,4 +227,3 @@ class EmacTestMemoryManager : public EMACMemoryManager {
229227
};
230228

231229
#endif /* EMAC_TEST_MEMORY_MANAGER_H */
232-
#endif

TESTS/network/emac/emac_TestNetworkStack.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
* limitations under the License.
1616
*/
1717

18-
#if MBED_CONF_APP_TEST_WIFI || MBED_CONF_APP_TEST_ETHERNET
19-
2018
#include "unity.h"
2119

2220
#include "EMACMemoryManager.h"
@@ -205,5 +203,3 @@ OnboardNetworkStack &OnboardNetworkStack::get_default_instance()
205203
return EmacTestNetworkStack::get_instance();
206204
}
207205
#endif
208-
209-
#endif

0 commit comments

Comments
 (0)