Skip to content

Commit 97a7466

Browse files
authored
Merge pull request #11841 from AriParkkila/wifi-reorder
WiFi: Re-order Greentea tests with minor fixes
2 parents 30145b1 + ad1107e commit 97a7466

8 files changed

+24
-84
lines changed

TESTS/network/wifi/README.md

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ Please refer to the following table for priorities of test cases. Priorities are
5353
| 4 | WIFI_SET_CHANNEL | | SHOULD |
5454
| 5 | WIFI_GET_RSSI | | SHOULD |
5555
| 6 | WIFI_CONNECT_PARAMS_NULL | | MUST |
56-
| 7 | WIFI_CONNECT_PARAMS_VALID_UNSECURE | | MUST |
5756
| 8 | WIFI_CONNECT_PARAMS_VALID_SECURE | With security type: | |
5857
| | | NSAPI_SECURITY_WEP | SHOULD |
5958
| | | NSAPI_SECURITY_WPA | SHOULD |
@@ -271,28 +270,6 @@ Test enviroment is set up as specified in "Test Environment" chapter.
271270

272271
Both `connect()` calls return NSAPI_ERROR_PARAMETER.
273272

274-
### WIFI_CONNECT_PARAMS_VALID_UNSECURE
275-
276-
**Description:**
277-
278-
Test `WiFiInterface::connect(ssid, pass, security)` with valid parameters for the unsecure network.
279-
280-
**Precondition:**
281-
282-
Test enviroment is set up as specified in the "Test Environment" chapter.
283-
284-
**Test steps:**
285-
286-
1. Initialize the driver.
287-
2. Call `WiFiInterface::connect( <ssid:unsecure>, NULL)`.
288-
3. `disconnect()`.
289-
4. Call `WiFiInterface::connect( <ssid:unsecure>, "")`.
290-
5. `disconnect()`.
291-
292-
**Expected result:**
293-
294-
`connect()` calls return NSAPI_ERROR_OK.
295-
296273
### WIFI_CONNECT_PARAMS_VALID_SECURE
297274

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

352329
1. Initialize the driver.
353-
2. Call `WiFiInterface::connect( <ssid:secure>, <pw:secure>, NSAPI_SECURITY_WPA2, <ch:unsecure>)`.
330+
2. Call `WiFiInterface::connect( <ssid:secure>, <pw:secure>, NSAPI_SECURITY_WPA2, <ch:secure>)`.
354331
3. `disconnect()`.
355332

356333
**Expected result:**
@@ -398,7 +375,7 @@ Test `WiFiInterface::connect()` and `WiFiInterface::disconnect()` in non-blockin
398375
**Test steps:**
399376

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

475452
1. Initialize the driver.
476-
2. Call `WiFiInterface::set_credentials( <ssid:unsecure>, NULL)`.
453+
2. Call `WiFiInterface::set_credentials( <ssid:secure>, NULL)`.
477454
3. Repeat 10 times:
478455
1. Call `WiFiInterface::connect()`.
479456
2. `disconnect()`.

TESTS/network/wifi/main.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,20 @@ Case cases[] = {
7070
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID) || defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
7171
Case("WIFI-SCAN", wifi_scan),
7272
#endif
73-
#if defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
73+
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID)
7474
Case("WIFI-GET-RSSI", wifi_get_rssi),
75-
Case("WIFI-CONNECT-PARAMS-VALID-UNSECURE", wifi_connect_params_valid_unsecure),
76-
Case("WIFI-CONNECT", wifi_connect),
77-
//Most boards are not passing this test, but they should if they support non-blocking API.
78-
//Case("WIFI_CONNECT_DISCONNECT_NONBLOCK", wifi_connect_disconnect_nonblock),
7975
Case("WIFI-CONNECT-DISCONNECT-REPEAT", wifi_connect_disconnect_repeat),
80-
#endif
81-
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID)
8276
Case("WIFI-CONNECT-PARAMS-VALID-SECURE", wifi_connect_params_valid_secure),
8377
Case("WIFI-CONNECT-PARAMS-CHANNEL", wifi_connect_params_channel),
8478
Case("WIFI-CONNECT-PARAMS-CHANNEL-FAIL", wifi_connect_params_channel_fail),
8579
Case("WIFI-CONNECT-SECURE", wifi_connect_secure),
8680
Case("WIFI-CONNECT-SECURE-FAIL", wifi_connect_secure_fail),
8781
#endif
82+
#if defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
83+
Case("WIFI-CONNECT", wifi_connect),
84+
//Most boards are not passing this test, but they should if they support non-blocking API.
85+
//Case("WIFI_CONNECT_DISCONNECT_NONBLOCK", wifi_connect_disconnect_nonblock),
86+
#endif
8887
};
8988

