Skip to content

Commit d95acbc

Browse files
author
Cruz Monrreal
authored
Merge pull request #6851 from mikaleppanen/emac_test_updates
Updated emac greentea tests
2 parents 942209e + 22e4c34 commit d95acbc

File tree

6 files changed

+126
-11
lines changed

6 files changed

+126
-11
lines changed

TESTS/network/emac/README.md

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,80 @@
11
# Introduction
22

3-
This document describes how to run EMAC tests. The EMAC test cases are made using the Ethernet Configuration Testing Protocol (CTP). To run the tests, one device in the Ethernet segment needs to be configured to be a CTP echo server. The devices running the test cases, use the echo server to forward the CTP Ethernet frames back.
3+
This document describes how to run EMAC tests. The EMAC test cases are made using the Ethernet Configuration Testing Protocol (CTP). To run the tests, you need to configure one device in the Ethernet segment to be a CTP echo server. The devices running the test cases use the echo server to forward the CTP Ethernet frames back.
44

55
## Configuring the CTP echo server
66

7-
To configure a device to be a CTP echo server, you need to enable the `echo-server` setting in the `json` file of the test environment application. When a device is configured to be a CTP echo server, it starts to forward CTP messages automatically when it is switched on and continues to do so until it is switched off.
7+
To configure a device to be a CTP echo server, you need to enable the `echo-server` setting in the `json` file of the test environment application. When you configure a device to be a CTP echo server, it starts to forward CTP messages automatically when it is on and continues to do so until you switch it off.
8+
9+
## Other configuration options
10+
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.
12+
13+
## Example commands
14+
15+
### CTP echo server
16+
17+
You can use the following command to a build CTP echo server:
18+
19+
`mbed test --compile -m TARGET -t GCC_ARM -v -n tests-network-emac --app-config TESTS/network/emac/template_mbed_app_echo_server.txt`
20+
21+
Replace TARGET with the target device. After building, flash the binary to the CTP echo server device.
22+
23+
You can verify that the CTP echo server has started properly by making a terminal connection to the device, resetting it and verifying that `echo server started successfully` prints on the terminal. You can run host tests when the CTP echo server is running on the Ethernet segment.
24+
25+
For Wi-Fi tests, the CTP echo server can also run on the ethernet side as long as the network configuration is such that Ethernet frames are routed between Wi-Fi and Ethernet.
26+
27+
The CTP echo server sends a 100-byte long broadcast CTP Ethernet frame every 60 seconds to inform the network of its presence.
28+
29+
### Running tests
30+
31+
You can use the following command to run tests:
32+
33+
`mbed test --compile --run -m TARGET -t GCC_ARM -v -n tests-network-emac --app-config TESTS/network/emac/template_mbed_app.txt`
34+
35+
Replace TARGET with the target device.
36+
37+
## Traces
38+
39+
Test cases have different trace levels based on how much tracing can be done without affecting the performance of the test case. Configure tracing using `SET\_TRACE\_LEVEL` macro.
40+
41+
For example, the `EMAC broadcast` test enables send, input CTP frame, success and failure traces:
42+
43+
`SET_TRACE_LEVEL(TRACE_SEND | TRACE_ETH_FRAMES | TRACE_SUCCESS | TRACE_FAILURE);`
44+
45+
This example trace is about a message sent to broadcast address `ff:ff:ff:ff:ff:ff` that an echo server answers:
46+
47+
```
48+
49+
message sent ff:ff:ff:ff:ff:ff
50+
51+
response: receipt number 24 LENGTH OK DATA OK BROADCAST
52+
53+
```
54+
55+
This example trace is about a message sent to broadcast address `ff:ff:ff:ff:ff:ff` that an echo server does not answer:
56+
57+
```
58+
59+
message sent ff:ff:ff:ff:ff:ff
60+
61+
NO RESPONSE: receipt number 25
62+
63+
```
64+
65+
This example is about input message trace. Message hex dump contains the first 32 bytes of the received Ethernet frame:
66+
67+
```
68+
69+
INP> LEN 100
70+
71+
INP> 000000 ff ff ff ff ff ff ba 42 ed 79 11 8a 90 00
72+
73+
INP> 00000e 00 00 02 00 ba 42 ed 79 11 8a 01 00 01 00
74+
75+
```
76+
77+
To verify whether the echo server is receiving CTP Ethernet frames, enable `echo-server-trace` option in the echo server configuration file. You can use this for debugging purposes. Do not run performance tests such as `EMAC unicast burst` with tracing enabled because tracing affects the echo server performance.
878

