Update Greentea WiFi tests

Use similar network interface configuration as used in netsocket tests
Improve test coverage
pull/6665/head
Juha Ylinen 2018-05-04 12:23:55 +03:00 committed by Seppo Takalo
parent f04f7c1773
commit 8e81d0153a
7 changed files with 33 additions and 51 deletions

View File

@ -15,36 +15,12 @@
* limitations under the License. * limitations under the License.
*/ */
#ifndef MBED_CONF_APP_OBJECT_CONSTRUCTION
#error [NOT_SUPPORTED] No network interface found for this target.
#endif
#include "mbed.h" #include "mbed.h"
#include MBED_CONF_APP_HEADER_FILE
// Pick the correct driver based on mbed_app.json
#define INTERNAL 1
#define WIFI_ESP8266 2
#define X_NUCLEO_IDW0XX1 3
#if MBED_CONF_APP_WIFI_DRIVER == INTERNAL
#if TARGET_UBLOX_EVK_ODIN_W2
#include "OdinWiFiInterface.h"
#define DRIVER OdinWiFiInterface
#elif TARGET_REALTEK_RTL8195AM
#include "RTWInterface.h"
#define DRIVER RTWInterface
#else
#error [NOT_SUPPORTED] Unsupported Wifi driver
#endif
#elif MBED_CONF_APP_WIFI_DRIVER == WIFI_ESP8266
#include "ESP8266Interface.h"
#define DRIVER ESP8266Interface
#elif MBED_CONF_APP_WIFI_DRIVER == X_NUCLEO_IDW0XX1
#include "SpwfSAInterface.h"
#define DRIVER SpwfSAInterface
#else
#error [NOT_SUPPORTED] Unsupported Wifi driver
#endif
WiFiInterface *get_interface() WiFiInterface *get_interface()
{ {
@ -55,10 +31,7 @@ WiFiInterface *get_interface()
return interface; return interface;
} }
#if MBED_CONF_APP_WIFI_DRIVER == INTERNAL interface = MBED_CONF_APP_OBJECT_CONSTRUCTION;
interface = new DRIVER();
#else
interface = new DRIVER(MBED_CONF_APP_WIFI_TX, MBED_CONF_APP_WIFI_RX);
#endif
return interface; return interface;
} }

View File

@ -15,6 +15,10 @@
* limitations under the License. * limitations under the License.
*/ */
#ifndef MBED_CONF_APP_OBJECT_CONSTRUCTION
#error [NOT_SUPPORTED] No network interface found for this target.
#endif
#include "mbed.h" #include "mbed.h"
#include "greentea-client/test_env.h" #include "greentea-client/test_env.h"
#include "unity.h" #include "unity.h"
@ -26,11 +30,8 @@
#if !defined(MBED_CONF_APP_AP_MAC_SECURE) || \ #if !defined(MBED_CONF_APP_AP_MAC_SECURE) || \
!defined(MBED_CONF_APP_MAX_SCAN_SIZE) || \ !defined(MBED_CONF_APP_MAX_SCAN_SIZE) || \
!defined(MBED_CONF_APP_WIFI_CH_SECURE) || \ !defined(MBED_CONF_APP_WIFI_CH_SECURE) || \
!defined(MBED_CONF_APP_WIFI_DRIVER) || \
!defined(MBED_CONF_APP_WIFI_PASSWORD) || \ !defined(MBED_CONF_APP_WIFI_PASSWORD) || \
!defined(MBED_CONF_APP_WIFI_RX) || \
!defined(MBED_CONF_APP_WIFI_SECURE_SSID) || \ !defined(MBED_CONF_APP_WIFI_SECURE_SSID) || \
!defined(MBED_CONF_APP_WIFI_TX) || \
!defined MBED_CONF_APP_WIFI_SECURE_PROTOCOL !defined MBED_CONF_APP_WIFI_SECURE_PROTOCOL
#error [NOT_SUPPORTED] Requires parameters from mbed_app.json (for secure connections) #error [NOT_SUPPORTED] Requires parameters from mbed_app.json (for secure connections)
#endif #endif
@ -40,10 +41,7 @@
#if !defined(MBED_CONF_APP_AP_MAC_UNSECURE) || \ #if !defined(MBED_CONF_APP_AP_MAC_UNSECURE) || \
!defined(MBED_CONF_APP_MAX_SCAN_SIZE) || \ !defined(MBED_CONF_APP_MAX_SCAN_SIZE) || \
!defined(MBED_CONF_APP_WIFI_CH_UNSECURE) || \ !defined(MBED_CONF_APP_WIFI_CH_UNSECURE) || \
!defined(MBED_CONF_APP_WIFI_DRIVER) || \
!defined(MBED_CONF_APP_WIFI_PASSWORD) || \ !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) !defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
#error [NOT_SUPPORTED] Requires parameters from mbed_app.json (for unsecure connections) #error [NOT_SUPPORTED] Requires parameters from mbed_app.json (for unsecure connections)
#endif #endif

