Skip to content

Commit 5fa2edc

Browse files
author
Mika Leppänen
committed
Updated greentea EMAC tests to use default interface
1 parent 96af5a4 commit 5fa2edc

19 files changed

+48
-150
lines changed

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: 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
#ifndef EMAC_TEST_MEMORY_MANAGER_H
2119
#define EMAC_TEST_MEMORY_MANAGER_H
2220

@@ -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

TESTS/network/emac/emac_TestNetworkStack.h

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
#ifndef EMAC_TEST_NETWORK_STACK_H
2119
#define EMAC_TEST_NETWORK_STACK_H
2220

@@ -392,5 +390,3 @@ class EmacTestNetworkStack : public OnboardNetworkStack, private mbed::NonCopyab
392390
};
393391

394392
#endif /* EMAC_TEST_NETWORK_STACK_H */
395-
396-
#endif

TESTS/network/emac/emac_ctp.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
#include "unity/unity.h"
2020
#include "utest.h"
2121

22-
#if MBED_CONF_APP_TEST_WIFI || MBED_CONF_APP_TEST_ETHERNET
23-
2422
#include "mbed.h"
2523

2624
#include "EMAC.h"
@@ -152,5 +150,4 @@ void emac_if_ctp_msg_build(int eth_frame_len, const unsigned char *dest_addr, co
152150
emac_if_check_memory(false);
153151
}
154152

155-
#endif
156153

TESTS/network/emac/emac_membuf.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
#include "unity.h"
2121
#include "utest.h"
2222

23-
#if MBED_CONF_APP_TEST_WIFI || MBED_CONF_APP_TEST_ETHERNET
24-
25-
#include "lwip/opt.h" /* ETH_PAD_SIZE */
26-
2723
#include "mbed.h"
2824

2925
#include "EMAC.h"
@@ -79,5 +75,3 @@ void emac_if_memory_buffer_write(void *buf, unsigned char *eth_frame, bool write
7975
}
8076
}
8177
}
82-
83-
#endif

TESTS/network/emac/emac_test_broadcast.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
#include "unity.h"
2121
#include "utest.h"
2222

23-
#if MBED_CONF_APP_TEST_WIFI || MBED_CONF_APP_TEST_ETHERNET
24-
2523
#include "emac_tests.h"
2624
#include "emac_util.h"
2725
#include "emac_ctp.h"
@@ -101,4 +99,3 @@ void test_emac_broadcast(void)
10199
RESET_OUTGOING_MSG_DATA;
102100
}
103101

104-
#endif

TESTS/network/emac/emac_test_initialize.cpp

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,11 @@
2222
#include "unity.h"
2323
#include "utest.h"
2424

25-
#if MBED_CONF_APP_TEST_WIFI || MBED_CONF_APP_TEST_ETHERNET
26-
27-
#include "EthernetInterface.h"
25+
#include "NetworkInterface.h"
2826
#include "EMAC.h"
2927
#include "EMACMemoryManager.h"
3028
#include "emac_TestMemoryManager.h"
3129
#include "emac_TestNetworkStack.h"
32-
33-
#if MBED_CONF_APP_TEST_WIFI
34-
35-
#if defined(TARGET_UBLOX_EVK_ODIN_W2) || defined(TARGET_MTB_UBLOX_ODIN_W2)
36-
#include "OdinWiFiInterface.h"
37-
#endif
38-
#ifdef TARGET_REALTEK_RTL8195AM
39-
#include "RTWInterface.h"
40-
#endif
41-
#if defined(TARGET_MTB_ADV_WISE_1530) || \
42-
defined(TARGET_MTB_USI_WM_BN_BM_22) || \
43-
defined(TARGET_MTB_MXCHIP_EMW3166)
44-
#include "WicedInterface.h"
45-
#endif
46-
47-
#endif
48-
4930
#include "emac_initialize.h"
5031
#include "emac_tests.h"
5132
#include "emac_util.h"
@@ -59,29 +40,14 @@ void test_emac_initialize()
5940
{
6041
worker_loop_init();
6142

62-
#if MBED_CONF_APP_TEST_ETHERNET
63-
64-
static EthernetInterface *network_interface = new EthernetInterface;
65-
66-
#elif MBED_CONF_APP_TEST_WIFI
67-
68-
// Add wifi classes here
69-
#if defined(TARGET_UBLOX_EVK_ODIN_W2) || defined(TARGET_MTB_UBLOX_ODIN_W2)
70-
static WiFiInterface *network_interface = new OdinWiFiInterface;
71-
#elif defined(TARGET_REALTEK_RTL8195AM)
72-
static WiFiInterface *network_interface = new RTWInterface;
73-
#elif defined(TARGET_MTB_ADV_WISE_1530) || \
74-
defined(TARGET_MTB_USI_WM_BN_BM_22) || \
75-
defined(TARGET_MTB_MXCHIP_EMW3166)
76-
static WiFiInterface *network_interface = new WicedInterface;
77-
#else
78-
static WiFiInterface *network_interface = new WiFiInterface;
79-
#endif
43+
static NetworkInterface *network_interface = NetworkInterface::get_default_instance();
8044

45+
#define WIFI 2
46+
#if MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == WIFI
8147
#if MBED_CONF_APP_WIFI_SCAN
8248
WiFiAccessPoint ap[30];
8349

84-
int size = network_interface->scan(ap, 30);
50+
int size = network_interface->wifiInterface()->scan(ap, 30);
8551

8652
for (int i = 0; i < size; i++) {
8753
const char *ssid = ap[i].get_ssid();
@@ -96,9 +62,6 @@ void test_emac_initialize()
9662
printf("ch %i\r\n\r\n", ch);
9763
}
9864
#endif
99-
100-
network_interface->set_credentials(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD, MBED_CONF_APP_WIFI_SECURITY);
101-
10265
#endif
10366

10467
// Power up the interface and emac driver
@@ -154,5 +117,3 @@ bool emac_if_init(EMAC *emac)
154117

155118
return true;
156119
}
157-
158-
#endif

TESTS/network/emac/emac_test_memory.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
#include "unity.h"
2121
#include "utest.h"
2222

23-
#if MBED_CONF_APP_TEST_WIFI || MBED_CONF_APP_TEST_ETHERNET
24-
2523
#include "emac_tests.h"
2624
#include "emac_util.h"
2725
#include "emac_ctp.h"
@@ -163,5 +161,3 @@ void test_emac_memory()
163161
TEST_ASSERT_FALSE(ERROR_FLAGS);
164162
RESET_OUTGOING_MSG_DATA;
165163
}
166-
167-
#endif

0 commit comments

Comments
 (0)