Use the hostapd_test_utils helper methods in

the Hostapd AIDL VTS tests.

At the beginning of each test, we now:
 1. Disable the Wifi framework, Hostapd, and Vendor HAL.
 2. Enable the Hostapd and Vendor HAL.

At the end of each test, we now:
 1. Disable the Hostapd and Vendor HAL.
 2. Enable the Wifi framework.

Bug: 283402709
Test: atest VtsHalHostapdTargetTest --iterations 10
       # Tested on both an Android T and U device.
       # All tests passed in both cases.
Change-Id: I8b5e24ad44d13fad09d84f1b212e60ca8df3aa7e
This commit is contained in:
Gabriel Biren 2023-07-19 17:24:21 +00:00
parent 3454ce179a
commit c6cacf6149

View file

@ -32,6 +32,7 @@
#include <wifi_hidl_test_utils_1_5.h>
#include <wifi_hidl_test_utils_1_6.h>
#include "hostapd_test_utils.h"
#include "wifi_aidl_test_utils.h"
using aidl::android::hardware::wifi::hostapd::BandMask;
@ -56,10 +57,7 @@ const std::string kInvalidMaxPassphrase =
const int kIfaceChannel = 6;
const int kIfaceInvalidChannel = 567;
const std::vector<uint8_t> kTestZeroMacAddr(6, 0x0);
const Ieee80211ReasonCode kTestDisconnectReasonCode =
Ieee80211ReasonCode::WLAN_REASON_UNSPECIFIED;
const std::string kWifiAidlInstanceNameStr = std::string() + IWifi::descriptor + "/default";
const char* kWifiAidlInstanceName = kWifiAidlInstanceNameStr.c_str();
const Ieee80211ReasonCode kTestDisconnectReasonCode = Ieee80211ReasonCode::WLAN_REASON_UNSPECIFIED;
inline BandMask operator|(BandMask a, BandMask b) {
return static_cast<BandMask>(static_cast<int32_t>(a) |
@ -70,10 +68,13 @@ inline BandMask operator|(BandMask a, BandMask b) {
class HostapdAidl : public testing::TestWithParam<std::string> {
public:
virtual void SetUp() override {
hostapd = IHostapd::fromBinder(ndk::SpAIBinder(
AServiceManager_waitForService(GetParam().c_str())));
disableHalsAndFramework();
initializeHostapdAndVendorHal(GetParam());
hostapd = getHostapd(GetParam());
ASSERT_NE(hostapd, nullptr);
EXPECT_TRUE(hostapd->setDebugParams(DebugLevel::EXCESSIVE).isOk());
isAcsSupport = testing::checkSubstringInCommandOutput(
"/system/bin/cmd wifi get-softap-supported-features",
"wifi_softap_acs_supported");
@ -81,81 +82,23 @@ class HostapdAidl : public testing::TestWithParam<std::string> {
"/system/bin/cmd wifi get-softap-supported-features",
"wifi_softap_wpa3_sae_supported");
isBridgedSupport = testing::checkSubstringInCommandOutput(
"/system/bin/cmd wifi get-softap-supported-features",
"wifi_softap_bridged_ap_supported");
if (!isAidlServiceAvailable(kWifiAidlInstanceName)) {
const std::vector<std::string> instances = android::hardware::getAllHalInstanceNames(
::android::hardware::wifi::V1_0::IWifi::descriptor);
EXPECT_NE(0, instances.size());
wifiHidlInstanceName = instances[0];
}
"/system/bin/cmd wifi get-softap-supported-features",
"wifi_softap_bridged_ap_supported");
}
virtual void TearDown() override {
stopVendorHal();
hostapd->terminate();
// Wait 3 seconds to allow terminate to complete
sleep(3);
stopHostapdAndVendorHal();
startWifiFramework();
}
std::shared_ptr<IHostapd> hostapd;
std::string wifiHidlInstanceName;
bool isAcsSupport;
bool isWpa3SaeSupport;
bool isBridgedSupport;
void stopVendorHal() {
if (isAidlServiceAvailable(kWifiAidlInstanceName)) {
// HIDL and AIDL versions of getWifi() take different arguments
// i.e. const char* vs string
if (getWifi(kWifiAidlInstanceName) != nullptr) {
stopWifiService(kWifiAidlInstanceName);
}
} else {
if (getWifi(wifiHidlInstanceName) != nullptr) {
stopWifi(wifiHidlInstanceName);
}
}
}
std::string setupApIfaceAndGetName(bool isBridged) {
if (isAidlServiceAvailable(kWifiAidlInstanceName)) {
return setupApIfaceAndGetNameAidl(isBridged);
} else {
return setupApIfaceAndGetNameHidl(isBridged);
}
}
std::string setupApIfaceAndGetNameAidl(bool isBridged) {
std::shared_ptr<IWifiApIface> wifi_ap_iface;
if (isBridged) {
wifi_ap_iface = getBridgedWifiApIface(kWifiAidlInstanceName);
} else {
wifi_ap_iface = getWifiApIface(kWifiAidlInstanceName);
}
EXPECT_NE(nullptr, wifi_ap_iface.get());
std::string ap_iface_name;
auto status = wifi_ap_iface->getName(&ap_iface_name);
EXPECT_TRUE(status.isOk());
return ap_iface_name;
}
std::string setupApIfaceAndGetNameHidl(bool isBridged) {
android::sp<::android::hardware::wifi::V1_0::IWifiApIface> wifi_ap_iface;
if (isBridged) {
wifi_ap_iface = getBridgedWifiApIface_1_6(wifiHidlInstanceName);
} else {
wifi_ap_iface = getWifiApIface_1_5(wifiHidlInstanceName);
}
EXPECT_NE(nullptr, wifi_ap_iface.get());
const auto& status_and_name = HIDL_INVOKE(wifi_ap_iface, getName);
EXPECT_EQ(android::hardware::wifi::V1_0::WifiStatusCode::SUCCESS,
status_and_name.first.code);
return status_and_name.second;
}
IfaceParams getIfaceParamsWithoutAcs(std::string iface_name) {
IfaceParams iface_params;
ChannelParams channelParams;