From 3d87507c98f42f42aa9a4814c666933c2ae99d2d Mon Sep 17 00:00:00 2001 From: Seppo Takalo Date: Tue, 19 Sep 2017 20:16:36 +0300 Subject: [PATCH 1/8] Implement functional Wifi tests Implement 100% function coverage for WifiInterface as specified in "Wifi test plan" --- TESTS/network/wifi/get_interface.cpp | 21 ++ TESTS/network/wifi/main.cpp | 211 +++--------------- TESTS/network/wifi/wifi-constructor.cpp | 12 + TESTS/network/wifi/wifi_connect.cpp | 16 ++ .../wifi/wifi_connect_disconnect_repeat.cpp | 23 ++ .../wifi/wifi_connect_nocredentials.cpp | 16 ++ .../wifi/wifi_connect_params_channel.cpp | 21 ++ .../wifi/wifi_connect_params_channel_fail.cpp | 21 ++ .../network/wifi/wifi_connect_params_null.cpp | 13 ++ .../wifi/wifi_connect_params_valid_secure.cpp | 13 ++ .../wifi_connect_params_valid_unsecure.cpp | 14 ++ TESTS/network/wifi/wifi_connect_secure.cpp | 17 ++ .../network/wifi/wifi_connect_secure_fail.cpp | 17 ++ TESTS/network/wifi/wifi_get_rssi.cpp | 21 ++ TESTS/network/wifi/wifi_scan.cpp | 50 +++++ TESTS/network/wifi/wifi_scan_null.cpp | 14 ++ TESTS/network/wifi/wifi_set_channel.cpp | 56 +++++ TESTS/network/wifi/wifi_set_credential.cpp | 37 +++ TESTS/network/wifi/wifi_tests.h | 26 +++ 19 files changed, 435 insertions(+), 184 deletions(-) create mode 100644 TESTS/network/wifi/get_interface.cpp create mode 100644 TESTS/network/wifi/wifi-constructor.cpp create mode 100644 TESTS/network/wifi/wifi_connect.cpp create mode 100644 TESTS/network/wifi/wifi_connect_disconnect_repeat.cpp create mode 100644 TESTS/network/wifi/wifi_connect_nocredentials.cpp create mode 100644 TESTS/network/wifi/wifi_connect_params_channel.cpp create mode 100644 TESTS/network/wifi/wifi_connect_params_channel_fail.cpp create mode 100644 TESTS/network/wifi/wifi_connect_params_null.cpp create mode 100644 TESTS/network/wifi/wifi_connect_params_valid_secure.cpp create mode 100644 TESTS/network/wifi/wifi_connect_params_valid_unsecure.cpp create mode 100644 TESTS/network/wifi/wifi_connect_secure.cpp create mode 100644 TESTS/network/wifi/wifi_connect_secure_fail.cpp create mode 100644 TESTS/network/wifi/wifi_get_rssi.cpp create mode 100644 TESTS/network/wifi/wifi_scan.cpp create mode 100644 TESTS/network/wifi/wifi_scan_null.cpp create mode 100644 TESTS/network/wifi/wifi_set_channel.cpp create mode 100644 TESTS/network/wifi/wifi_set_credential.cpp create mode 100644 TESTS/network/wifi/wifi_tests.h diff --git a/TESTS/network/wifi/get_interface.cpp b/TESTS/network/wifi/get_interface.cpp new file mode 100644 index 0000000000..54e2bb2a96 --- /dev/null +++ b/TESTS/network/wifi/get_interface.cpp @@ -0,0 +1,21 @@ +#include "mbed.h" +#include "ESP8266Interface.h" + +WiFiInterface *get_interface() +{ + static WiFiInterface *interface = NULL; + + if (interface) + delete interface; + +#if TARGET_UBLOX_EVK_ODIN_W2 +#include "OdinWiFiInterface.h" + interface = new OdinWiFiInterface(); +#elif TARGET_REALTEK_RTL8195AM +#include "RTWInterface.h" + interface = new RTWInterface(); +#else + interface = new ESP8266Interface(D1, D0); +#endif + return interface; +} diff --git a/TESTS/network/wifi/main.cpp b/TESTS/network/wifi/main.cpp index c242a8c291..9c029910df 100644 --- a/TESTS/network/wifi/main.cpp +++ b/TESTS/network/wifi/main.cpp @@ -1,196 +1,39 @@ -/* mbed Microcontroller Library - * Copyright (c) 2016 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "utest/utest.h" -#include "unity/unity.h" -#include "greentea-client/test_env.h" - #include "mbed.h" - -#if TARGET_UBLOX_EVK_ODIN_W2 -#include "OdinWiFiInterface.h" -#else -#error [NOT_SUPPORTED] Only built in WiFi modules are supported at this time. -#endif +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" using namespace utest::v1; -/** - * WiFi tests require following macros to be defined: - * - MBED_CONF_APP_WIFI_SSID - SSID of a network the test will try connecting to - * - MBED_CONF_APP_WIFI_PASSWORD - Passphrase that will be used to connecting to the network - * - WIFI_TEST_NETWORKS - List of network that presence will be asserted e.g. "net1", "net2", "net3" - */ -#if !defined(MBED_CONF_APP_WIFI_SSID) || !defined(MBED_CONF_APP_WIFI_PASSWORD) || !defined(MBED_CONF_APP_WIFI_NETWORKS) -#error [NOT_SUPPORTED] MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD and MBED_CONF_APP_WIFI_NETWORKS have to be defined for this test. -#endif - -const char *networks[] = {MBED_CONF_APP_WIFI_NETWORKS, NULL}; - -WiFiInterface *wifi; - -/* In normal circumstances the WiFi object could be global, but the delay introduced by WiFi initialization is an issue - for the tests. It causes Greentea to timeout on syncing with the board. To solve it we defer the actual object - creation till we actually need it. - */ -WiFiInterface *get_wifi() -{ - if (wifi == NULL) { - /* We don't really care about freeing this, as its lifetime is through the full test suit run. */ -#if TARGET_UBLOX_EVK_ODIN_W2 - wifi = new OdinWiFiInterface; -#endif - } - - return wifi; -} - -void check_wifi(const char *ssid, bool *net_stat) -{ - int i = 0; - while(networks[i]) { - if (strcmp(networks[i], ssid) == 0) { - net_stat[i] = true; - break; - } - i++; - } -} - -void wifi_scan() -{ - int count; - WiFiAccessPoint *aps; - const int net_len = sizeof(networks)/sizeof(networks[0]); - bool net_stat[net_len - 1]; - - memset(net_stat, 0, sizeof(net_stat)); - - count = get_wifi()->scan(NULL, 0); - TEST_ASSERT_MESSAGE(count >= 0, "WiFi interface returned error"); - TEST_ASSERT_MESSAGE(count > 0, "Scan result empty"); - - aps = new WiFiAccessPoint[count]; - count = get_wifi()->scan(aps, count); - for(int i = 0; i < count; i++) { - check_wifi(aps[i].get_ssid(), net_stat); - } - - delete[] aps; - - for (unsigned i = 0; i < sizeof(net_stat); i++) { - TEST_ASSERT_MESSAGE(net_stat[i] == true, "Not all required WiFi network detected"); - } -} - -void wifi_connect() -{ - int ret; - - ret = get_wifi()->connect(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD, NSAPI_SECURITY_WPA_WPA2); - TEST_ASSERT_MESSAGE(ret == 0, "Connect failed"); - - ret = get_wifi()->disconnect(); - TEST_ASSERT_MESSAGE(ret == 0, "Disconnect failed"); -} - -void wifi_connect_scan() -{ - int ret; - int count; - WiFiAccessPoint *aps; - const int net_len = sizeof(networks)/sizeof(networks[0]); - bool net_stat[net_len - 1]; - - memset(net_stat, 0, sizeof(net_stat)); - - ret = get_wifi()->connect(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD, NSAPI_SECURITY_WPA_WPA2); - TEST_ASSERT_MESSAGE(ret == 0, "Connect failed"); - - count = get_wifi()->scan(NULL, 0); - TEST_ASSERT_MESSAGE(count >= 0, "WiFi interface returned error"); - TEST_ASSERT_MESSAGE(count > 0, "Scan result empty"); - - aps = new WiFiAccessPoint[count]; - count = get_wifi()->scan(aps, count); - for(int i = 0; i < count; i++) { - check_wifi(aps[i].get_ssid(), net_stat); - } - - delete[] aps; - - ret = get_wifi()->disconnect(); - TEST_ASSERT_MESSAGE(ret == 0, "Disconnect failed"); - - for (unsigned i = 0; i < sizeof(net_stat); i++) { - TEST_ASSERT_MESSAGE(net_stat[i] == true, "Not all required WiFi network detected"); - } -} - -void wifi_http() -{ - TCPSocket socket; - int ret; - - ret = get_wifi()->connect(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD, NSAPI_SECURITY_WPA_WPA2); - TEST_ASSERT_MESSAGE(ret == 0, "Connect failed"); - - // Open a socket on the network interface, and create a TCP connection to www.arm.com - ret = socket.open(get_wifi()); - TEST_ASSERT_MESSAGE(ret == 0, "Socket open failed"); - ret = socket.connect("www.arm.com", 80); - TEST_ASSERT_MESSAGE(ret == 0, "Socket connect failed"); - - // Send a simple http request - char sbuffer[] = "GET / HTTP/1.1\r\nHost: www.arm.com\r\n\r\n"; - int scount = socket.send(sbuffer, sizeof sbuffer); - TEST_ASSERT_MESSAGE(scount >= 0, "Socket send failed"); - - // Recieve a simple http response and check if it's not empty - char rbuffer[64]; - int rcount = socket.recv(rbuffer, sizeof rbuffer); - TEST_ASSERT_MESSAGE(rcount >= 0, "Socket recv error"); - TEST_ASSERT_MESSAGE(rcount > 0, "No data received"); - - ret = socket.close(); - TEST_ASSERT_MESSAGE(ret == 0, "Socket close failed"); - - ret = get_wifi()->disconnect(); - TEST_ASSERT_MESSAGE(ret == 0, "Disconnect failed"); -} - -status_t greentea_failure_handler(const Case *const source, const failure_t reason) { - greentea_case_failure_abort_handler(source, reason); - return STATUS_CONTINUE; +utest::v1::status_t test_setup(const size_t number_of_cases) { + GREENTEA_SETUP(120, "default_auto"); + return verbose_test_setup_handler(number_of_cases); } +// Test cases Case cases[] = { - Case("Scan test", wifi_scan, greentea_failure_handler), - Case("Connect test", wifi_connect, greentea_failure_handler), - Case("Scan while connected test", wifi_connect_scan, greentea_failure_handler), - Case("HTTP test", wifi_http, greentea_failure_handler), + Case("WIFI-CONSTRUCTOR", wifi_constructor), + Case("WIFI-SET-CREDENTIAL", wifi_set_credential), + Case("WIFI-SET-CHANNEL", wifi_set_channel), + Case("WIFI-GET-RSSI", wifi_get_rssi), + Case("WIFI-CONNECT-PARAMS-NULL", wifi_connect_params_null), + Case("WIFI-CONNECT-PARAMS-VALID-UNSECURE", wifi_connect_params_valid_unsecure), + 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), + Case("WIFI-CONNECT-NOCREDENTIALS", wifi_connect_nocredentials), + Case("WIFI-CONNECT", wifi_connect), + Case("WIFI-CONNECT-SECURE", wifi_connect_secure), + Case("WIFI-CONNECT-SECURE-FAIL", wifi_connect_secure_fail), + Case("WIFI-CONNECT-DISCONNECT-REPEAT", wifi_connect_disconnect_repeat), + Case("WIFI-SCAN-NULL", wifi_scan_null), + Case("WIFI-SCAN", wifi_scan), }; -status_t greentea_test_setup(const size_t number_of_cases) { - GREENTEA_SETUP(90, "default_auto"); - return greentea_test_setup_handler(number_of_cases); -} - +Specification specification(test_setup, cases); +// Entry point into the tests int main() { - Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler); - Harness::run(specification); + return !Harness::run(specification); } diff --git a/TESTS/network/wifi/wifi-constructor.cpp b/TESTS/network/wifi/wifi-constructor.cpp new file mode 100644 index 0000000000..d2cffb3626 --- /dev/null +++ b/TESTS/network/wifi/wifi-constructor.cpp @@ -0,0 +1,12 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" + +using namespace utest::v1; + +void wifi_constructor() { + WiFiInterface *wifi = get_interface(); + TEST_ASSERT(wifi); +} diff --git a/TESTS/network/wifi/wifi_connect.cpp b/TESTS/network/wifi/wifi_connect.cpp new file mode 100644 index 0000000000..2d6ac51444 --- /dev/null +++ b/TESTS/network/wifi/wifi_connect.cpp @@ -0,0 +1,16 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" + +using namespace utest::v1; + +void wifi_connect(void) +{ + WiFiInterface *wifi = get_interface(); + + 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()); +} diff --git a/TESTS/network/wifi/wifi_connect_disconnect_repeat.cpp b/TESTS/network/wifi/wifi_connect_disconnect_repeat.cpp new file mode 100644 index 0000000000..971de306ff --- /dev/null +++ b/TESTS/network/wifi/wifi_connect_disconnect_repeat.cpp @@ -0,0 +1,23 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" + +using namespace utest::v1; + +void wifi_connect_disconnect_repeat(void) +{ + WiFiInterface *wifi = get_interface(); + nsapi_error_t error; + + error = wifi->set_credentials(MBED_CONF_APP_WIFI_UNSECURE_SSID, NULL); + TEST_ASSERT(error == NSAPI_ERROR_OK); + + for(int i=0; i<10; i++) { + error = wifi->connect(); + TEST_ASSERT(error == NSAPI_ERROR_OK); + error = wifi->disconnect(); + TEST_ASSERT(error == NSAPI_ERROR_OK); + } +} diff --git a/TESTS/network/wifi/wifi_connect_nocredentials.cpp b/TESTS/network/wifi/wifi_connect_nocredentials.cpp new file mode 100644 index 0000000000..f540328aeb --- /dev/null +++ b/TESTS/network/wifi/wifi_connect_nocredentials.cpp @@ -0,0 +1,16 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" + +using namespace utest::v1; + +void wifi_connect_nocredentials(void) +{ + WiFiInterface *wifi = get_interface(); + nsapi_error_t error; + error = wifi->connect(); + wifi->disconnect(); + TEST_ASSERT(error == NSAPI_ERROR_PARAMETER); +} diff --git a/TESTS/network/wifi/wifi_connect_params_channel.cpp b/TESTS/network/wifi/wifi_connect_params_channel.cpp new file mode 100644 index 0000000000..c440470a9d --- /dev/null +++ b/TESTS/network/wifi/wifi_connect_params_channel.cpp @@ -0,0 +1,21 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" + +using namespace utest::v1; + +void wifi_connect_params_channel(void) +{ + WiFiInterface *wifi = get_interface(); + + if (wifi->set_channel(1) == NSAPI_ERROR_UNSUPPORTED && wifi->set_channel(36) == NSAPI_ERROR_UNSUPPORTED) { + TEST_IGNORE_MESSAGE("set_channel() not supported"); + 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_SECURE); + TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, error); +} + diff --git a/TESTS/network/wifi/wifi_connect_params_channel_fail.cpp b/TESTS/network/wifi/wifi_connect_params_channel_fail.cpp new file mode 100644 index 0000000000..d5d9733a15 --- /dev/null +++ b/TESTS/network/wifi/wifi_connect_params_channel_fail.cpp @@ -0,0 +1,21 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" + +using namespace utest::v1; + +void wifi_connect_params_channel_fail(void) +{ + WiFiInterface *wifi = get_interface(); + + if (wifi->set_channel(1) == NSAPI_ERROR_UNSUPPORTED && wifi->set_channel(36) == NSAPI_ERROR_UNSUPPORTED) { + TEST_IGNORE_MESSAGE("set_channel() not supported"); + 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); + TEST_ASSERT(error==NSAPI_ERROR_CONNECTION_TIMEOUT || error==NSAPI_ERROR_NO_CONNECTION); +} + diff --git a/TESTS/network/wifi/wifi_connect_params_null.cpp b/TESTS/network/wifi/wifi_connect_params_null.cpp new file mode 100644 index 0000000000..22f7c1917d --- /dev/null +++ b/TESTS/network/wifi/wifi_connect_params_null.cpp @@ -0,0 +1,13 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" + +using namespace utest::v1; + +void wifi_connect_params_null(void) +{ + WiFiInterface *wifi = get_interface(); + TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_PARAMETER, wifi->connect(NULL, NULL)); +} diff --git a/TESTS/network/wifi/wifi_connect_params_valid_secure.cpp b/TESTS/network/wifi/wifi_connect_params_valid_secure.cpp new file mode 100644 index 0000000000..ba906a20d7 --- /dev/null +++ b/TESTS/network/wifi/wifi_connect_params_valid_secure.cpp @@ -0,0 +1,13 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" + +using namespace utest::v1; + +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)); +} diff --git a/TESTS/network/wifi/wifi_connect_params_valid_unsecure.cpp b/TESTS/network/wifi/wifi_connect_params_valid_unsecure.cpp new file mode 100644 index 0000000000..4a63e664f0 --- /dev/null +++ b/TESTS/network/wifi/wifi_connect_params_valid_unsecure.cpp @@ -0,0 +1,14 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" + +using namespace utest::v1; + +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)); +} + diff --git a/TESTS/network/wifi/wifi_connect_secure.cpp b/TESTS/network/wifi/wifi_connect_secure.cpp new file mode 100644 index 0000000000..b6d47051cf --- /dev/null +++ b/TESTS/network/wifi/wifi_connect_secure.cpp @@ -0,0 +1,17 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" + +using namespace utest::v1; + +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->connect()); +} + diff --git a/TESTS/network/wifi/wifi_connect_secure_fail.cpp b/TESTS/network/wifi/wifi_connect_secure_fail.cpp new file mode 100644 index 0000000000..9b271f7fcb --- /dev/null +++ b/TESTS/network/wifi/wifi_connect_secure_fail.cpp @@ -0,0 +1,17 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" + +using namespace utest::v1; + +void wifi_connect_secure_fail(void) +{ + WiFiInterface *wifi = get_interface(); + + TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->set_credentials(MBED_CONF_APP_WIFI_SECURE_SSID, "aaaaaaaa", NSAPI_SECURITY_WPA2)); + + TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_AUTH_FAILURE, wifi->connect()); +} + diff --git a/TESTS/network/wifi/wifi_get_rssi.cpp b/TESTS/network/wifi/wifi_get_rssi.cpp new file mode 100644 index 0000000000..7c980c5e28 --- /dev/null +++ b/TESTS/network/wifi/wifi_get_rssi.cpp @@ -0,0 +1,21 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" + +using namespace utest::v1; + +void wifi_get_rssi(void) +{ + WiFiInterface *wifi = get_interface(); + + TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->set_credentials(MBED_CONF_APP_WIFI_UNSECURE_SSID, NULL)); + + TEST_ASSERT_EQUAL_INT8(0, wifi->get_rssi()); + + TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->connect()); + + TEST_ASSERT_INT8_WITHIN(-35, -65, wifi->get_rssi()); // -30 ... -100 +} + diff --git a/TESTS/network/wifi/wifi_scan.cpp b/TESTS/network/wifi/wifi_scan.cpp new file mode 100644 index 0000000000..a9aa057873 --- /dev/null +++ b/TESTS/network/wifi/wifi_scan.cpp @@ -0,0 +1,50 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" +#include + +using namespace utest::v1; + +void wifi_scan(void) +{ + WiFiInterface *wifi = get_interface(); + + WiFiAccessPoint ap[MBED_CONF_APP_MAX_SCAN_SIZE]; + + int size = wifi->scan(ap, MBED_CONF_APP_MAX_SCAN_SIZE); + TEST_ASSERT(size >= 2); + + bool secure_found = false; + bool unsecure_found = false; + + char secure_bssid[6]; + char unsecure_bssid[6]; + const char *coversion_string = "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx"; + TEST_ASSERT_EQUAL_INT_MESSAGE(6, sscanf(MBED_CONF_APP_AP_MAC_SECURE, coversion_string, &secure_bssid[0], &secure_bssid[1], &secure_bssid[2], &secure_bssid[3], &secure_bssid[4], &secure_bssid[5]), "Failed to convert ap-mac-secure from mbed_app.json"); + TEST_ASSERT_EQUAL_INT_MESSAGE(6, sscanf(MBED_CONF_APP_AP_MAC_UNSECURE, coversion_string, &unsecure_bssid[0], &unsecure_bssid[1], &unsecure_bssid[2], &unsecure_bssid[3], &unsecure_bssid[4], &unsecure_bssid[5]), "Failed to convert ap-mac-unsecure from mbed_app.json"); + + for (int i=0; iscan(NULL, 0) >= 2); +} + diff --git a/TESTS/network/wifi/wifi_set_channel.cpp b/TESTS/network/wifi/wifi_set_channel.cpp new file mode 100644 index 0000000000..f7681b136f --- /dev/null +++ b/TESTS/network/wifi/wifi_set_channel.cpp @@ -0,0 +1,56 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" +#include + +using namespace utest::v1; + +void wifi_set_channel(void) +{ + bool is_2Ghz = false; + bool is_5Ghz = false; + + WiFiInterface *wifi = get_interface(); + + if (wifi->set_channel(1) == NSAPI_ERROR_UNSUPPORTED && wifi->set_channel(36) == NSAPI_ERROR_UNSUPPORTED) { + TEST_IGNORE_MESSAGE("set_channel() not supported"); + return; + } + + nsapi_error_t error; + error = wifi->set_channel(1); + if (error == NSAPI_ERROR_OK) { + is_2Ghz = true; + } + + error = wifi->set_channel(30); + if (error == NSAPI_ERROR_OK) { + is_5Ghz = true; + } + + TEST_ASSERT(is_2Ghz || is_5Ghz); + + if (is_2Ghz) { + error = wifi->set_channel(0); + TEST_ASSERT(error == NSAPI_ERROR_PARAMETER); + error = wifi->set_channel(1); + TEST_ASSERT(error == NSAPI_ERROR_OK); + error = wifi->set_channel(13); + TEST_ASSERT(error == NSAPI_ERROR_OK || error == NSAPI_ERROR_PARAMETER); + error = wifi->set_channel(15); + TEST_ASSERT(error == NSAPI_ERROR_PARAMETER); + } + + if (is_5Ghz) { + error = wifi->set_channel(30); + TEST_ASSERT(error == NSAPI_ERROR_PARAMETER); + error = wifi->set_channel(36); + TEST_ASSERT(error == NSAPI_ERROR_OK); + error = wifi->set_channel(169); + TEST_ASSERT(error == NSAPI_ERROR_PARAMETER); + } + +} + diff --git a/TESTS/network/wifi/wifi_set_credential.cpp b/TESTS/network/wifi/wifi_set_credential.cpp new file mode 100644 index 0000000000..b08df974fc --- /dev/null +++ b/TESTS/network/wifi/wifi_set_credential.cpp @@ -0,0 +1,37 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" + +using namespace utest::v1; + +void wifi_set_credential(void) +{ + WiFiInterface *iface = get_interface(); + nsapi_error_t error; + + error = iface->set_credentials(NULL, NULL, 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", NULL, 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", "12345678", NSAPI_SECURITY_WPA); + TEST_ASSERT(error == NSAPI_ERROR_OK); + + error = iface->set_credentials("OK", "12345678", NSAPI_SECURITY_WPA2); + TEST_ASSERT(error == NSAPI_ERROR_OK); + + error = iface->set_credentials("OK", "12345678", NSAPI_SECURITY_WPA_WPA2); + TEST_ASSERT(error == NSAPI_ERROR_OK); + + error = iface->set_credentials("OK", "kUjd0PHHeAqaDoyfcDDEOvbyiVbYMpUHDukGoR6EJZnO5iLzWsfwiM9JQqOngni82", NSAPI_SECURITY_WPA2); + TEST_ASSERT(error == NSAPI_ERROR_PARAMETER); +} diff --git a/TESTS/network/wifi/wifi_tests.h b/TESTS/network/wifi/wifi_tests.h new file mode 100644 index 0000000000..0d66fb689d --- /dev/null +++ b/TESTS/network/wifi/wifi_tests.h @@ -0,0 +1,26 @@ +#ifndef WIFI_TESTS_H +#define WIFI_TESTS_H + +#include "WiFiInterface.h" + +WiFiInterface *get_interface(void); + +/* Test cases */ +void wifi_constructor(void); +void wifi_set_credential(void); +void wifi_set_channel(void); +void wifi_get_rssi(void); +void wifi_connect_params_null(void); +void wifi_connect_params_valid_unsecure(void); +void wifi_connect_params_valid_secure(void); +void wifi_connect_params_channel(void); +void wifi_connect_params_channel_fail(void); +void wifi_connect(void); +void wifi_connect_nocredentials(void); +void wifi_connect_secure(void); +void wifi_connect_secure_fail(void); +void wifi_connect_disconnect_repeat(void); +void wifi_scan_null(void); +void wifi_scan(void); + +#endif //WIFI_TESTS_H From 3ac788fa0259ea2c4e6176c15ed3c6c371f09bf5 Mon Sep 17 00:00:00 2001 From: Seppo Takalo Date: Tue, 19 Sep 2017 20:16:36 +0300 Subject: [PATCH 2/8] Set timeout to 4 minutes. Wifi connections and scanning takes long time. 2 minutes might not be enough. --- TESTS/network/wifi/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TESTS/network/wifi/main.cpp b/TESTS/network/wifi/main.cpp index 9c029910df..754df739d5 100644 --- a/TESTS/network/wifi/main.cpp +++ b/TESTS/network/wifi/main.cpp @@ -7,7 +7,7 @@ using namespace utest::v1; utest::v1::status_t test_setup(const size_t number_of_cases) { - GREENTEA_SETUP(120, "default_auto"); + GREENTEA_SETUP(240, "default_auto"); return verbose_test_setup_handler(number_of_cases); } From 0498e8d3c32130e07d7eac39a8d090f46ef89482 Mon Sep 17 00:00:00 2001 From: Seppo Takalo Date: Fri, 22 Sep 2017 12:15:27 +0300 Subject: [PATCH 3/8] Update template mbed_app.json --- TESTS/network/wifi/template_mbed_app.txt | 37 +++++++++++++++++------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/TESTS/network/wifi/template_mbed_app.txt b/TESTS/network/wifi/template_mbed_app.txt index 77a7af0cf9..c3862ae983 100644 --- a/TESTS/network/wifi/template_mbed_app.txt +++ b/TESTS/network/wifi/template_mbed_app.txt @@ -1,21 +1,36 @@ { "config": { - "wifi-ssid": { + "wifi-secure-ssid": { "help": "WiFi SSID", - "value": "\"SSID\"" + "value": "\"SSID-SECURE\"" + }, + "wifi-unsecure-ssid": { + "help": "WiFi SSID", + "value": "\"SSID-UNSECURE\"" }, "wifi-password": { "help": "WiFi Password", - "value": "\"PASS\"" + "value": "\"PASSWORD\"" }, - "wifi-networks": { - "help": "WiFi SSIDs which presence will be asserted in the test", - "value": "\"SSID1\",\"SSID2\",\"SSID3\"" - } - }, - "target_overrides": { - "UBLOX_EVK_ODIN_W2": { - "target.device_has": ["EMAC"] + "wifi-ch-secure": { + "help": "Channel number of secure SSID", + "value": 1 + }, + "wifi-ch-unsecure": { + "help": "Channel number of unsecure SSID", + "value": 2 + }, + "ap-mac-secure": { + "help": "BSSID of secure AP in form of AA:BB:CC:DD:EE:FF", + "value": "\"AA:AA:AA:AA:AA:AA\"" + }, + "ap-mac-unsecure": { + "help": "BSSID of unsecure AP in form of \"AA:BB:CC:DD:EE:FF\"", + "value": "\"BB:BB:BB:BB:BB:BB\"" + }, + "max-scan-size": { + "help": "How many networks may appear in Wifi scan result", + "value": 10 } } } From fde08a1ee8df4cf263a5ec6b5989dec3e2f95a03 Mon Sep 17 00:00:00 2001 From: Seppo Takalo Date: Fri, 29 Sep 2017 12:55:04 +0300 Subject: [PATCH 4/8] Fix includes. Cannot include header file witin a function (without severe side effects) --- TESTS/network/wifi/get_interface.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/TESTS/network/wifi/get_interface.cpp b/TESTS/network/wifi/get_interface.cpp index 54e2bb2a96..99653e009c 100644 --- a/TESTS/network/wifi/get_interface.cpp +++ b/TESTS/network/wifi/get_interface.cpp @@ -1,5 +1,12 @@ #include "mbed.h" + +#if TARGET_UBLOX_EVK_ODIN_W2 +#include "OdinWiFiInterface.h" +#elif TARGET_REALTEK_RTL8195AM +#include "RTWInterface.h" +#else #include "ESP8266Interface.h" +#endif WiFiInterface *get_interface() { @@ -9,10 +16,8 @@ WiFiInterface *get_interface() delete interface; #if TARGET_UBLOX_EVK_ODIN_W2 -#include "OdinWiFiInterface.h" interface = new OdinWiFiInterface(); #elif TARGET_REALTEK_RTL8195AM -#include "RTWInterface.h" interface = new RTWInterface(); #else interface = new ESP8266Interface(D1, D0); From 5b40280cabd9d0014ba9c2aa4babe50df1e86a2b Mon Sep 17 00:00:00 2001 From: Seppo Takalo Date: Tue, 3 Oct 2017 12:09:52 +0300 Subject: [PATCH 5/8] Update help text --- TESTS/network/wifi/template_mbed_app.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TESTS/network/wifi/template_mbed_app.txt b/TESTS/network/wifi/template_mbed_app.txt index c3862ae983..847b7c0b04 100644 --- a/TESTS/network/wifi/template_mbed_app.txt +++ b/TESTS/network/wifi/template_mbed_app.txt @@ -1,11 +1,11 @@ { "config": { "wifi-secure-ssid": { - "help": "WiFi SSID", + "help": "WiFi SSID for WPA2 secured network", "value": "\"SSID-SECURE\"" }, "wifi-unsecure-ssid": { - "help": "WiFi SSID", + "help": "WiFi SSID for unsecure netwrok", "value": "\"SSID-UNSECURE\"" }, "wifi-password": { From 72e7c326c966b126c81ccb00d68acef54c76d838 Mon Sep 17 00:00:00 2001 From: Seppo Takalo Date: Tue, 3 Oct 2017 12:50:03 +0300 Subject: [PATCH 6/8] Fix builds for targets without wifi or without mbed_app.json --- TESTS/network/wifi/get_interface.cpp | 29 ++++++++++++++++++++---- TESTS/network/wifi/main.cpp | 15 ++++++++++++ TESTS/network/wifi/template_mbed_app.txt | 12 ++++++++++ 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/TESTS/network/wifi/get_interface.cpp b/TESTS/network/wifi/get_interface.cpp index 99653e009c..d89751c891 100644 --- a/TESTS/network/wifi/get_interface.cpp +++ b/TESTS/network/wifi/get_interface.cpp @@ -1,11 +1,32 @@ #include "mbed.h" +// Pick the correct driver based on mbed_app.json +#define INTERNAL 1 +#define WIFI_ESP8266 2 +#define X_NUCLEO_IDW01M1 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_IDW01M1 +#include "SpwfSAInterface.h" +#define DRIVER SpwfSAInterface +#else +#error [NOT_SUPPORTED] Unsupported Wifi driver #endif WiFiInterface *get_interface() @@ -15,12 +36,10 @@ WiFiInterface *get_interface() if (interface) delete interface; -#if TARGET_UBLOX_EVK_ODIN_W2 - interface = new OdinWiFiInterface(); -#elif TARGET_REALTEK_RTL8195AM - interface = new RTWInterface(); +#if MBED_CONF_APP_WIFI_DRIVER == INTERNAL + interface = new DRIVER(); #else - interface = new ESP8266Interface(D1, D0); + interface = new DRIVER(MBED_CONF_APP_WIFI_TX, MBED_CONF_APP_WIFI_RX); #endif return interface; } diff --git a/TESTS/network/wifi/main.cpp b/TESTS/network/wifi/main.cpp index 754df739d5..85bb2e9a07 100644 --- a/TESTS/network/wifi/main.cpp +++ b/TESTS/network/wifi/main.cpp @@ -4,6 +4,21 @@ #include "utest.h" #include "wifi_tests.h" +// Test for parameters +#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) || \ + !defined(MBED_CONF_APP_WIFI_UNSECURE_SSID) +#error [NOT_SUPPORTED] Requires parameters from mbed_app.json +#endif + using namespace utest::v1; utest::v1::status_t test_setup(const size_t number_of_cases) { diff --git a/TESTS/network/wifi/template_mbed_app.txt b/TESTS/network/wifi/template_mbed_app.txt index 847b7c0b04..ddab934545 100644 --- a/TESTS/network/wifi/template_mbed_app.txt +++ b/TESTS/network/wifi/template_mbed_app.txt @@ -20,6 +20,18 @@ "help": "Channel number of unsecure SSID", "value": 2 }, + "wifi-driver": { + "help": "Wifi driver to use, valid values are INTERNAL, WIFI_ESP8266 and X_NUCLEO_IDW01M1", + "value": "INTERNAL" + }, + "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" + }, "ap-mac-secure": { "help": "BSSID of secure AP in form of AA:BB:CC:DD:EE:FF", "value": "\"AA:AA:AA:AA:AA:AA\"" From 80198f2dcdf3696795f56069e4e75d08c337a67a Mon Sep 17 00:00:00 2001 From: Seppo Takalo Date: Wed, 4 Oct 2017 12:32:46 +0300 Subject: [PATCH 7/8] Add Doxygen documentation for testcases. --- TESTS/network/wifi/wifi_tests.h | 39 ++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/TESTS/network/wifi/wifi_tests.h b/TESTS/network/wifi/wifi_tests.h index 0d66fb689d..1ef40ccc2d 100644 --- a/TESTS/network/wifi/wifi_tests.h +++ b/TESTS/network/wifi/wifi_tests.h @@ -3,24 +3,61 @@ #include "WiFiInterface.h" +/** Get WiFiInterface based on provided + * app_json. */ WiFiInterface *get_interface(void); -/* Test cases */ +/* + * Test cases + */ + +/** Test that constructor of the driver works. */ void wifi_constructor(void); + +/** This test case is to test whether the driver accepts valid credentials and reject ones that are not valid. */ void wifi_set_credential(void); + +/** Test validity of WiFiInterface::set_channel(). */ void wifi_set_channel(void); + +/** Test WiFiInterface::get_rssi() API. + * When connected, it should return valid RSSI value. When unconnected it should return 0. */ void wifi_get_rssi(void); + +/** Test WiFiInterface::connect(ssid, pass, security, channel) with NULL parameters */ void wifi_connect_params_null(void); + +/** Test WiFiInterface::connect(ssid, pass, security) with valid parameters for unsecure network */ void wifi_connect_params_valid_unsecure(void); + +/** Test WiFiInterface::connect(ssid, pass, security) with valid parameters for secure network */ void wifi_connect_params_valid_secure(void); + +/** Test WiFiInterface::connect(ssid, pass, security, channel) with valid parameters for secure network using channel specified. */ void wifi_connect_params_channel(void); + +/** Test WiFiInterface::connect(ssid, pass, security, channel) with valid parameters for secure network using wrong channel number. */ void wifi_connect_params_channel_fail(void); + +/** Test WiFiInterface::connect() without parameters. Use set_credentials() for setting parameters. */ void wifi_connect(void); + +/** Test WiFiInterface::connect() without parameters. Don't set parameters with set_credentials() */ void wifi_connect_nocredentials(void); + +/** Test WiFiInterface::connect() without parameters. Use secure settings for set_credentials. */ void wifi_connect_secure(void); + +/** Test WiFiInterface::connect() failing with wrong password. */ void wifi_connect_secure_fail(void); + +/** Test WiFiInterface::connect() - disconnect() repeatition works. */ void wifi_connect_disconnect_repeat(void); + +/** Call WiFiInterface::scan() with null parameters to get number of networks available. */ void wifi_scan_null(void); + +/** Call WiFiInterface::scan() with valid accesspoint list allocated */ void wifi_scan(void); #endif //WIFI_TESTS_H From 429b0688bd9df1c168265a301a8e4b600123838d Mon Sep 17 00:00:00 2001 From: Seppo Takalo Date: Wed, 4 Oct 2017 17:45:25 +0300 Subject: [PATCH 8/8] Add license texts --- TESTS/network/wifi/get_interface.cpp | 17 +++++++++++++++++ TESTS/network/wifi/main.cpp | 17 +++++++++++++++++ TESTS/network/wifi/wifi-constructor.cpp | 17 +++++++++++++++++ TESTS/network/wifi/wifi_connect.cpp | 17 +++++++++++++++++ .../wifi/wifi_connect_disconnect_repeat.cpp | 17 +++++++++++++++++ .../network/wifi/wifi_connect_nocredentials.cpp | 17 +++++++++++++++++ .../wifi/wifi_connect_params_channel.cpp | 17 +++++++++++++++++ .../wifi/wifi_connect_params_channel_fail.cpp | 17 +++++++++++++++++ TESTS/network/wifi/wifi_connect_params_null.cpp | 17 +++++++++++++++++ .../wifi/wifi_connect_params_valid_secure.cpp | 17 +++++++++++++++++ .../wifi/wifi_connect_params_valid_unsecure.cpp | 17 +++++++++++++++++ TESTS/network/wifi/wifi_connect_secure.cpp | 17 +++++++++++++++++ TESTS/network/wifi/wifi_connect_secure_fail.cpp | 17 +++++++++++++++++ TESTS/network/wifi/wifi_get_rssi.cpp | 17 +++++++++++++++++ TESTS/network/wifi/wifi_scan.cpp | 17 +++++++++++++++++ TESTS/network/wifi/wifi_scan_null.cpp | 17 +++++++++++++++++ TESTS/network/wifi/wifi_set_channel.cpp | 17 +++++++++++++++++ TESTS/network/wifi/wifi_set_credential.cpp | 17 +++++++++++++++++ 18 files changed, 306 insertions(+) diff --git a/TESTS/network/wifi/get_interface.cpp b/TESTS/network/wifi/get_interface.cpp index d89751c891..9bafab9b58 100644 --- a/TESTS/network/wifi/get_interface.cpp +++ b/TESTS/network/wifi/get_interface.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" // Pick the correct driver based on mbed_app.json diff --git a/TESTS/network/wifi/main.cpp b/TESTS/network/wifi/main.cpp index 85bb2e9a07..1245b11e2d 100644 --- a/TESTS/network/wifi/main.cpp +++ b/TESTS/network/wifi/main.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi-constructor.cpp b/TESTS/network/wifi/wifi-constructor.cpp index d2cffb3626..3fa80ff5cb 100644 --- a/TESTS/network/wifi/wifi-constructor.cpp +++ b/TESTS/network/wifi/wifi-constructor.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_connect.cpp b/TESTS/network/wifi/wifi_connect.cpp index 2d6ac51444..c244e0247f 100644 --- a/TESTS/network/wifi/wifi_connect.cpp +++ b/TESTS/network/wifi/wifi_connect.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_connect_disconnect_repeat.cpp b/TESTS/network/wifi/wifi_connect_disconnect_repeat.cpp index 971de306ff..9ee73fc558 100644 --- a/TESTS/network/wifi/wifi_connect_disconnect_repeat.cpp +++ b/TESTS/network/wifi/wifi_connect_disconnect_repeat.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_connect_nocredentials.cpp b/TESTS/network/wifi/wifi_connect_nocredentials.cpp index f540328aeb..c930d7d0a9 100644 --- a/TESTS/network/wifi/wifi_connect_nocredentials.cpp +++ b/TESTS/network/wifi/wifi_connect_nocredentials.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_connect_params_channel.cpp b/TESTS/network/wifi/wifi_connect_params_channel.cpp index c440470a9d..08c34a9c54 100644 --- a/TESTS/network/wifi/wifi_connect_params_channel.cpp +++ b/TESTS/network/wifi/wifi_connect_params_channel.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_connect_params_channel_fail.cpp b/TESTS/network/wifi/wifi_connect_params_channel_fail.cpp index d5d9733a15..f1d56d2249 100644 --- a/TESTS/network/wifi/wifi_connect_params_channel_fail.cpp +++ b/TESTS/network/wifi/wifi_connect_params_channel_fail.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_connect_params_null.cpp b/TESTS/network/wifi/wifi_connect_params_null.cpp index 22f7c1917d..6a471bd604 100644 --- a/TESTS/network/wifi/wifi_connect_params_null.cpp +++ b/TESTS/network/wifi/wifi_connect_params_null.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_connect_params_valid_secure.cpp b/TESTS/network/wifi/wifi_connect_params_valid_secure.cpp index ba906a20d7..0da25c6792 100644 --- a/TESTS/network/wifi/wifi_connect_params_valid_secure.cpp +++ b/TESTS/network/wifi/wifi_connect_params_valid_secure.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_connect_params_valid_unsecure.cpp b/TESTS/network/wifi/wifi_connect_params_valid_unsecure.cpp index 4a63e664f0..e1540b24a8 100644 --- a/TESTS/network/wifi/wifi_connect_params_valid_unsecure.cpp +++ b/TESTS/network/wifi/wifi_connect_params_valid_unsecure.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_connect_secure.cpp b/TESTS/network/wifi/wifi_connect_secure.cpp index b6d47051cf..dce86f969f 100644 --- a/TESTS/network/wifi/wifi_connect_secure.cpp +++ b/TESTS/network/wifi/wifi_connect_secure.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_connect_secure_fail.cpp b/TESTS/network/wifi/wifi_connect_secure_fail.cpp index 9b271f7fcb..7e55a290a8 100644 --- a/TESTS/network/wifi/wifi_connect_secure_fail.cpp +++ b/TESTS/network/wifi/wifi_connect_secure_fail.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_get_rssi.cpp b/TESTS/network/wifi/wifi_get_rssi.cpp index 7c980c5e28..ac4338ff93 100644 --- a/TESTS/network/wifi/wifi_get_rssi.cpp +++ b/TESTS/network/wifi/wifi_get_rssi.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_scan.cpp b/TESTS/network/wifi/wifi_scan.cpp index a9aa057873..d4722dd0d0 100644 --- a/TESTS/network/wifi/wifi_scan.cpp +++ b/TESTS/network/wifi/wifi_scan.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_scan_null.cpp b/TESTS/network/wifi/wifi_scan_null.cpp index bfdd42391f..784d91b896 100644 --- a/TESTS/network/wifi/wifi_scan_null.cpp +++ b/TESTS/network/wifi/wifi_scan_null.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_set_channel.cpp b/TESTS/network/wifi/wifi_set_channel.cpp index f7681b136f..ecb7915004 100644 --- a/TESTS/network/wifi/wifi_set_channel.cpp +++ b/TESTS/network/wifi/wifi_set_channel.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_set_credential.cpp b/TESTS/network/wifi/wifi_set_credential.cpp index b08df974fc..78f5d60427 100644 --- a/TESTS/network/wifi/wifi_set_credential.cpp +++ b/TESTS/network/wifi/wifi_set_credential.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h"