View File

@ -24,17 +24,12 @@
"help": "Channel number of unsecure SSID", "help": "Channel number of unsecure SSID",
"value": 2 "value": 2
}, },
"wifi-driver": { "header-file": {
"help": "Wifi driver to use, valid values are INTERNAL, WIFI_ESP8266 and X_NUCLEO_IDW0XX1", "help" : "String for including your driver header file",
"value": "INTERNAL" "value" : "\"WIFI_INTERFACE.h\""
}, },
"wifi-tx": { "object-construction" : {
"help": "TX pin for serial connection to external device", "value" : "new WIFI_INTERFACE()"
"value": "D1"
},
"wifi-rx": {
"help": "RX pin for serial connection to external device",
"value": "D0"
}, },
"ap-mac-secure": { "ap-mac-secure": {
"help": "BSSID of secure AP in form of AA:BB:CC:DD:EE:FF", "help": "BSSID of secure AP in form of AA:BB:CC:DD:EE:FF",

View File

@ -27,4 +27,5 @@ void wifi_connect_params_null(void)
{ {
WiFiInterface *wifi = get_interface(); WiFiInterface *wifi = get_interface();
TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_PARAMETER, wifi->connect(NULL, NULL)); TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_PARAMETER, wifi->connect(NULL, NULL));
TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_PARAMETER, wifi->connect("", ""));
} }

View File

@ -29,6 +29,9 @@ void wifi_connect_params_valid_unsecure(void)
{ {
WiFiInterface *wifi = get_interface(); WiFiInterface *wifi = get_interface();
TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->connect(MBED_CONF_APP_WIFI_UNSECURE_SSID, NULL)); TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->connect(MBED_CONF_APP_WIFI_UNSECURE_SSID, NULL));
TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->disconnect());
TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->connect(MBED_CONF_APP_WIFI_UNSECURE_SSID, ""));
TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->disconnect());
} }
#endif // defined(MBED_CONF_APP_WIFI_UNSECURE_SSID) #endif // defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)

View File

@ -51,7 +51,7 @@ void wifi_set_channel(void)
if (is_2Ghz) { if (is_2Ghz) {
error = wifi->set_channel(0); error = wifi->set_channel(0);
TEST_ASSERT(error == NSAPI_ERROR_PARAMETER); TEST_ASSERT(error == NSAPI_ERROR_OK);
error = wifi->set_channel(1); error = wifi->set_channel(1);
TEST_ASSERT(error == NSAPI_ERROR_OK); TEST_ASSERT(error == NSAPI_ERROR_OK);
error = wifi->set_channel(13); error = wifi->set_channel(13);

View File

@ -31,15 +31,27 @@ void wifi_set_credential(void)
error = iface->set_credentials(NULL, NULL, NSAPI_SECURITY_NONE); error = iface->set_credentials(NULL, NULL, NSAPI_SECURITY_NONE);
TEST_ASSERT(error == NSAPI_ERROR_PARAMETER); TEST_ASSERT(error == NSAPI_ERROR_PARAMETER);
error = iface->set_credentials("", "", NSAPI_SECURITY_NONE);
TEST_ASSERT(error == NSAPI_ERROR_PARAMETER);
error = iface->set_credentials("OK", NULL, NSAPI_SECURITY_NONE); error = iface->set_credentials("OK", NULL, NSAPI_SECURITY_NONE);
TEST_ASSERT(error == NSAPI_ERROR_OK); TEST_ASSERT(error == NSAPI_ERROR_OK);
error = iface->set_credentials("OK", "", NSAPI_SECURITY_NONE);
TEST_ASSERT(error == NSAPI_ERROR_OK);
error = iface->set_credentials("OK", NULL, NSAPI_SECURITY_WEP); error = iface->set_credentials("OK", NULL, NSAPI_SECURITY_WEP);
TEST_ASSERT(error == NSAPI_ERROR_PARAMETER); TEST_ASSERT(error == NSAPI_ERROR_PARAMETER);
error = iface->set_credentials("OK", "", NSAPI_SECURITY_WEP);
TEST_ASSERT(error == NSAPI_ERROR_PARAMETER);
error = iface->set_credentials("OK", NULL, NSAPI_SECURITY_WPA_WPA2); error = iface->set_credentials("OK", NULL, NSAPI_SECURITY_WPA_WPA2);
TEST_ASSERT(error == NSAPI_ERROR_PARAMETER); TEST_ASSERT(error == NSAPI_ERROR_PARAMETER);
error = iface->set_credentials("OK", "", NSAPI_SECURITY_WPA_WPA2);
TEST_ASSERT(error == NSAPI_ERROR_PARAMETER);
error = iface->set_credentials("OK", NULL, NSAPI_SECURITY_NONE); error = iface->set_credentials("OK", NULL, NSAPI_SECURITY_NONE);
TEST_ASSERT(error == NSAPI_ERROR_OK); TEST_ASSERT(error == NSAPI_ERROR_OK);