9089
Specification specification(test_setup, cases, greentea_continue_handlers);

TESTS/network/wifi/wifi_connect_disconnect_repeat.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323

2424
using namespace utest::v1;
2525

26-
#if defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
26+
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID)
2727

2828
void wifi_connect_disconnect_repeat(void)
2929
{
3030
WiFiInterface *wifi = get_interface();
3131
nsapi_error_t error;
3232

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

3636
for (int i = 0; i < 10; i++) {
@@ -41,4 +41,4 @@ void wifi_connect_disconnect_repeat(void)
4141
}
4242
}
4343

44-
#endif // defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
44+
#endif // defined(MBED_CONF_APP_WIFI_SECURE_SSID)

TESTS/network/wifi/wifi_connect_params_valid_secure.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ void wifi_connect_params_valid_secure(void)
3030
WiFiInterface *wifi = get_interface();
3131

3232
if (wifi->connect(MBED_CONF_APP_WIFI_SECURE_SSID, MBED_CONF_APP_WIFI_PASSWORD, get_security()) == NSAPI_ERROR_OK) {
33-
wifi->disconnect();
34-
return;
33+
if (wifi->disconnect() == NSAPI_ERROR_OK) {
34+
return;
35+
}
3536
}
3637

3738
TEST_FAIL();

TESTS/network/wifi/wifi_connect_params_valid_unsecure.cpp

Lines changed: 0 additions & 37 deletions
This file was deleted.

TESTS/network/wifi/wifi_connect_secure.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,13 @@ void wifi_connect_secure(void)
2929
{
3030
WiFiInterface *wifi = get_interface();
3131

32-
TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->set_credentials(MBED_CONF_APP_WIFI_SECURE_SSID, MBED_CONF_APP_WIFI_PASSWORD, get_security()));
33-
32+
// Driver shall cache the credentials
33+
char ssid[] = MBED_CONF_APP_WIFI_SECURE_SSID;
34+
char password[] = MBED_CONF_APP_WIFI_PASSWORD;
35+
TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->set_credentials(ssid, password, get_security()));
36+
ssid[0] = '\0';
37+
password[0] = '\0';
3438
TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->connect());
35-
3639
TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->disconnect());
3740
}
3841

TESTS/network/wifi/wifi_get_rssi.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323

2424
using namespace utest::v1;
2525

26-
#if defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
26+
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID)
2727

2828
void wifi_get_rssi(void)
2929
{
3030
WiFiInterface *wifi = get_interface();
3131

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

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

@@ -40,4 +40,4 @@ void wifi_get_rssi(void)
4040
TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->disconnect());
4141
}
4242

43-
#endif // defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
43+
#endif // defined(MBED_CONF_APP_WIFI_SECURE_SSID)

TESTS/network/wifi/wifi_tests.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ void wifi_get_rssi(void);
4848
/** Test WiFiInterface::connect(ssid, pass, security, channel) with NULL parameters */
4949
void wifi_connect_params_null(void);
5050

51-
/** Test WiFiInterface::connect(ssid, pass, security) with valid parameters for unsecure network */
52-
void wifi_connect_params_valid_unsecure(void);
53-
5451
/** Test WiFiInterface::connect(ssid, pass, security) with valid parameters for secure network */
5552
void wifi_connect_params_valid_secure(void);
5653

0 commit comments

Comments
 (0)