Skip to content

Updated emac greentea tests #6851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 72 additions & 2 deletions TESTS/network/emac/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,80 @@
# Introduction

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

## Configuring the CTP echo server

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

## Other configuration options

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.

## Example commands

### CTP echo server

You can use the following command to a build CTP echo server:

`mbed test --compile -m TARGET -t GCC_ARM -v -n tests-network-emac --app-config TESTS/network/emac/template_mbed_app_echo_server.txt`

Replace TARGET with the target device. After building, flash the binary to the CTP echo server device.

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.

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.

The CTP echo server sends a 100-byte long broadcast CTP Ethernet frame every 60 seconds to inform the network of its presence.

### Running tests

You can use the following command to run tests:

`mbed test --compile --run -m TARGET -t GCC_ARM -v -n tests-network-emac --app-config TESTS/network/emac/template_mbed_app.txt`

Replace TARGET with the target device.

## Traces

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.

For example, the `EMAC broadcast` test enables send, input CTP frame, success and failure traces:

`SET_TRACE_LEVEL(TRACE_SEND | TRACE_ETH_FRAMES | TRACE_SUCCESS | TRACE_FAILURE);`

This example trace is about a message sent to broadcast address `ff:ff:ff:ff:ff:ff` that an echo server answers:

```

message sent ff:ff:ff:ff:ff:ff

response: receipt number 24 LENGTH OK DATA OK BROADCAST

```

This example trace is about a message sent to broadcast address `ff:ff:ff:ff:ff:ff` that an echo server does not answer:

```

message sent ff:ff:ff:ff:ff:ff

NO RESPONSE: receipt number 25

```

This example is about input message trace. Message hex dump contains the first 32 bytes of the received Ethernet frame:

```

INP> LEN 100

INP> 000000 ff ff ff ff ff ff ba 42 ed 79 11 8a 90 00

INP> 00000e 00 00 02 00 ba 42 ed 79 11 8a 01 00 01 00

```

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.

## Test cases

Expand Down
3 changes: 2 additions & 1 deletion TESTS/network/emac/emac_test_broadcast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ void test_emac_broadcast_cb(int opt)
#if MBED_CONF_APP_ECHO_SERVER
static bool echo_server_started = false;
if (!echo_server_started) {
#if MBED_CONF_APP_ECHO_SERVER_TRACE == 0
SET_TRACE_LEVEL(TRACE_NONE);
#endif
printf("echo server started successfully\r\n\r\n");
echo_server_started = true;
} else {
Expand All @@ -65,7 +67,6 @@ void test_emac_broadcast_cb(int opt)
if (++no_response_cnt > 3) {
if (++retries > 6) {
printf("too many retries\r\n\r\n");
RESET_ERROR_FLAGS(NO_RESPONSE);
END_TEST_LOOP;
} else {
printf("retry count %i\r\n\r\n", retries);
Expand Down
2 changes: 0 additions & 2 deletions TESTS/network/emac/emac_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,13 +510,11 @@ static void worker_loop_event_cb(int event)
{
if (event == LINK_UP) {
link_up = true;
printf("cable connected\r\n\r\n");
link_status_semaphore.release();
}

if (event == LINK_DOWN) {
link_up = false;
printf("cable disconnected\r\n\r\n");
}
}

Expand Down
13 changes: 7 additions & 6 deletions TESTS/network/emac/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
* limitations under the License.
*/

#if !defined(MBED_CONF_APP_TEST_WIFI) || \
!defined(MBED_CONF_APP_TEST_ETHERNET) || \
!defined(MBED_CONF_APP_ECHO_SERVER) || \
!defined(MBED_CONF_APP_WIFI_SCAN) || \
!defined(MBED_CONF_APP_WIFI_SSID ) || \
!defined(MBED_CONF_APP_WIFI_SECURITY) || \
#if !defined(MBED_CONF_APP_TEST_WIFI) || \
!defined(MBED_CONF_APP_TEST_ETHERNET) || \
!defined(MBED_CONF_APP_ECHO_SERVER) || \
!defined(MBED_CONF_APP_ECHO_SERVER_TRACE) || \
!defined(MBED_CONF_APP_WIFI_SCAN) || \
!defined(MBED_CONF_APP_WIFI_SSID ) || \
!defined(MBED_CONF_APP_WIFI_SECURITY) || \
!defined(MBED_CONF_APP_WIFI_PASSWORD)
#error [NOT_SUPPORTED] Requires parameters from mbed_app.json
#endif
Expand Down
4 changes: 4 additions & 0 deletions TESTS/network/emac/template_mbed_app.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
"help": "Build test to be echo server",
"value": 0
},
"echo-server-trace": {
"help": "Trace incoming messages on echo server",
"value": 0
},
"wifi-scan": {
"help": "Scan and list access points",
"value": 0
Expand Down
41 changes: 41 additions & 0 deletions TESTS/network/emac/template_mbed_app_echo_server.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"config": {
"test-ethernet": {
"help": "Enable ethernet testing",
"value": 1
},
"test-wifi": {
"help": "Enable wifi testing",
"value": 0
},
"echo-server": {
"help": "Build test to be echo server",
"value": 1
},
"echo-server-trace": {
"help": "Trace incoming messages on echo server",
"value": 0
},
"wifi-scan": {
"help": "Scan and list access points",
"value": 0
},
"wifi-ssid": {
"help": "WiFi SSID for network",
"value": "\"SSID\""
},
"wifi-security": {
"help": "WiFi Security",
"value": "NSAPI_SECURITY_WPA_WPA2"
},
"wifi-password": {
"help": "WiFi Password",
"value": "\"PASSWORD\""
}
},
"target_overrides": {
"*": {
"nsapi.default-stack": "TEST"
}
}
}