Skip to content

Commit 6e7cac9

Browse files
author
Mika Leppänen
committed
Updated emac greentea tests
- Improved markdown - Set tests to fail if CTP echo server is not present
1 parent 942209e commit 6e7cac9

File tree

6 files changed

+124
-9
lines changed

6 files changed

+124
-9
lines changed

TESTS/network/emac/README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,76 @@ This document describes how to run EMAC tests. The EMAC test cases are made usin
66

77
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.
88

9+
## Other configuration options
10+
11+
Default configuration files included with tests are configured for ethernet. For Wifi, set `test-ethernet` to 0 and `test-wifi` to 1. Also Wifi SSID and security options need to be configured to the configuration file.
12+
13+
## Example commands
14+
15+
### CTP echo server
16+
17+
You can use following command to 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 been started properly by making terminal connection to the device, resetting it and verifying that `echo server started successfully` is printed on the terminal. Host tests can be run when the CTP echo server is running on the Ethernet segment.
24+
25+
For Wifi tests the CTP echo server can be also running of ethernet side as long as network configuration is such that Ethernet frames are routed between Wifi and Ethernet.
26+
27+
CTP echo server is sending 100 bytes long broadcast CTP Ethernet frame every 60 seconds to inform the network of its presence.
28+
29+
### Running tests
30+
31+
You can use 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. Tracing is configured using `SET\_TRACE\_LEVEL' macro.
40+
41+
For example `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+
Here is an example trace about a message that has been send to broadcast address `ff:ff:ff:ff:ff:ff` and is answered by echo server:
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+
Here is an example trace about a message that has been send to broadcast address `ff:ff:ff:ff:ff:ff` and is not answered by echo server:
56+
57+
```
58+
59+
message sent ff:ff:ff:ff:ff:ff
60+
61+
NO RESPONSE: receipt number 25
62+
63+
```
64+
65+
Here is an example 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+
If you like to verify whether the echo server is receiving CTP Ethernet frames you can enable `echo-server-trace` option in the echo server configuration file. This can be used for debugging purposes. Do not run performance test like `EMAC unicast burst` with tracing enabled, since tracing affects the echo server performance.
78+
979
## Test cases
1080

1181
### EMAC initialize

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)