Merge pull request #5605 from betzw/betzw_tests_network_wb

TESTS/NETWORK: Split Wi-Fi test for secure & unsecure tests
pull/5689/merge
Martin Kojtal 2017-12-12 17:28:56 +00:00 committed by GitHub
commit 79a8bf1c8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 66 additions and 7 deletions

View File

@ -20,7 +20,7 @@
// Pick the correct driver based on mbed_app.json
#define INTERNAL 1
#define WIFI_ESP8266 2
#define X_NUCLEO_IDW01M1 3
#define X_NUCLEO_IDW0XX1 3
#if MBED_CONF_APP_WIFI_DRIVER == INTERNAL
@ -39,7 +39,7 @@
#include "ESP8266Interface.h"
#define DRIVER ESP8266Interface
#elif MBED_CONF_APP_WIFI_DRIVER == X_NUCLEO_IDW01M1
#elif MBED_CONF_APP_WIFI_DRIVER == X_NUCLEO_IDW0XX1
#include "SpwfSAInterface.h"
#define DRIVER SpwfSAInterface
#else

View File

@ -22,19 +22,31 @@
#include "wifi_tests.h"
// Test for parameters
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID)
#if !defined(MBED_CONF_APP_AP_MAC_SECURE) || \
!defined(MBED_CONF_APP_AP_MAC_UNSECURE) || \
!defined(MBED_CONF_APP_MAX_SCAN_SIZE) || \
!defined(MBED_CONF_APP_WIFI_CH_SECURE) || \
!defined(MBED_CONF_APP_WIFI_CH_UNSECURE) || \
!defined(MBED_CONF_APP_WIFI_DRIVER) || \
!defined(MBED_CONF_APP_WIFI_PASSWORD) || \
!defined(MBED_CONF_APP_WIFI_RX) || \
!defined(MBED_CONF_APP_WIFI_SECURE_SSID) || \
!defined(MBED_CONF_APP_WIFI_TX)
#error [NOT_SUPPORTED] Requires parameters from mbed_app.json (for secure connections)
#endif
#endif // defined(MBED_CONF_APP_WIFI_SECURE_SSID)
#if defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
#if !defined(MBED_CONF_APP_AP_MAC_UNSECURE) || \
!defined(MBED_CONF_APP_MAX_SCAN_SIZE) || \
!defined(MBED_CONF_APP_WIFI_CH_UNSECURE) || \
!defined(MBED_CONF_APP_WIFI_DRIVER) || \
!defined(MBED_CONF_APP_WIFI_PASSWORD) || \
!defined(MBED_CONF_APP_WIFI_RX) || \
!defined(MBED_CONF_APP_WIFI_TX) || \
!defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
#error [NOT_SUPPORTED] Requires parameters from mbed_app.json
#error [NOT_SUPPORTED] Requires parameters from mbed_app.json (for unsecure connections)
#endif
#endif // defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
using namespace utest::v1;
@ -48,19 +60,33 @@ Case cases[] = {
Case("WIFI-CONSTRUCTOR", wifi_constructor),
Case("WIFI-SET-CREDENTIAL", wifi_set_credential),
Case("WIFI-SET-CHANNEL", wifi_set_channel),
#if defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
Case("WIFI-GET-RSSI", wifi_get_rssi),
#endif
Case("WIFI-CONNECT-PARAMS-NULL", wifi_connect_params_null),
#if defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
Case("WIFI-CONNECT-PARAMS-VALID-UNSECURE", wifi_connect_params_valid_unsecure),
#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),
#endif
Case("WIFI-CONNECT-NOCREDENTIALS", wifi_connect_nocredentials),
#if defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
Case("WIFI-CONNECT", wifi_connect),
#endif
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID)
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-DISCONNECT-REPEAT", wifi_connect_disconnect_repeat),
#endif
Case("WIFI-SCAN-NULL", wifi_scan_null),
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID) && defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
Case("WIFI-SCAN", wifi_scan),
#endif
};
Specification specification(test_setup, cases);

View File

