Skip to content

Cypress: Initial commit of SoftAP host tests. #12125

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

Closed
wants to merge 22 commits into from
Closed
Changes from 3 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions TESTS/softap/ap/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Copyright (c) 2017-2019, 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.
*/

#if !defined(MBED_CONF_APP_SOFTAP_SSID) || \
!defined(MBED_CONF_APP_SOFTAP_CHANNEL) || \
!defined(MBED_CONF_APP_SOFTAP_PASSWORD)

#error [NOT_SUPPORTED] Requires parameters from mbed_app.json
#endif

#define SOFTAP 1

#if MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE != SOFTAP

#error [NOT_SUPPORTED] SoftAP testing need to be enabled
#endif

#if !defined(TARGET_PSOC6)
#error [NOT_SUPPORTED] Wifi tests are not valid for the target
#endif

#define SOFTAP_IP_ADDRESS "192.168.10.1"
#define NETMASK "255.255.255.0"
#define GATEWAY "192.168.10.1"

#include "greentea-client/test_env.h"
#include "unity.h"
#include "utest.h"

#include "WhdSoftAPInterface.h"

using namespace utest::v1;

static char _key[256] = { 0 };
static char _value[128] = { 0 };

void host_os_type_verification()
{
greentea_send_kv("get_os_type", "host");
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
TEST_ASSERT_EQUAL_STRING("Linux", _value);
}

void softap_test()
{
WhdSoftAPInterface *softap = WhdSoftAPInterface::get_default_instance();
TEST_ASSERT_TRUE(softap != NULL);

softap->set_network(SOFTAP_IP_ADDRESS, NETMASK, GATEWAY);
int ret = softap->start(MBED_CONF_APP_SOFTAP_SSID, MBED_CONF_APP_SOFTAP_PASSWORD, NSAPI_SECURITY_WPA_WPA2,
MBED_CONF_APP_SOFTAP_CHANNEL);
TEST_ASSERT_EQUAL_INT(0, ret);
greentea_send_kv("softap", "up");
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
TEST_ASSERT_EQUAL_STRING("passed", _key);
}

utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
{
// here, we specify the timeout (150) and the host runner (the name of our Python file)
GREENTEA_SETUP(150, "softap_basic");
Copy link
Contributor

@jamesbeyond jamesbeyond Dec 30, 2019

Choose a reason for hiding this comment

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

I can see this test requires softap_basic host test but seems this python script is not part of this PR

return greentea_test_setup_handler(number_of_cases);
}

Case cases[] = {
Case("Host OS Type Verification", host_os_type_verification),
Case("SoftAP test", softap_test)
};

Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);

int main()
{
return Harness::run(specification);
}