Skip to content

WiFi: Re-order Greentea tests with minor fixes #11841

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 1 commit into from
Nov 15, 2019
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
29 changes: 3 additions & 26 deletions TESTS/network/wifi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ Please refer to the following table for priorities of test cases. Priorities are
| 4 | WIFI_SET_CHANNEL | | SHOULD |
| 5 | WIFI_GET_RSSI | | SHOULD |
| 6 | WIFI_CONNECT_PARAMS_NULL | | MUST |
| 7 | WIFI_CONNECT_PARAMS_VALID_UNSECURE | | MUST |
| 8 | WIFI_CONNECT_PARAMS_VALID_SECURE | With security type: | |
| | | NSAPI_SECURITY_WEP | SHOULD |
| | | NSAPI_SECURITY_WPA | SHOULD |
Expand Down Expand Up @@ -271,28 +270,6 @@ Test enviroment is set up as specified in "Test Environment" chapter.

Both `connect()` calls return NSAPI_ERROR_PARAMETER.

### WIFI_CONNECT_PARAMS_VALID_UNSECURE

**Description:**

Test `WiFiInterface::connect(ssid, pass, security)` with valid parameters for the unsecure network.

**Precondition:**

Test enviroment is set up as specified in the "Test Environment" chapter.

**Test steps:**

1. Initialize the driver.
2. Call `WiFiInterface::connect( <ssid:unsecure>, NULL)`.
3. `disconnect()`.
4. Call `WiFiInterface::connect( <ssid:unsecure>, "")`.
5. `disconnect()`.

**Expected result:**

`connect()` calls return NSAPI_ERROR_OK.

### WIFI_CONNECT_PARAMS_VALID_SECURE

**Description:**
Expand Down Expand Up @@ -350,7 +327,7 @@ Test enviroment is set up as specified in the "Test Environment" chapter.
**Test steps:**

1. Initialize the driver.
2. Call `WiFiInterface::connect( <ssid:secure>, <pw:secure>, NSAPI_SECURITY_WPA2, <ch:unsecure>)`.
2. Call `WiFiInterface::connect( <ssid:secure>, <pw:secure>, NSAPI_SECURITY_WPA2, <ch:secure>)`.
3. `disconnect()`.

**Expected result:**
Expand Down Expand Up @@ -398,7 +375,7 @@ Test `WiFiInterface::connect()` and `WiFiInterface::disconnect()` in non-blockin
**Test steps:**

1. Initialize the driver.
2. `Call WiFiInterface::set_credentials( <ssid:unsecure>, NULL)`.
2. `Call WiFiInterface::set_credentials( <ssid:secure>, NULL)`.
3. `Call WiFiInterface::set_blocking(false)`
4. `Call WiFiInterface::connect()`.
5. `Cal WiFiInterface::set_credentials(const char *ssid, const char *pass, nsapi_security_t security)`
Expand Down Expand Up @@ -473,7 +450,7 @@ The test enviroment is set up as specified in the "Test Environment" chapter.
**Test steps:**

1. Initialize the driver.
2. Call `WiFiInterface::set_credentials( <ssid:unsecure>, NULL)`.
2. Call `WiFiInterface::set_credentials( <ssid:secure>, NULL)`.
3. Repeat 10 times:
1. Call `WiFiInterface::connect()`.
2. `disconnect()`.
Expand Down
13 changes: 6 additions & 7 deletions TESTS/network/wifi/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,20 @@ Case cases[] = {
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID) || defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
Case("WIFI-SCAN", wifi_scan),
#endif
#if defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID)
Case("WIFI-GET-RSSI", wifi_get_rssi),
Case("WIFI-CONNECT-PARAMS-VALID-UNSECURE", wifi_connect_params_valid_unsecure),
Case("WIFI-CONNECT", wifi_connect),
//Most boards are not passing this test, but they should if they support non-blocking API.
//Case("WIFI_CONNECT_DISCONNECT_NONBLOCK", wifi_connect_disconnect_nonblock),
Case("WIFI-CONNECT-DISCONNECT-REPEAT", wifi_connect_disconnect_repeat),
#endif
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID)
Case("WIFI-CONNECT-PARAMS-VALID-SECURE", wifi_connect_params_valid_secure),
Case("WIFI-CONNECT-PARAMS-CHANNEL", wifi_connect_params_channel),
Case("WIFI-CONNECT-PARAMS-CHANNEL-FAIL", wifi_connect_params_channel_fail),
Case("WIFI-CONNECT-SECURE", wifi_connect_secure),
Case("WIFI-CONNECT-SECURE-FAIL", wifi_connect_secure_fail),
#endif
#if defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
Case("WIFI-CONNECT", wifi_connect),
//Most boards are not passing this test, but they should if they support non-blocking API.
//Case("WIFI_CONNECT_DISCONNECT_NONBLOCK", wifi_connect_disconnect_nonblock),
#endif
};

Specification specification(test_setup, cases, greentea_continue_handlers);
Expand Down
6 changes: 3 additions & 3 deletions TESTS/network/wifi/wifi_connect_disconnect_repeat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@

using namespace utest::v1;

#if defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID)

void wifi_connect_disconnect_repeat(void)
{
WiFiInterface *wifi = get_interface();
nsapi_error_t error;

error = wifi->set_credentials(MBED_CONF_APP_WIFI_UNSECURE_SSID, NULL);
error = wifi->set_credentials(MBED_CONF_APP_WIFI_SECURE_SSID, MBED_CONF_APP_WIFI_PASSWORD, get_security());
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, error);

for (int i = 0; i < 10; i++) {
Expand All @@ -41,4 +41,4 @@ void wifi_connect_disconnect_repeat(void)
}
}

#endif // defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
#endif // defined(MBED_CONF_APP_WIFI_SECURE_SSID)
5 changes: 3 additions & 2 deletions TESTS/network/wifi/wifi_connect_params_valid_secure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ void wifi_connect_params_valid_secure(void)
WiFiInterface *wifi = get_interface();

if (wifi->connect(MBED_CONF_APP_WIFI_SECURE_SSID, MBED_CONF_APP_WIFI_PASSWORD, get_security()) == NSAPI_ERROR_OK) {
wifi->disconnect();
return;
if (wifi->disconnect() == NSAPI_ERROR_OK) {
return;
}
}

TEST_FAIL();
Expand Down
37 changes: 0 additions & 37 deletions TESTS/network/wifi/wifi_connect_params_valid_unsecure.cpp

This file was deleted.

9 changes: 6 additions & 3 deletions TESTS/network/wifi/wifi_connect_secure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ void wifi_connect_secure(void)
{
WiFiInterface *wifi = get_interface();

TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->set_credentials(MBED_CONF_APP_WIFI_SECURE_SSID, MBED_CONF_APP_WIFI_PASSWORD, get_security()));

// Driver shall cache the credentials
char ssid[] = MBED_CONF_APP_WIFI_SECURE_SSID;
char password[] = MBED_CONF_APP_WIFI_PASSWORD;
TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->set_credentials(ssid, password, get_security()));
ssid[0] = '\0';
password[0] = '\0';
TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->connect());

TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->disconnect());
}

Expand Down
6 changes: 3 additions & 3 deletions TESTS/network/wifi/wifi_get_rssi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@

using namespace utest::v1;

#if defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID)

void wifi_get_rssi(void)
{
WiFiInterface *wifi = get_interface();

TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->set_credentials(MBED_CONF_APP_WIFI_UNSECURE_SSID, NULL));
TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->set_credentials(MBED_CONF_APP_WIFI_SECURE_SSID, MBED_CONF_APP_WIFI_PASSWORD, get_security()));

TEST_ASSERT_EQUAL_INT8(0, wifi->get_rssi());

Expand All @@ -40,4 +40,4 @@ void wifi_get_rssi(void)
TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->disconnect());
}

#endif // defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
#endif // defined(MBED_CONF_APP_WIFI_SECURE_SSID)
3 changes: 0 additions & 3 deletions TESTS/network/wifi/wifi_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ void wifi_get_rssi(void);
/** Test WiFiInterface::connect(ssid, pass, security, channel) with NULL parameters */
void wifi_connect_params_null(void);

/** Test WiFiInterface::connect(ssid, pass, security) with valid parameters for unsecure network */
void wifi_connect_params_valid_unsecure(void);

/** Test WiFiInterface::connect(ssid, pass, security) with valid parameters for secure network */
void wifi_connect_params_valid_secure(void);

Expand Down