@ -21,7 +21,7 @@
"value": 2
},
"wifi-driver": {
"help": "Wifi driver to use, valid values are INTERNAL, WIFI_ESP8266 and X_NUCLEO_IDW01M1",
"help": "Wifi driver to use, valid values are INTERNAL, WIFI_ESP8266 and X_NUCLEO_IDW0XX1",
"value": "INTERNAL"
},
"wifi-tx": {

View File

@ -23,6 +23,8 @@
using namespace utest::v1;
#if defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
void wifi_connect(void)
{
WiFiInterface *wifi = get_interface();
@ -31,3 +33,5 @@ void wifi_connect(void)
TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->connect());
}
#endif // defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)

View File

@ -23,6 +23,8 @@
using namespace utest::v1;
#if defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
void wifi_connect_disconnect_repeat(void)
{
WiFiInterface *wifi = get_interface();
@ -38,3 +40,5 @@ void wifi_connect_disconnect_repeat(void)
TEST_ASSERT(error == NSAPI_ERROR_OK);
}
}
#endif // defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)

View File

@ -23,6 +23,8 @@
using namespace utest::v1;
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID)
void wifi_connect_params_channel(void)
{
WiFiInterface *wifi = get_interface();
@ -36,3 +38,4 @@ void wifi_connect_params_channel(void)
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, error);
}
#endif // defined(MBED_CONF_APP_WIFI_SECURE_SSID)

View File

@ -23,6 +23,8 @@
using namespace utest::v1;
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID)
void wifi_connect_params_channel_fail(void)
{
WiFiInterface *wifi = get_interface();
@ -32,7 +34,8 @@ void wifi_connect_params_channel_fail(void)
return;
}
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_UNSECURE);
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(error==NSAPI_ERROR_CONNECTION_TIMEOUT || error==NSAPI_ERROR_NO_CONNECTION);
}
#endif // defined(MBED_CONF_APP_WIFI_SECURE_SSID)

View File

@ -23,8 +23,12 @@
using namespace utest::v1;
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID)
void wifi_connect_params_valid_secure(void)
{
WiFiInterface *wifi = get_interface();
TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->connect(MBED_CONF_APP_WIFI_SECURE_SSID, MBED_CONF_APP_WIFI_PASSWORD, NSAPI_SECURITY_WPA2));
}
#endif // defined(MBED_CONF_APP_WIFI_SECURE_SSID)

View File

@ -23,9 +23,12 @@
using namespace utest::v1;
#if defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
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));
}
#endif // defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)

View File

@ -23,6 +23,8 @@
using namespace utest::v1;
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID)
void wifi_connect_secure(void)
{
WiFiInterface *wifi = get_interface();
@ -32,3 +34,4 @@ void wifi_connect_secure(void)
TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->connect());
}
#endif // defined(MBED_CONF_APP_WIFI_SECURE_SSID)

View File

@ -23,6 +23,8 @@
using namespace utest::v1;
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID)
void wifi_connect_secure_fail(void)
{
WiFiInterface *wifi = get_interface();
@ -32,3 +34,4 @@ void wifi_connect_secure_fail(void)
TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_AUTH_FAILURE, wifi->connect());
}
#endif // defined(MBED_CONF_APP_WIFI_SECURE_SSID)

View File

@ -23,6 +23,8 @@
using namespace utest::v1;
#if defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
void wifi_get_rssi(void)
{
WiFiInterface *wifi = get_interface();
@ -36,3 +38,4 @@ void wifi_get_rssi(void)
TEST_ASSERT_INT8_WITHIN(-35, -65, wifi->get_rssi()); // -30 ... -100
}
#endif // defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)

View File

@ -24,6 +24,8 @@
using namespace utest::v1;
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID) && defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
void wifi_scan(void)
{
WiFiInterface *wifi = get_interface();
@ -65,3 +67,4 @@ void wifi_scan(void)
TEST_ASSERT_TRUE(unsecure_found);
}
#endif // defined(MBED_CONF_APP_WIFI_SECURE_SSID) && defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)