From 6eab68a9e66e53d2e82236a2f843aab1033eb44b Mon Sep 17 00:00:00 2001 From: Nethaji B Date: Wed, 12 Jul 2023 12:48:47 +0530 Subject: [PATCH] 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 --- .../vts/functional/wifi_hidl_test_utils.cpp | 23 +++++++++++++++++++ .../1.0/vts/functional/wifi_hidl_test_utils.h | 4 ++++ .../functional/wifi_ap_iface_hidl_test.cpp | 6 +++++ 3 files changed, 33 insertions(+) diff --git a/wifi/1.0/vts/functional/wifi_hidl_test_utils.cpp b/wifi/1.0/vts/functional/wifi_hidl_test_utils.cpp index 02f8209e5b..fae30c0795 100644 --- a/wifi/1.0/vts/functional/wifi_hidl_test_utils.cpp +++ b/wifi/1.0/vts/functional/wifi_hidl_test_utils.cpp @@ -89,6 +89,24 @@ bool configureChipToSupportIfaceTypeInternal(const sp& wifi_chip, ChipModeId mode_id; return configureChipToSupportIfaceTypeInternal(wifi_chip, type, &mode_id); } + +bool doesChipSupportIfaceTypeInternal(const sp& 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 getWifi(const std::string& instance_name) { @@ -205,6 +223,11 @@ bool configureChipToSupportIfaceType(const sp& wifi_chip, configured_mode_id); } +bool doesChipSupportIfaceType(const sp& wifi_chip, + IfaceType type) { + return doesChipSupportIfaceTypeInternal(wifi_chip, type); +} + void stopWifi(const std::string& instance_name) { sp wifi = IWifi::getService(instance_name); ASSERT_NE(wifi, nullptr); diff --git a/wifi/1.0/vts/functional/wifi_hidl_test_utils.h b/wifi/1.0/vts/functional/wifi_hidl_test_utils.h index 62c015cb39..876c316953 100644 --- a/wifi/1.0/vts/functional/wifi_hidl_test_utils.h +++ b/wifi/1.0/vts/functional/wifi_hidl_test_utils.h @@ -49,6 +49,10 @@ bool configureChipToSupportIfaceType( const android::sp& 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& 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( diff --git a/wifi/1.5/vts/functional/wifi_ap_iface_hidl_test.cpp b/wifi/1.5/vts/functional/wifi_ap_iface_hidl_test.cpp index 424f9345f8..c3bd4d729d 100644 --- a/wifi/1.5/vts/functional/wifi_ap_iface_hidl_test.cpp +++ b/wifi/1.5/vts/functional/wifi_ap_iface_hidl_test.cpp @@ -58,12 +58,16 @@ class WifiApIfaceHidlTest : public ::testing::TestWithParam { "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 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 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 wifi_ap_iface = getWifiApIface_1_5(GetInstanceName()); ASSERT_NE(nullptr, wifi_ap_iface.get()); const auto& status_and_instances =