mirror of https://github.com/ARMmbed/mbed-os.git
Update Greentea WiFi tests
Use similar network interface configuration as used in netsocket tests Improve test coveragepull/6665/head
parent
f04f7c1773
commit
8e81d0153a
|
|
@ -15,36 +15,12 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef MBED_CONF_APP_OBJECT_CONSTRUCTION
|
||||
#error [NOT_SUPPORTED] No network interface found for this target.
|
||||
#endif
|
||||
|
||||
#include "mbed.h"
|
||||
|
||||
// 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
|
||||
#include MBED_CONF_APP_HEADER_FILE
|
||||
|
||||
WiFiInterface *get_interface()
|
||||
{
|
||||
|
|
@ -55,10 +31,7 @@ WiFiInterface *get_interface()
|
|||
return interface;
|
||||
}
|
||||
|
||||
#if MBED_CONF_APP_WIFI_DRIVER == INTERNAL
|
||||
interface = new DRIVER();
|
||||
#else
|
||||
interface = new DRIVER(MBED_CONF_APP_WIFI_TX, MBED_CONF_APP_WIFI_RX);
|
||||
#endif
|
||||
interface = MBED_CONF_APP_OBJECT_CONSTRUCTION;
|
||||
|
||||
return interface;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@
|
|||
* 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 "greentea-client/test_env.h"
|
||||
#include "unity.h"
|
||||
|
|
@ -26,11 +30,8 @@
|
|||
#if !defined(MBED_CONF_APP_AP_MAC_SECURE) || \
|
||||
!defined(MBED_CONF_APP_MAX_SCAN_SIZE) || \
|
||||
!defined(MBED_CONF_APP_WIFI_CH_SECURE) || \
|
||||
!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) || \
|
||||
!defined MBED_CONF_APP_WIFI_SECURE_PROTOCOL
|
||||
#error [NOT_SUPPORTED] Requires parameters from mbed_app.json (for secure connections)
|
||||
#endif
|
||||
|
|
@ -40,10 +41,7 @@
|
|||
#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 (for unsecure connections)
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -24,17 +24,12 @@
|
|||
"help": "Channel number of unsecure SSID",
|
||||
"value": 2
|
||||
},
|
||||
"wifi-driver": {
|
||||
"help": "Wifi driver to use, valid values are INTERNAL, WIFI_ESP8266 and X_NUCLEO_IDW0XX1",
|
||||
"value": "INTERNAL"
|
||||
"header-file": {
|
||||
"help" : "String for including your driver header file",
|
||||
"value" : "\"WIFI_INTERFACE.h\""
|
||||
},
|
||||
"wifi-tx": {
|
||||
"help": "TX pin for serial connection to external device",
|
||||
"value": "D1"
|
||||
},
|
||||
"wifi-rx": {
|
||||
"help": "RX pin for serial connection to external device",
|
||||
"value": "D0"
|
||||
"object-construction" : {
|
||||
"value" : "new WIFI_INTERFACE()"
|
||||
},
|
||||
"ap-mac-secure": {
|
||||
"help": "BSSID of secure AP in form of AA:BB:CC:DD:EE:FF",
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_PARAMETER, wifi->connect("", ""));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,9 @@ 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));
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ void wifi_set_channel(void)
|
|||
|
||||
if (is_2Ghz) {
|
||||
error = wifi->set_channel(0);
|
||||
TEST_ASSERT(error == NSAPI_ERROR_PARAMETER);
|
||||
TEST_ASSERT(error == NSAPI_ERROR_OK);
|
||||
error = wifi->set_channel(1);
|
||||
TEST_ASSERT(error == NSAPI_ERROR_OK);
|
||||
error = wifi->set_channel(13);
|
||||
|
|
|
|||
|
|
@ -31,15 +31,27 @@ void wifi_set_credential(void)
|
|||
error = iface->set_credentials(NULL, NULL, NSAPI_SECURITY_NONE);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
TEST_ASSERT(error == NSAPI_ERROR_OK);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue