Skip to content
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

Greentea wifi test cases - disconnect done as teardown after each connect #5743

Merged
merged 6 commits into from Dec 28, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions TESTS/network/wifi/wifi_connect.cpp
Expand Up @@ -32,6 +32,7 @@ void wifi_connect(void)
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->connect());
wifi->disconnect();
}

#endif // defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
2 changes: 1 addition & 1 deletion TESTS/network/wifi/wifi_connect_nocredentials.cpp
Expand Up @@ -29,5 +29,5 @@ void wifi_connect_nocredentials(void)
nsapi_error_t error;
error = wifi->connect();
wifi->disconnect();
TEST_ASSERT(error == NSAPI_ERROR_PARAMETER);
TEST_ASSERT(error == NSAPI_ERROR_NO_SSID);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also accept the NSAPI_ERROR_PARAMETER

I'm not sure that all drivers currently return this NO_SSID.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add it.

}
1 change: 1 addition & 0 deletions TESTS/network/wifi/wifi_connect_params_channel.cpp
Expand Up @@ -36,6 +36,7 @@ void wifi_connect_params_channel(void)

nsapi_error_t error = wifi->connect(MBED_CONF_APP_WIFI_SECURE_SSID, MBED_CONF_APP_WIFI_PASSWORD, NSAPI_SECURITY_WPA2, MBED_CONF_APP_WIFI_CH_SECURE);
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, error);
wifi->disconnect();
}

#endif // defined(MBED_CONF_APP_WIFI_SECURE_SSID)
1 change: 1 addition & 0 deletions TESTS/network/wifi/wifi_connect_params_null.cpp
Expand Up @@ -27,4 +27,5 @@ void wifi_connect_params_null(void)
{
WiFiInterface *wifi = get_interface();
TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_PARAMETER, wifi->connect(NULL, NULL));
wifi->disconnect();
}
4 changes: 4 additions & 0 deletions TESTS/network/wifi/wifi_connect_params_valid_secure.cpp
Expand Up @@ -30,18 +30,22 @@ 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, NSAPI_SECURITY_WPA2) == NSAPI_ERROR_OK) {
wifi->disconnect();
return;
}

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

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

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

Expand Down
1 change: 1 addition & 0 deletions TESTS/network/wifi/wifi_connect_params_valid_unsecure.cpp
Expand Up @@ -29,6 +29,7 @@ void wifi_connect_params_valid_unsecure(void)
{
WiFiInterface *wifi = get_interface();
TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->connect(MBED_CONF_APP_WIFI_UNSECURE_SSID, NULL));
wifi->disconnect();
}

#endif // defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
3 changes: 2 additions & 1 deletion TESTS/network/wifi/wifi_connect_secure.cpp
Expand Up @@ -29,9 +29,10 @@ 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, NSAPI_SECURITY_WPA2));
TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->set_credentials(MBED_CONF_APP_WIFI_SECURE_SSID, MBED_CONF_APP_WIFI_PASSWORD, NSAPI_SECURITY_WPA_WPA2));

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

#endif // defined(MBED_CONF_APP_WIFI_SECURE_SSID)
2 changes: 2 additions & 0 deletions TESTS/network/wifi/wifi_get_rssi.cpp
Expand Up @@ -36,6 +36,8 @@ void wifi_get_rssi(void)
TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->connect());

TEST_ASSERT_INT8_WITHIN(-10, -100, wifi->get_rssi());

wifi->disconnect();
}

#endif // defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
8 changes: 6 additions & 2 deletions TESTS/network/wifi/wifi_scan.cpp
Expand Up @@ -54,12 +54,16 @@ void wifi_scan(void)
if (strcmp(MBED_CONF_APP_WIFI_SECURE_SSID, ssid) == 0) {
secure_found = true;
TEST_ASSERT_EQUAL_INT(NSAPI_SECURITY_WPA2, security);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be changed also to WPA/WPA2?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it should and I'll change it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security to check against should be defined in the .json which also defines the wlan ap to connect to.

TEST_ASSERT_EQUAL_INT(MBED_CONF_APP_WIFI_CH_SECURE, ch);
if (MBED_CONF_APP_WIFI_CH_SECURE) {
TEST_ASSERT_EQUAL_INT(MBED_CONF_APP_WIFI_CH_SECURE, ch);
}
}
if (strcmp(MBED_CONF_APP_WIFI_UNSECURE_SSID, ssid) == 0) {
unsecure_found = true;
TEST_ASSERT_EQUAL_INT(NSAPI_SECURITY_NONE, security);
TEST_ASSERT_EQUAL_INT(MBED_CONF_APP_WIFI_CH_UNSECURE, ch);
if (MBED_CONF_APP_WIFI_CH_UNSECURE) {
TEST_ASSERT_EQUAL_INT(MBED_CONF_APP_WIFI_CH_UNSECURE, ch);
}
}
}
TEST_ASSERT_TRUE(secure_found);
Expand Down