Loading wifi/hostapd/1.0/vts/functional/hostapd_hidl_test.cpp +16 −2 Original line number Original line Diff line number Diff line Loading @@ -48,6 +48,13 @@ class HostapdHidlTest virtual void SetUp() override { virtual void SetUp() override { wifi_instance_name_ = std::get<0>(GetParam()); wifi_instance_name_ = std::get<0>(GetParam()); hostapd_instance_name_ = std::get<1>(GetParam()); hostapd_instance_name_ = std::get<1>(GetParam()); // Disable Wi-Fi framework to avoid interference isWifiEnabled_ = isWifiFrameworkEnabled(); isScanAlwaysEnabled_ = isWifiScanAlwaysAvailable(); toggleWifiFramework(false); toggleWifiScanAlwaysAvailable(false); stopSupplicantIfNeeded(wifi_instance_name_); stopSupplicantIfNeeded(wifi_instance_name_); startHostapdAndWaitForHidlService(wifi_instance_name_, startHostapdAndWaitForHidlService(wifi_instance_name_, hostapd_instance_name_); hostapd_instance_name_); Loading @@ -58,9 +65,16 @@ class HostapdHidlTest virtual void TearDown() override { virtual void TearDown() override { HIDL_INVOKE_VOID_WITHOUT_ARGUMENTS(hostapd_, terminate); HIDL_INVOKE_VOID_WITHOUT_ARGUMENTS(hostapd_, terminate); stopHostapd(wifi_instance_name_); stopHostapd(wifi_instance_name_); // Restore Wi-Fi framework state toggleWifiFramework(isWifiEnabled_); toggleWifiScanAlwaysAvailable(isScanAlwaysEnabled_); } } protected: protected: bool isWifiEnabled_ = false; bool isScanAlwaysEnabled_ = false; std::string getPrimaryWlanIfaceName() { std::string getPrimaryWlanIfaceName() { std::array<char, PROPERTY_VALUE_MAX> buffer; std::array<char, PROPERTY_VALUE_MAX> buffer; property_get("wifi.interface", buffer.data(), "wlan0"); property_get("wifi.interface", buffer.data(), "wlan0"); Loading wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.cpp +21 −0 Original line number Original line Diff line number Diff line Loading @@ -98,3 +98,24 @@ bool is_1_1(const sp<IHostapd>& hostapd) { ::android::hardware::wifi::hostapd::V1_1::IHostapd::castFrom(hostapd); ::android::hardware::wifi::hostapd::V1_1::IHostapd::castFrom(hostapd); return hostapd_1_1.get() != nullptr; return hostapd_1_1.get() != nullptr; } } void toggleWifiFramework(bool enable) { std::string cmd = "/system/bin/cmd wifi set-wifi-enabled "; cmd += enable ? "enabled" : "disabled"; testing::checkSubstringInCommandOutput(cmd.c_str(), "X"); } void toggleWifiScanAlwaysAvailable(bool enable) { std::string cmd = "/system/bin/cmd wifi set-scan-always-available "; cmd += enable ? "enabled" : "disabled"; testing::checkSubstringInCommandOutput(cmd.c_str(), "X"); } bool isWifiFrameworkEnabled() { return testing::checkSubstringInCommandOutput("/system/bin/cmd wifi status", "Wifi is enabled"); } bool isWifiScanAlwaysAvailable() { return testing::checkSubstringInCommandOutput("/system/bin/cmd wifi status", "Wifi scanning is always available"); } wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.h +5 −2 Original line number Original line Diff line number Diff line Loading @@ -17,14 +17,17 @@ #ifndef HOSTAPD_HIDL_TEST_UTILS_H #ifndef HOSTAPD_HIDL_TEST_UTILS_H #define HOSTAPD_HIDL_TEST_UTILS_H #define HOSTAPD_HIDL_TEST_UTILS_H #include <VtsCoreUtil.h> #include <android/hardware/wifi/hostapd/1.0/IHostapd.h> #include <android/hardware/wifi/hostapd/1.0/IHostapd.h> #include <android/hardware/wifi/hostapd/1.1/IHostapd.h> #include <android/hardware/wifi/hostapd/1.1/IHostapd.h> // Used to stop the android wifi framework before every test. // Used to stop the android wifi framework before every test. void stopWifiFramework(const std::string& instance_name); void startWifiFramework(const std::string& instance_name); void stopSupplicantIfNeeded(const std::string& instance_name); void stopSupplicantIfNeeded(const std::string& instance_name); void stopHostapd(const std::string& instance_name); void stopHostapd(const std::string& instance_name); void toggleWifiFramework(bool enable); void toggleWifiScanAlwaysAvailable(bool enable); bool isWifiFrameworkEnabled(); bool isWifiScanAlwaysAvailable(); // Used to configure the chip, driver and start wpa_hostapd before every // Used to configure the chip, driver and start wpa_hostapd before every // test. // test. void startHostapdAndWaitForHidlService( void startHostapdAndWaitForHidlService( Loading Loading
wifi/hostapd/1.0/vts/functional/hostapd_hidl_test.cpp +16 −2 Original line number Original line Diff line number Diff line Loading @@ -48,6 +48,13 @@ class HostapdHidlTest virtual void SetUp() override { virtual void SetUp() override { wifi_instance_name_ = std::get<0>(GetParam()); wifi_instance_name_ = std::get<0>(GetParam()); hostapd_instance_name_ = std::get<1>(GetParam()); hostapd_instance_name_ = std::get<1>(GetParam()); // Disable Wi-Fi framework to avoid interference isWifiEnabled_ = isWifiFrameworkEnabled(); isScanAlwaysEnabled_ = isWifiScanAlwaysAvailable(); toggleWifiFramework(false); toggleWifiScanAlwaysAvailable(false); stopSupplicantIfNeeded(wifi_instance_name_); stopSupplicantIfNeeded(wifi_instance_name_); startHostapdAndWaitForHidlService(wifi_instance_name_, startHostapdAndWaitForHidlService(wifi_instance_name_, hostapd_instance_name_); hostapd_instance_name_); Loading @@ -58,9 +65,16 @@ class HostapdHidlTest virtual void TearDown() override { virtual void TearDown() override { HIDL_INVOKE_VOID_WITHOUT_ARGUMENTS(hostapd_, terminate); HIDL_INVOKE_VOID_WITHOUT_ARGUMENTS(hostapd_, terminate); stopHostapd(wifi_instance_name_); stopHostapd(wifi_instance_name_); // Restore Wi-Fi framework state toggleWifiFramework(isWifiEnabled_); toggleWifiScanAlwaysAvailable(isScanAlwaysEnabled_); } } protected: protected: bool isWifiEnabled_ = false; bool isScanAlwaysEnabled_ = false; std::string getPrimaryWlanIfaceName() { std::string getPrimaryWlanIfaceName() { std::array<char, PROPERTY_VALUE_MAX> buffer; std::array<char, PROPERTY_VALUE_MAX> buffer; property_get("wifi.interface", buffer.data(), "wlan0"); property_get("wifi.interface", buffer.data(), "wlan0"); Loading
wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.cpp +21 −0 Original line number Original line Diff line number Diff line Loading @@ -98,3 +98,24 @@ bool is_1_1(const sp<IHostapd>& hostapd) { ::android::hardware::wifi::hostapd::V1_1::IHostapd::castFrom(hostapd); ::android::hardware::wifi::hostapd::V1_1::IHostapd::castFrom(hostapd); return hostapd_1_1.get() != nullptr; return hostapd_1_1.get() != nullptr; } } void toggleWifiFramework(bool enable) { std::string cmd = "/system/bin/cmd wifi set-wifi-enabled "; cmd += enable ? "enabled" : "disabled"; testing::checkSubstringInCommandOutput(cmd.c_str(), "X"); } void toggleWifiScanAlwaysAvailable(bool enable) { std::string cmd = "/system/bin/cmd wifi set-scan-always-available "; cmd += enable ? "enabled" : "disabled"; testing::checkSubstringInCommandOutput(cmd.c_str(), "X"); } bool isWifiFrameworkEnabled() { return testing::checkSubstringInCommandOutput("/system/bin/cmd wifi status", "Wifi is enabled"); } bool isWifiScanAlwaysAvailable() { return testing::checkSubstringInCommandOutput("/system/bin/cmd wifi status", "Wifi scanning is always available"); }
wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.h +5 −2 Original line number Original line Diff line number Diff line Loading @@ -17,14 +17,17 @@ #ifndef HOSTAPD_HIDL_TEST_UTILS_H #ifndef HOSTAPD_HIDL_TEST_UTILS_H #define HOSTAPD_HIDL_TEST_UTILS_H #define HOSTAPD_HIDL_TEST_UTILS_H #include <VtsCoreUtil.h> #include <android/hardware/wifi/hostapd/1.0/IHostapd.h> #include <android/hardware/wifi/hostapd/1.0/IHostapd.h> #include <android/hardware/wifi/hostapd/1.1/IHostapd.h> #include <android/hardware/wifi/hostapd/1.1/IHostapd.h> // Used to stop the android wifi framework before every test. // Used to stop the android wifi framework before every test. void stopWifiFramework(const std::string& instance_name); void startWifiFramework(const std::string& instance_name); void stopSupplicantIfNeeded(const std::string& instance_name); void stopSupplicantIfNeeded(const std::string& instance_name); void stopHostapd(const std::string& instance_name); void stopHostapd(const std::string& instance_name); void toggleWifiFramework(bool enable); void toggleWifiScanAlwaysAvailable(bool enable); bool isWifiFrameworkEnabled(); bool isWifiScanAlwaysAvailable(); // Used to configure the chip, driver and start wpa_hostapd before every // Used to configure the chip, driver and start wpa_hostapd before every // test. // test. void startHostapdAndWaitForHidlService( void startHostapdAndWaitForHidlService( Loading