Skip wifi AP tests, if AP feature is not supported

- Added API to check wifi chip supports AP interface
- Check AP support as a precondition for AP related TCs

Bug: 284925541
Test: atest VtsHalWifiApV1_5TargetTest
Change-Id: I1121d7b787ed972980bab0e05a52f3ca2f3d0a24
This commit is contained in:
Nethaji B 2023-07-12 12:48:47 +05:30 committed by Gabriel Biren
parent 12320fd071
commit 6eab68a9e6
3 changed files with 33 additions and 0 deletions

View file

@ -89,6 +89,24 @@ bool configureChipToSupportIfaceTypeInternal(const sp<IWifiChip>& wifi_chip,
ChipModeId mode_id;
return configureChipToSupportIfaceTypeInternal(wifi_chip, type, &mode_id);
}
bool doesChipSupportIfaceTypeInternal(const sp<IWifiChip>& wifi_chip,
IfaceType type) {
ChipModeId mode_id;
if (!wifi_chip.get()) {
return false;
}
const auto& status_and_modes = HIDL_INVOKE(wifi_chip, getAvailableModes);
if (status_and_modes.first.code != WifiStatusCode::SUCCESS) {
return false;
}
if (!findAnyModeSupportingIfaceType(type, status_and_modes.second,
&mode_id)) {
return false;
}
return true;
}
} // namespace
sp<IWifi> getWifi(const std::string& instance_name) {
@ -205,6 +223,11 @@ bool configureChipToSupportIfaceType(const sp<IWifiChip>& wifi_chip,
configured_mode_id);
}
bool doesChipSupportIfaceType(const sp<IWifiChip>& wifi_chip,
IfaceType type) {
return doesChipSupportIfaceTypeInternal(wifi_chip, type);
}
void stopWifi(const std::string& instance_name) {
sp<IWifi> wifi = IWifi::getService(instance_name);
ASSERT_NE(wifi, nullptr);

View file

@ -49,6 +49,10 @@ bool configureChipToSupportIfaceType(
const android::sp<android::hardware::wifi::V1_0::IWifiChip>& wifi_chip,
android::hardware::wifi::V1_0::IfaceType type,
android::hardware::wifi::V1_0::ChipModeId* configured_mode_id);
// Check whether wifi chip supports given interface type mode
bool doesChipSupportIfaceType(
const android::sp<android::hardware::wifi::V1_0::IWifiChip>& wifi_chip,
android::hardware::wifi::V1_0::IfaceType type);
// Used to trigger IWifi.stop() at the end of every test.
void stopWifi(const std::string& instance_name);
uint32_t getChipCapabilitiesLatest(

View file

@ -58,12 +58,16 @@ class WifiApIfaceHidlTest : public ::testing::TestWithParam<std::string> {
"wifi_softap_bridged_ap_supported");
// Make sure to start with a clean state
stopWifi(GetInstanceName());
// Read AP mode capabilities from the wifi chip modes
sp<IWifiChip> wifi_chip_ = getWifiChip_1_5(GetInstanceName());
isApModeSupport_ = doesChipSupportIfaceType(wifi_chip_, IfaceType::AP);
}
virtual void TearDown() override { stopWifi(GetInstanceName()); }
protected:
bool isBridgedSupport_ = false;
bool isApModeSupport_ = false;
std::string GetInstanceName() { return GetParam(); }
};
@ -83,6 +87,7 @@ TEST_P(WifiApIfaceHidlTest, resetToFactoryMacAddressInBridgedModeTest) {
* resetToFactoryMacAddress in non-bridged mode
*/
TEST_P(WifiApIfaceHidlTest, resetToFactoryMacAddressTest) {
if (!isApModeSupport_) GTEST_SKIP() << "Missing AP support";
sp<IWifiApIface> wifi_ap_iface = getWifiApIface_1_5(GetInstanceName());
ASSERT_NE(nullptr, wifi_ap_iface.get());
const auto& status = HIDL_INVOKE(wifi_ap_iface, resetToFactoryMacAddress);
@ -93,6 +98,7 @@ TEST_P(WifiApIfaceHidlTest, resetToFactoryMacAddressTest) {
* getBridgedInstances in non-bridged mode
*/
TEST_P(WifiApIfaceHidlTest, getBridgedInstancesTest) {
if (!isApModeSupport_) GTEST_SKIP() << "Missing AP support";
sp<IWifiApIface> wifi_ap_iface = getWifiApIface_1_5(GetInstanceName());
ASSERT_NE(nullptr, wifi_ap_iface.get());
const auto& status_and_instances =