diff --git a/wifi/supplicant/1.3/vts/functional/Android.bp b/wifi/supplicant/1.3/vts/functional/Android.bp index abb86008b5..3dabe7cd93 100644 --- a/wifi/supplicant/1.3/vts/functional/Android.bp +++ b/wifi/supplicant/1.3/vts/functional/Android.bp @@ -19,7 +19,7 @@ cc_library_static { defaults: ["VtsHalTargetTestDefaults"], srcs: ["supplicant_hidl_test_utils_1_3.cpp"], export_include_dirs: [ - "." + ".", ], static_libs: [ "VtsHalWifiV1_0TargetTestUtil", @@ -61,5 +61,8 @@ cc_test { "libwifi-system", "libwifi-system-iface", ], - test_suites: ["general-tests"], + test_suites: [ + "general-tests", + "vts-core", + ], } diff --git a/wifi/supplicant/1.3/vts/functional/VtsHalWifiSupplicantV1_3TargetTest.cpp b/wifi/supplicant/1.3/vts/functional/VtsHalWifiSupplicantV1_3TargetTest.cpp index 4dbb64eeda..9dbeee104f 100644 --- a/wifi/supplicant/1.3/vts/functional/VtsHalWifiSupplicantV1_3TargetTest.cpp +++ b/wifi/supplicant/1.3/vts/functional/VtsHalWifiSupplicantV1_3TargetTest.cpp @@ -14,49 +14,8 @@ * limitations under the License. */ -#include -#include -#include - #include "supplicant_hidl_test_utils.h" -#include "wifi_hidl_test_utils.h" -class WifiSupplicantHidlEnvironment_1_3 : public WifiSupplicantHidlEnvironment { - public: - // get the test environment singleton - static WifiSupplicantHidlEnvironment_1_3* Instance() { - static WifiSupplicantHidlEnvironment_1_3* instance = - new WifiSupplicantHidlEnvironment_1_3; - return instance; - } - virtual void registerTestServices() override { - registerTestService<::android::hardware::wifi::V1_0::IWifi>(); - registerTestService<::android::hardware::wifi::V1_1::IWifi>(); - registerTestService< - ::android::hardware::wifi::supplicant::V1_0::ISupplicant>(); - registerTestService< - ::android::hardware::wifi::supplicant::V1_1::ISupplicant>(); - registerTestService< - ::android::hardware::wifi::supplicant::V1_2::ISupplicant>(); - registerTestService< - ::android::hardware::wifi::supplicant::V1_3::ISupplicant>(); - } - - private: - WifiSupplicantHidlEnvironment_1_3() {} -}; - -WifiSupplicantHidlEnvironment* gEnv = - WifiSupplicantHidlEnvironment_1_3::Instance(); - -int main(int argc, char** argv) { - ::testing::AddGlobalTestEnvironment(gEnv); - ::testing::InitGoogleTest(&argc, argv); - gEnv->init(&argc, argv); - int status = gEnv->initFromOptions(argc, argv); - if (status == 0) { - int status = RUN_ALL_TESTS(); - LOG(INFO) << "Test result = " << status; - } - return status; -} +// TODO(b/143892896): Remove this file after wifi_hidl_test_utils.cpp is +// updated. +WifiSupplicantHidlEnvironment* gEnv = nullptr; diff --git a/wifi/supplicant/1.3/vts/functional/supplicant_hidl_test_utils_1_3.cpp b/wifi/supplicant/1.3/vts/functional/supplicant_hidl_test_utils_1_3.cpp index 308808deff..7ea54620da 100644 --- a/wifi/supplicant/1.3/vts/functional/supplicant_hidl_test_utils_1_3.cpp +++ b/wifi/supplicant/1.3/vts/functional/supplicant_hidl_test_utils_1_3.cpp @@ -21,13 +21,25 @@ #include "supplicant_hidl_test_utils_1_3.h" using ::android::sp; +using ::android::hardware::wifi::supplicant::V1_3::ISupplicant; using ::android::hardware::wifi::supplicant::V1_3::ISupplicantStaIface; using ::android::hardware::wifi::supplicant::V1_3::ISupplicantStaNetwork; -sp getSupplicantStaIface_1_3() { - return ISupplicantStaIface::castFrom(getSupplicantStaIface()); +sp getSupplicantStaIface_1_3( + const android::sp& + supplicant) { + return ISupplicantStaIface::castFrom(getSupplicantStaIface(supplicant)); } -sp createSupplicantStaNetwork_1_3() { - return ISupplicantStaNetwork::castFrom(createSupplicantStaNetwork()); +sp createSupplicantStaNetwork_1_3( + const android::sp& + supplicant) { + return ISupplicantStaNetwork::castFrom( + createSupplicantStaNetwork(supplicant)); +} + +sp getSupplicant_1_3(const std::string& supplicant_instance_name, + bool isP2pOn) { + return ISupplicant::castFrom( + getSupplicant(supplicant_instance_name, isP2pOn)); } diff --git a/wifi/supplicant/1.3/vts/functional/supplicant_hidl_test_utils_1_3.h b/wifi/supplicant/1.3/vts/functional/supplicant_hidl_test_utils_1_3.h index 39dbb8fc96..f8dca138fd 100644 --- a/wifi/supplicant/1.3/vts/functional/supplicant_hidl_test_utils_1_3.h +++ b/wifi/supplicant/1.3/vts/functional/supplicant_hidl_test_utils_1_3.h @@ -17,12 +17,18 @@ #ifndef SUPPLICANT_HIDL_TEST_UTILS_1_3_H #define SUPPLICANT_HIDL_TEST_UTILS_1_3_H +#include #include #include android::sp -getSupplicantStaIface_1_3(); +getSupplicantStaIface_1_3( + const android::sp& + supplicant); android::sp -createSupplicantStaNetwork_1_3(); - +createSupplicantStaNetwork_1_3( + const android::sp& + supplicant); +android::sp +getSupplicant_1_3(const std::string& supplicant_instance_name, bool isP2pOn); #endif /* SUPPLICANT_HIDL_TEST_UTILS_1_3_H */ diff --git a/wifi/supplicant/1.3/vts/functional/supplicant_sta_iface_hidl_test.cpp b/wifi/supplicant/1.3/vts/functional/supplicant_sta_iface_hidl_test.cpp index adc955e68b..48b14f35c3 100644 --- a/wifi/supplicant/1.3/vts/functional/supplicant_sta_iface_hidl_test.cpp +++ b/wifi/supplicant/1.3/vts/functional/supplicant_sta_iface_hidl_test.cpp @@ -14,13 +14,19 @@ * limitations under the License. */ -#include +#include +#include +#include #include +#include #include #include #include #include +#include +#include #include +#include #include #include "supplicant_hidl_test_utils.h" @@ -40,6 +46,7 @@ using ::android::hardware::wifi::supplicant::V1_2::DppNetRole; using ::android::hardware::wifi::supplicant::V1_2::DppProgressCode; using ::android::hardware::wifi::supplicant::V1_3::ConnectionCapabilities; using ::android::hardware::wifi::supplicant::V1_3::DppSuccessCode; +using ::android::hardware::wifi::supplicant::V1_3::ISupplicant; using ::android::hardware::wifi::supplicant::V1_3::ISupplicantStaIface; using ::android::hardware::wifi::supplicant::V1_3::ISupplicantStaIfaceCallback; using ::android::hardware::wifi::supplicant::V1_3::ISupplicantStaNetwork; @@ -48,16 +55,27 @@ using ::android::hardware::wifi::supplicant::V1_3::WpaDriverCapabilitiesMask; #define TIMEOUT_PERIOD 60 class IfaceDppCallback; -class SupplicantStaIfaceHidlTest : public ::testing::VtsHalHidlTargetTestBase { +class SupplicantStaIfaceHidlTest + : public ::testing::TestWithParam> { public: virtual void SetUp() override { - startSupplicantAndWaitForHidlService(); - EXPECT_TRUE(turnOnExcessiveLogging()); - sta_iface_ = getSupplicantStaIface_1_3(); + wifi_v1_0_instance_name_ = std::get<0>(GetParam()); + supplicant_v1_3_instance_name_ = std::get<1>(GetParam()); + isP2pOn_ = + testing::deviceSupportsFeature("android.hardware.wifi.direct"); + + startSupplicantAndWaitForHidlService(wifi_v1_0_instance_name_, + supplicant_v1_3_instance_name_); + supplicant_ = + getSupplicant_1_3(supplicant_v1_3_instance_name_, isP2pOn_); + EXPECT_TRUE(turnOnExcessiveLogging(supplicant_)); + sta_iface_ = getSupplicantStaIface_1_3(supplicant_); ASSERT_NE(sta_iface_.get(), nullptr); } - virtual void TearDown() override { stopSupplicant(); } + virtual void TearDown() override { + stopSupplicant(wifi_v1_0_instance_name_); + } int64_t pmkCacheExpirationTimeInSec; std::vector serializedPmkCacheEntry; @@ -104,6 +122,11 @@ class SupplicantStaIfaceHidlTest : public ::testing::VtsHalHidlTargetTestBase { protected: // ISupplicantStaIface object used for all tests in this fixture. sp sta_iface_; + sp supplicant_; + bool isP2pOn_ = false; + std::string wifi_v1_0_instance_name_; + std::string supplicant_v1_3_instance_name_; + bool isDppSupported() { uint32_t keyMgmtMask = 0; @@ -302,7 +325,7 @@ class IfaceBssTmHandlingDoneCallback : public IfaceCallback { /* * RegisterCallback_1_3 */ -TEST_F(SupplicantStaIfaceHidlTest, RegisterCallback_1_3) { +TEST_P(SupplicantStaIfaceHidlTest, RegisterCallback_1_3) { sta_iface_->registerCallback_1_3( new IfaceCallback(), [](const SupplicantStatus& status) { EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code); @@ -312,7 +335,7 @@ TEST_F(SupplicantStaIfaceHidlTest, RegisterCallback_1_3) { /* * getConnectionCapabilities */ -TEST_F(SupplicantStaIfaceHidlTest, GetConnectionCapabilities) { +TEST_P(SupplicantStaIfaceHidlTest, GetConnectionCapabilities) { sta_iface_->getConnectionCapabilities( [&](const SupplicantStatus& status, ConnectionCapabilities /* capabilities */) { @@ -323,7 +346,7 @@ TEST_F(SupplicantStaIfaceHidlTest, GetConnectionCapabilities) { /* * GetWpaDriverCapabilities */ -TEST_F(SupplicantStaIfaceHidlTest, GetWpaDriverCapabilities) { +TEST_P(SupplicantStaIfaceHidlTest, GetWpaDriverCapabilities) { sta_iface_->getWpaDriverCapabilities( [&](const SupplicantStatus& status, uint32_t) { EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code); @@ -333,7 +356,7 @@ TEST_F(SupplicantStaIfaceHidlTest, GetWpaDriverCapabilities) { /* * SetMboCellularDataStatus */ -TEST_F(SupplicantStaIfaceHidlTest, SetMboCellularDataStatus) { +TEST_P(SupplicantStaIfaceHidlTest, SetMboCellularDataStatus) { uint32_t driverCapMask = 0; // Get MBO support from the device. @@ -358,7 +381,7 @@ TEST_F(SupplicantStaIfaceHidlTest, SetMboCellularDataStatus) { /* * GetKeyMgmtCapabilities_1_3 */ -TEST_F(SupplicantStaIfaceHidlTest, GetKeyMgmtCapabilities_1_3) { +TEST_P(SupplicantStaIfaceHidlTest, GetKeyMgmtCapabilities_1_3) { sta_iface_->getKeyMgmtCapabilities_1_3([&](const SupplicantStatus& status, uint32_t keyMgmtMask) { if (SupplicantStatusCode::SUCCESS != status.code) { @@ -377,7 +400,7 @@ TEST_F(SupplicantStaIfaceHidlTest, GetKeyMgmtCapabilities_1_3) { /* * StartDppEnrolleeInitiator */ -TEST_F(SupplicantStaIfaceHidlTest, StartDppEnrolleeInitiator) { +TEST_P(SupplicantStaIfaceHidlTest, StartDppEnrolleeInitiator) { // We need to first get the key management capabilities from the device. // If DPP is not supported, we just pass the test. if (!isDppSupported()) { @@ -428,7 +451,7 @@ TEST_F(SupplicantStaIfaceHidlTest, StartDppEnrolleeInitiator) { /* * StartDppConfiguratorInitiator */ -TEST_F(SupplicantStaIfaceHidlTest, StartDppConfiguratorInitiator) { +TEST_P(SupplicantStaIfaceHidlTest, StartDppConfiguratorInitiator) { // We need to first get the key management capabilities from the device. // If DPP is not supported, we just pass the test. if (!isDppSupported()) { @@ -480,3 +503,12 @@ TEST_F(SupplicantStaIfaceHidlTest, StartDppConfiguratorInitiator) { EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code); }); } +INSTANTIATE_TEST_CASE_P( + PerInstance, SupplicantStaIfaceHidlTest, + testing::Combine( + testing::ValuesIn(android::hardware::getAllHalInstanceNames( + android::hardware::wifi::V1_0::IWifi::descriptor)), + testing::ValuesIn(android::hardware::getAllHalInstanceNames( + android::hardware::wifi::supplicant::V1_3::ISupplicant:: + descriptor))), + android::hardware::PrintInstanceTupleNameToString<>); diff --git a/wifi/supplicant/1.3/vts/functional/supplicant_sta_network_hidl_test.cpp b/wifi/supplicant/1.3/vts/functional/supplicant_sta_network_hidl_test.cpp index d6f55f54fc..d82db50c9c 100644 --- a/wifi/supplicant/1.3/vts/functional/supplicant_sta_network_hidl_test.cpp +++ b/wifi/supplicant/1.3/vts/functional/supplicant_sta_network_hidl_test.cpp @@ -16,9 +16,16 @@ #include +#include #include +#include +#include +#include #include #include +#include +#include +#include #include "supplicant_hidl_test_utils.h" #include "supplicant_hidl_test_utils_1_3.h" @@ -28,6 +35,7 @@ using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatus; using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatusCode; +using ::android::hardware::wifi::supplicant::V1_3::ISupplicant; using ::android::hardware::wifi::supplicant::V1_3::ISupplicantStaIface; using ::android::hardware::wifi::supplicant::V1_3::ISupplicantStaNetwork; using ::android::hardware::wifi::supplicant::V1_3::OcspType; @@ -37,23 +45,34 @@ constexpr OcspType kTestInvalidOcspType = (OcspType)-1; } // namespace class SupplicantStaNetworkHidlTest - : public ::testing::VtsHalHidlTargetTestBase { + : public ::testing::TestWithParam> { public: virtual void SetUp() override { - startSupplicantAndWaitForHidlService(); - EXPECT_TRUE(turnOnExcessiveLogging()); - sta_iface_ = getSupplicantStaIface_1_3(); - ASSERT_NE(nullptr, sta_iface_.get()); - sta_network_ = createSupplicantStaNetwork_1_3(); - ASSERT_NE(nullptr, sta_network_.get()); + wifi_v1_0_instance_name_ = std::get<0>(GetParam()); + supplicant_v1_3_instance_name_ = std::get<1>(GetParam()); + isP2pOn_ = + testing::deviceSupportsFeature("android.hardware.wifi.direct"); + startSupplicantAndWaitForHidlService(wifi_v1_0_instance_name_, + supplicant_v1_3_instance_name_); + supplicant_ = + getSupplicant_1_3(supplicant_v1_3_instance_name_, isP2pOn_); + EXPECT_TRUE(turnOnExcessiveLogging(supplicant_)); + sta_network_ = createSupplicantStaNetwork_1_3(supplicant_); + ASSERT_NE(sta_network_.get(), nullptr); } - virtual void TearDown() override { stopSupplicant(); } + virtual void TearDown() override { + stopSupplicant(wifi_v1_0_instance_name_); + } protected: sp sta_iface_; // ISupplicantStaNetwork object used for all tests in this fixture. sp sta_network_; + sp supplicant_; + bool isP2pOn_ = false; + std::string wifi_v1_0_instance_name_; + std::string supplicant_v1_3_instance_name_; bool isWapiSupported() { uint32_t keyMgmtMask = 0; @@ -78,7 +97,7 @@ class SupplicantStaNetworkHidlTest /* * SetGetOcsp */ -TEST_F(SupplicantStaNetworkHidlTest, SetGetOcsp) { +TEST_P(SupplicantStaNetworkHidlTest, SetGetOcsp) { OcspType testOcspType = kTestOcspType; sta_network_->setOcsp(testOcspType, [](const SupplicantStatus &status) { @@ -100,7 +119,7 @@ TEST_F(SupplicantStaNetworkHidlTest, SetGetOcsp) { /* * SetPmkCacheEntry */ -TEST_F(SupplicantStaNetworkHidlTest, SetPmkCache) { +TEST_P(SupplicantStaNetworkHidlTest, SetPmkCache) { uint8_t bytes[128] = {0}; std::vector serializedEntry(bytes, bytes + sizeof(bytes)); @@ -113,7 +132,7 @@ TEST_F(SupplicantStaNetworkHidlTest, SetPmkCache) { /* * SetGetKeyMgmt_1_3, check new WAPI proto support */ -TEST_F(SupplicantStaNetworkHidlTest, SetGetKeyMgmt_1_3) { +TEST_P(SupplicantStaNetworkHidlTest, SetGetKeyMgmt_1_3) { uint32_t keyMgmt = (uint32_t)ISupplicantStaNetwork::KeyMgmtMask::WAPI_PSK; sta_network_->setKeyMgmt_1_3(keyMgmt, [](const SupplicantStatus &status) { @@ -155,7 +174,7 @@ TEST_F(SupplicantStaNetworkHidlTest, SetGetKeyMgmt_1_3) { /* * SetGetProto_1_3, check new WAPI proto support */ -TEST_F(SupplicantStaNetworkHidlTest, SetGetProto_1_3) { +TEST_P(SupplicantStaNetworkHidlTest, SetGetProto_1_3) { uint32_t wapiProto = (uint32_t)ISupplicantStaNetwork::ProtoMask::WAPI; sta_network_->setProto(wapiProto, [](const SupplicantStatus &status) { if (SupplicantStatusCode::SUCCESS != status.code) { @@ -176,7 +195,7 @@ TEST_F(SupplicantStaNetworkHidlTest, SetGetProto_1_3) { /* * SetGetGroupCipher_1_3, check new WAPI support */ -TEST_F(SupplicantStaNetworkHidlTest, SetGetGroupCipher_1_3) { +TEST_P(SupplicantStaNetworkHidlTest, SetGetGroupCipher_1_3) { uint32_t groupCipher = (uint32_t)ISupplicantStaNetwork::GroupCipherMask::SMS4; @@ -203,7 +222,7 @@ TEST_F(SupplicantStaNetworkHidlTest, SetGetGroupCipher_1_3) { /* * SetGetPairwiseCipher_1_3, check new WAPI support */ -TEST_F(SupplicantStaNetworkHidlTest, SetGetPairwiseCipher_1_3) { +TEST_P(SupplicantStaNetworkHidlTest, SetGetPairwiseCipher_1_3) { uint32_t pairwiseCipher = (uint32_t)ISupplicantStaNetwork::PairwiseCipherMask::SMS4; @@ -230,7 +249,7 @@ TEST_F(SupplicantStaNetworkHidlTest, SetGetPairwiseCipher_1_3) { /* * SetGetWapiCertSuite */ -TEST_F(SupplicantStaNetworkHidlTest, SetGetWapiCertSuite) { +TEST_P(SupplicantStaNetworkHidlTest, SetGetWapiCertSuite) { hidl_string testWapiCertSuite = "suite"; if (isWapiSupported()) { @@ -266,3 +285,12 @@ TEST_F(SupplicantStaNetworkHidlTest, SetGetWapiCertSuite) { }); } } +INSTANTIATE_TEST_CASE_P( + PerInstance, SupplicantStaNetworkHidlTest, + testing::Combine( + testing::ValuesIn(android::hardware::getAllHalInstanceNames( + android::hardware::wifi::V1_0::IWifi::descriptor)), + testing::ValuesIn(android::hardware::getAllHalInstanceNames( + android::hardware::wifi::supplicant::V1_3::ISupplicant:: + descriptor))), + android::hardware::PrintInstanceTupleNameToString<>);