979
## Test cases
1080

TESTS/network/emac/emac_test_broadcast.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ void test_emac_broadcast_cb(int opt)
4545
#if MBED_CONF_APP_ECHO_SERVER
4646
static bool echo_server_started = false;
4747
if (!echo_server_started) {
48+
#if MBED_CONF_APP_ECHO_SERVER_TRACE == 0
4849
SET_TRACE_LEVEL(TRACE_NONE);
50+
#endif
4951
printf("echo server started successfully\r\n\r\n");
5052
echo_server_started = true;
5153
} else {
@@ -65,7 +67,6 @@ void test_emac_broadcast_cb(int opt)
6567
if (++no_response_cnt > 3) {
6668
if (++retries > 6) {
6769
printf("too many retries\r\n\r\n");
68-
RESET_ERROR_FLAGS(NO_RESPONSE);
6970
END_TEST_LOOP;
7071
} else {
7172
printf("retry count %i\r\n\r\n", retries);

TESTS/network/emac/emac_util.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,13 +510,11 @@ static void worker_loop_event_cb(int event)
510510
{
511511
if (event == LINK_UP) {
512512
link_up = true;
513-
printf("cable connected\r\n\r\n");
514513
link_status_semaphore.release();
515514
}
516515

517516
if (event == LINK_DOWN) {
518517
link_up = false;
519-
printf("cable disconnected\r\n\r\n");
520518
}
521519
}
522520

TESTS/network/emac/main.cpp

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

18-
#if !defined(MBED_CONF_APP_TEST_WIFI) || \
19-
!defined(MBED_CONF_APP_TEST_ETHERNET) || \
20-
!defined(MBED_CONF_APP_ECHO_SERVER) || \
21-
!defined(MBED_CONF_APP_WIFI_SCAN) || \
22-
!defined(MBED_CONF_APP_WIFI_SSID ) || \
23-
!defined(MBED_CONF_APP_WIFI_SECURITY) || \
18+
#if !defined(MBED_CONF_APP_TEST_WIFI) || \
19+
!defined(MBED_CONF_APP_TEST_ETHERNET) || \
20+
!defined(MBED_CONF_APP_ECHO_SERVER) || \
21+
!defined(MBED_CONF_APP_ECHO_SERVER_TRACE) || \
22+
!defined(MBED_CONF_APP_WIFI_SCAN) || \
23+
!defined(MBED_CONF_APP_WIFI_SSID ) || \
24+
!defined(MBED_CONF_APP_WIFI_SECURITY) || \
2425
!defined(MBED_CONF_APP_WIFI_PASSWORD)
2526
#error [NOT_SUPPORTED] Requires parameters from mbed_app.json
2627
#endif

TESTS/network/emac/template_mbed_app.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
"help": "Build test to be echo server",
1313
"value": 0
1414
},
15+
"echo-server-trace": {
16+
"help": "Trace incoming messages on echo server",
17+
"value": 0
18+
},
1519
"wifi-scan": {
1620
"help": "Scan and list access points",
1721
"value": 0
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"config": {
3+
"test-ethernet": {
4+
"help": "Enable ethernet testing",
5+
"value": 1
6+
},
7+
"test-wifi": {
8+
"help": "Enable wifi testing",
9+
"value": 0
10+
},
11+
"echo-server": {
12+
"help": "Build test to be echo server",
13+
"value": 1
14+
},
15+
"echo-server-trace": {
16+
"help": "Trace incoming messages on echo server",
17+
"value": 0
18+
},
19+
"wifi-scan": {
20+
"help": "Scan and list access points",
21+
"value": 0
22+
},
23+
"wifi-ssid": {
24+
"help": "WiFi SSID for network",
25+
"value": "\"SSID\""
26+
},
27+
"wifi-security": {
28+
"help": "WiFi Security",
29+
"value": "NSAPI_SECURITY_WPA_WPA2"
30+
},
31+
"wifi-password": {
32+
"help": "WiFi Password",
33+
"value": "\"PASSWORD\""
34+
}
35+
},
36+
"target_overrides": {
37+
"*": {
38+
"nsapi.default-stack": "TEST"
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)