From fa7543563f144a4d9de25fad3b587d114f2ee55e Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Mon, 14 Sep 2020 15:07:47 +0800 Subject: [PATCH] wifi: wait for the framework to be ready before checking features supplicant vts will stop and then start the framework, it is too slow to allow next test checking necessary features. This change also create a base class, SupplicantHidlTestBase, to do the common initialization for all vts tests. Bug: 167230822 Test: atest VtsHalWifiSupplicantV1_0TargetTest \ VtsHalWifiSupplicantP2pV1_0TargetTest \ VtsHalWifiSupplicantV1_1TargetTest \ VtsHalWifiSupplicantV1_2TargetTest \ VtsHalWifiSupplicantP2pV1_2TargetTest \ VtsHalWifiSupplicantV1_3TargetTest \ Change-Id: Ice25c6d2198f719fc964a17515e66146a0a8ace2 --- .../functional/supplicant_hidl_test_utils.cpp | 14 ++++++ .../functional/supplicant_hidl_test_utils.h | 49 +++++++++++++++++++ .../supplicant_p2p_iface_hidl_test.cpp | 45 +++++------------ .../supplicant_sta_iface_hidl_test.cpp | 30 ++---------- .../supplicant_sta_network_hidl_test.cpp | 29 ++--------- .../vts/functional/supplicant_hidl_test.cpp | 4 +- .../supplicant_hidl_test_utils_1_1.h | 25 ++-------- .../supplicant_sta_iface_hidl_test.cpp | 7 ++- .../supplicant_sta_network_hidl_test.cpp | 11 ++--- .../supplicant_hidl_test_utils_1_2.h | 25 ++-------- .../supplicant_p2p_iface_hidl_test.cpp | 5 +- .../supplicant_sta_iface_hidl_test.cpp | 5 +- .../supplicant_sta_network_hidl_test.cpp | 4 +- .../supplicant_hidl_test_utils_1_3.h | 13 +++++ .../supplicant_sta_iface_hidl_test.cpp | 27 +--------- .../supplicant_sta_network_hidl_test.cpp | 27 +--------- 16 files changed, 124 insertions(+), 196 deletions(-) diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp index 5e7a371d67..be6aad9583 100644 --- a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp +++ b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp @@ -283,3 +283,17 @@ bool turnOnExcessiveLogging(const sp& supplicant) { }); return !operation_failed; } + +bool waitForFrameworkReady() { + int waitCount = 10; + do { + // Check whether package service is ready or not. + if (!testing::checkSubstringInCommandOutput( + "/system/bin/service check package", ": not found")) { + return true; + } + LOG(INFO) << "Framework is not ready"; + sleep(1); + } while (waitCount-- > 0); + return false; +} diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.h b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.h index 1ccf0919aa..33945ccb19 100644 --- a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.h +++ b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.h @@ -17,6 +17,8 @@ #ifndef SUPPLICANT_HIDL_TEST_UTILS_H #define SUPPLICANT_HIDL_TEST_UTILS_H +#include +#include #include #include #include @@ -62,4 +64,51 @@ bool turnOnExcessiveLogging( bool turnOnExcessiveLogging(); +bool waitForFrameworkReady(); + +class SupplicantHidlTestBase + : public ::testing::TestWithParam> { + public: + virtual void SetUp() override { + // should always be v1.0 wifi + wifi_v1_0_instance_name_ = std::get<0>(GetParam()); + supplicant_instance_name_ = std::get<1>(GetParam()); + std::system("/system/bin/start"); + ASSERT_TRUE(waitForFrameworkReady()); + + isP2pOn_ = + testing::deviceSupportsFeature("android.hardware.wifi.direct"); + // Stop Framework + std::system("/system/bin/stop"); + stopSupplicant(wifi_v1_0_instance_name_); + startSupplicantAndWaitForHidlService(wifi_v1_0_instance_name_, + supplicant_instance_name_); + LOG(INFO) << "SupplicantHidlTestBase isP2pOn_: " << isP2pOn_; + } + + virtual void TearDown() override { + stopSupplicant(wifi_v1_0_instance_name_); + // Start Framework + std::system("/system/bin/start"); + } + + protected: + bool isP2pOn_ = false; + std::string wifi_v1_0_instance_name_; + std::string supplicant_instance_name_; +}; + +class SupplicantHidlTestBaseV1_0 : public SupplicantHidlTestBase { + public: + virtual void SetUp() override { + SupplicantHidlTestBase::SetUp(); + supplicant_ = getSupplicant(supplicant_instance_name_, isP2pOn_); + ASSERT_NE(supplicant_.get(), nullptr); + EXPECT_TRUE(turnOnExcessiveLogging(supplicant_)); + } + + protected: + android::sp + supplicant_; +}; #endif /* SUPPLICANT_HIDL_TEST_UTILS_H */ diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp index c333c4f859..e897e73062 100644 --- a/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp +++ b/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp @@ -71,21 +71,13 @@ constexpr uint32_t kTestExtListenInterval = 400; constexpr SupplicantNetworkId kTestNetworkId = 5; } // namespace -class SupplicantP2pIfaceHidlTest - : public ::testing::TestWithParam> { +class SupplicantP2pIfaceHidlTest : public SupplicantHidlTestBaseV1_0 { public: virtual void SetUp() override { - wifi_instance_name_ = std::get<0>(GetParam()); - supplicant_instance_name_ = std::get<1>(GetParam()); - isP2pOn_ = - testing::deviceSupportsFeature("android.hardware.wifi.direct"); - // Stop Framework - std::system("/system/bin/stop"); - stopSupplicant(wifi_instance_name_); - startSupplicantAndWaitForHidlService(wifi_instance_name_, - supplicant_instance_name_); - supplicant_ = getSupplicant(supplicant_instance_name_, isP2pOn_); - EXPECT_TRUE(turnOnExcessiveLogging(supplicant_)); + SupplicantHidlTestBaseV1_0::SetUp(); + if (!isP2pOn_) { + GTEST_SKIP() << "Wi-Fi Direct is not supported, skip this test."; + } p2p_iface_ = getSupplicantP2pIface(supplicant_); ASSERT_NE(p2p_iface_.get(), nullptr); @@ -93,22 +85,11 @@ class SupplicantP2pIfaceHidlTest memcpy(peer_mac_addr_.data(), kTestPeerMacAddr, peer_mac_addr_.size()); } - virtual void TearDown() override { - stopSupplicant(wifi_instance_name_); - // Start Framework - std::system("/system/bin/start"); - } - protected: - bool isP2pOn_ = false; - sp supplicant_; - // ISupplicantP2pIface object used for all tests in this fixture. sp p2p_iface_; // MAC address to use for various tests. std::array mac_addr_; std::array peer_mac_addr_; - std::string wifi_instance_name_; - std::string supplicant_instance_name_; }; class IfaceCallback : public ISupplicantP2pIfaceCallback { @@ -201,8 +182,8 @@ class IfaceCallback : public ISupplicantP2pIfaceCallback { * successfully created. */ TEST_P(SupplicantP2pIfaceHidlTest, Create) { - stopSupplicant(wifi_instance_name_); - startSupplicantAndWaitForHidlService(wifi_instance_name_, + stopSupplicant(wifi_v1_0_instance_name_); + startSupplicantAndWaitForHidlService(wifi_v1_0_instance_name_, supplicant_instance_name_); sp p2p_iface = getSupplicantP2pIface( getSupplicant(supplicant_instance_name_, isP2pOn_)); @@ -301,8 +282,8 @@ TEST_P(SupplicantP2pIfaceHidlTest, Connect) { mac_addr_, ISupplicantP2pIface::WpsProvisionMethod::PBC, kTestConnectPin, false, false, kTestConnectGoIntent, [](const SupplicantStatus& status, const hidl_string& /* pin */) { - // This is not going to work with fake values. - EXPECT_EQ(SupplicantStatusCode::FAILURE_UNKNOWN, status.code); + // After enabling auto-join, it will succeed always. + EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code); }); } @@ -314,12 +295,12 @@ TEST_P(SupplicantP2pIfaceHidlTest, CancelConnect) { mac_addr_, ISupplicantP2pIface::WpsProvisionMethod::PBC, kTestConnectPin, false, false, kTestConnectGoIntent, [](const SupplicantStatus& status, const hidl_string& /* pin */) { - // This is not going to work with fake values. - EXPECT_EQ(SupplicantStatusCode::FAILURE_UNKNOWN, status.code); + // After enabling auto-join, it will succeed always. + EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code); }); p2p_iface_->cancelConnect([](const SupplicantStatus& status) { - EXPECT_EQ(SupplicantStatusCode::FAILURE_UNKNOWN, status.code); + EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code); }); } @@ -654,4 +635,4 @@ INSTANTIATE_TEST_CASE_P( android::hardware::getAllHalInstanceNames(IWifi::descriptor)), testing::ValuesIn(android::hardware::getAllHalInstanceNames( ISupplicant::descriptor))), - android::hardware::PrintInstanceTupleNameToString<>); \ No newline at end of file + android::hardware::PrintInstanceTupleNameToString<>); diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp index ff287541f8..9134b5a825 100644 --- a/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp +++ b/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp @@ -66,42 +66,22 @@ constexpr uint8_t kTestWpsDeviceType[] = {[0 ... 7] = 0x01}; constexpr uint16_t kTestWpsConfigMethods = 0xffff; } // namespace -class SupplicantStaIfaceHidlTest - : public ::testing::TestWithParam> { +class SupplicantStaIfaceHidlTest : public SupplicantHidlTestBaseV1_0 { public: virtual void SetUp() override { - wifi_instance_name_ = std::get<0>(GetParam()); - supplicant_instance_name_ = std::get<1>(GetParam()); - isP2pOn_ = - testing::deviceSupportsFeature("android.hardware.wifi.direct"); - // Stop Framework - std::system("/system/bin/stop"); - stopSupplicant(wifi_instance_name_); - startSupplicantAndWaitForHidlService(wifi_instance_name_, - supplicant_instance_name_); - supplicant_ = getSupplicant(supplicant_instance_name_, isP2pOn_); - EXPECT_TRUE(turnOnExcessiveLogging(supplicant_)); + SupplicantHidlTestBaseV1_0::SetUp(); sta_iface_ = getSupplicantStaIface(supplicant_); ASSERT_NE(sta_iface_.get(), nullptr); memcpy(mac_addr_.data(), kTestMacAddr, mac_addr_.size()); } - virtual void TearDown() override { - stopSupplicant(wifi_instance_name_); - // Start Framework - std::system("/system/bin/start"); - } - protected: bool isP2pOn_ = false; - sp supplicant_; // ISupplicantStaIface object used for all tests in this fixture. sp sta_iface_; // MAC address to use for various tests. std::array mac_addr_; - std::string wifi_instance_name_; - std::string supplicant_instance_name_; }; class IfaceCallback : public ISupplicantStaIfaceCallback { @@ -183,8 +163,8 @@ class IfaceCallback : public ISupplicantStaIfaceCallback { * successfully created. */ TEST_P(SupplicantStaIfaceHidlTest, Create) { - stopSupplicant(wifi_instance_name_); - startSupplicantAndWaitForHidlService(wifi_instance_name_, + stopSupplicant(wifi_v1_0_instance_name_); + startSupplicantAndWaitForHidlService(wifi_v1_0_instance_name_, supplicant_instance_name_); EXPECT_NE(nullptr, getSupplicantStaIface( getSupplicant(supplicant_instance_name_, isP2pOn_)) @@ -565,4 +545,4 @@ INSTANTIATE_TEST_CASE_P( android::hardware::getAllHalInstanceNames(IWifi::descriptor)), testing::ValuesIn(android::hardware::getAllHalInstanceNames( ISupplicant::descriptor))), - android::hardware::PrintInstanceTupleNameToString<>); \ No newline at end of file + android::hardware::PrintInstanceTupleNameToString<>); diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp index 295ebfb808..b94b6b27a9 100644 --- a/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp +++ b/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp @@ -79,21 +79,10 @@ constexpr uint32_t kTestPairwiseCipher = ISupplicantStaNetwork::PairwiseCipherMask::TKIP); } // namespace -class SupplicantStaNetworkHidlTest - : public ::testing::TestWithParam> { +class SupplicantStaNetworkHidlTest : public SupplicantHidlTestBaseV1_0 { public: virtual void SetUp() override { - wifi_instance_name_ = std::get<0>(GetParam()); - supplicant_instance_name_ = std::get<1>(GetParam()); - isP2pOn_ = - testing::deviceSupportsFeature("android.hardware.wifi.direct"); - // Stop Framework - std::system("/system/bin/stop"); - stopSupplicant(wifi_instance_name_); - startSupplicantAndWaitForHidlService(wifi_instance_name_, - supplicant_instance_name_); - supplicant_ = getSupplicant(supplicant_instance_name_, isP2pOn_); - EXPECT_TRUE(turnOnExcessiveLogging(supplicant_)); + SupplicantHidlTestBaseV1_0::SetUp(); sta_network_ = createSupplicantStaNetwork(supplicant_); ASSERT_NE(sta_network_.get(), nullptr); /* variable used to check if the underlying HAL version is 1.3 or @@ -105,12 +94,6 @@ class SupplicantStaNetworkHidlTest ssid_.assign(kTestSsidStr, kTestSsidStr + strlen(kTestSsidStr)); } - virtual void TearDown() override { - stopSupplicant(wifi_instance_name_); - // Start Framework - std::system("/system/bin/start"); - } - protected: void removeNetwork() { sp sta_iface = getSupplicantStaIface(supplicant_); @@ -128,14 +111,10 @@ class SupplicantStaNetworkHidlTest sp<::android::hardware::wifi::supplicant::V1_3::ISupplicantStaNetwork> v1_3 = nullptr; - bool isP2pOn_ = false; - sp supplicant_; // ISupplicantStaNetwork object used for all tests in this fixture. sp sta_network_; // SSID to use for various tests. std::vector ssid_; - std::string wifi_instance_name_; - std::string supplicant_instance_name_; }; class NetworkCallback : public ISupplicantStaNetworkCallback { @@ -158,8 +137,8 @@ class NetworkCallback : public ISupplicantStaNetworkCallback { * successfully created. */ TEST_P(SupplicantStaNetworkHidlTest, Create) { - stopSupplicant(wifi_instance_name_); - startSupplicantAndWaitForHidlService(wifi_instance_name_, + stopSupplicant(wifi_v1_0_instance_name_); + startSupplicantAndWaitForHidlService(wifi_v1_0_instance_name_, supplicant_instance_name_); sp supplicant = getSupplicant(supplicant_instance_name_, isP2pOn_); diff --git a/wifi/supplicant/1.1/vts/functional/supplicant_hidl_test.cpp b/wifi/supplicant/1.1/vts/functional/supplicant_hidl_test.cpp index 24a7ec31aa..4d952e4760 100644 --- a/wifi/supplicant/1.1/vts/functional/supplicant_hidl_test.cpp +++ b/wifi/supplicant/1.1/vts/functional/supplicant_hidl_test.cpp @@ -35,9 +35,9 @@ using ::android::hardware::wifi::supplicant::V1_0::IfaceType; using ::android::hardware::wifi::supplicant::V1_1::ISupplicant; using ::android::sp; -class SupplicantHidlTest : public SupplicantHidlTestBase { +class SupplicantHidlTest : public SupplicantHidlTestBaseV1_1 { public: - virtual void SetUp() override { SupplicantHidlTestBase::SetUp(); } + virtual void SetUp() override { SupplicantHidlTestBaseV1_1::SetUp(); } protected: std::string getWlan0IfaceName() { diff --git a/wifi/supplicant/1.1/vts/functional/supplicant_hidl_test_utils_1_1.h b/wifi/supplicant/1.1/vts/functional/supplicant_hidl_test_utils_1_1.h index 2104794770..b6feb41abe 100644 --- a/wifi/supplicant/1.1/vts/functional/supplicant_hidl_test_utils_1_1.h +++ b/wifi/supplicant/1.1/vts/functional/supplicant_hidl_test_utils_1_1.h @@ -36,34 +36,15 @@ createSupplicantStaNetwork_1_1( const android::sp& supplicant); -class SupplicantHidlTestBase - : public ::testing::TestWithParam> { +class SupplicantHidlTestBaseV1_1 : public SupplicantHidlTestBase { public: virtual void SetUp() override { - wifi_v1_0_instance_name_ = std::get<0>(GetParam()); - supplicant_v1_1_instance_name_ = std::get<1>(GetParam()); - isP2pOn_ = - testing::deviceSupportsFeature("android.hardware.wifi.direct"); - // Stop Framework - std::system("/system/bin/stop"); - stopSupplicant(wifi_v1_0_instance_name_); - startSupplicantAndWaitForHidlService(wifi_v1_0_instance_name_, - supplicant_v1_1_instance_name_); - supplicant_ = - getSupplicant_1_1(supplicant_v1_1_instance_name_, isP2pOn_); + SupplicantHidlTestBase::SetUp(); + supplicant_ = getSupplicant_1_1(supplicant_instance_name_, isP2pOn_); ASSERT_NE(supplicant_.get(), nullptr); } - virtual void TearDown() override { - stopSupplicant(wifi_v1_0_instance_name_); - // Start Framework - std::system("/system/bin/start"); - } - protected: android::sp supplicant_; - bool isP2pOn_ = false; - std::string wifi_v1_0_instance_name_; - std::string supplicant_v1_1_instance_name_; }; diff --git a/wifi/supplicant/1.1/vts/functional/supplicant_sta_iface_hidl_test.cpp b/wifi/supplicant/1.1/vts/functional/supplicant_sta_iface_hidl_test.cpp index 8a1aeccf7d..05428ffcf9 100644 --- a/wifi/supplicant/1.1/vts/functional/supplicant_sta_iface_hidl_test.cpp +++ b/wifi/supplicant/1.1/vts/functional/supplicant_sta_iface_hidl_test.cpp @@ -39,11 +39,10 @@ using ::android::hardware::wifi::supplicant::V1_1::ISupplicant; using ::android::hardware::wifi::supplicant::V1_1::ISupplicantStaIface; using ::android::hardware::wifi::supplicant::V1_1::ISupplicantStaIfaceCallback; -class SupplicantStaIfaceHidlTest : public SupplicantHidlTestBase { +class SupplicantStaIfaceHidlTest : public SupplicantHidlTestBaseV1_1 { public: virtual void SetUp() override { - SupplicantHidlTestBase::SetUp(); - EXPECT_TRUE(turnOnExcessiveLogging(supplicant_)); + SupplicantHidlTestBaseV1_1::SetUp(); sta_iface_ = getSupplicantStaIface_1_1(supplicant_); ASSERT_NE(sta_iface_.get(), nullptr); } @@ -148,4 +147,4 @@ INSTANTIATE_TEST_CASE_P( testing::ValuesIn(android::hardware::getAllHalInstanceNames( android::hardware::wifi::supplicant::V1_1::ISupplicant:: descriptor))), - android::hardware::PrintInstanceTupleNameToString<>); \ No newline at end of file + android::hardware::PrintInstanceTupleNameToString<>); diff --git a/wifi/supplicant/1.1/vts/functional/supplicant_sta_network_hidl_test.cpp b/wifi/supplicant/1.1/vts/functional/supplicant_sta_network_hidl_test.cpp index a4b7d40b53..707b971e04 100644 --- a/wifi/supplicant/1.1/vts/functional/supplicant_sta_network_hidl_test.cpp +++ b/wifi/supplicant/1.1/vts/functional/supplicant_sta_network_hidl_test.cpp @@ -37,11 +37,10 @@ constexpr uint8_t kTestIdentity[] = {0x45, 0x67, 0x98, 0x67, 0x56}; constexpr uint8_t kTestEncryptedIdentity[] = {0x35, 0x37, 0x58, 0x57, 0x26}; } // namespace -class SupplicantStaNetworkHidlTest : public SupplicantHidlTestBase { +class SupplicantStaNetworkHidlTest : public SupplicantHidlTestBaseV1_1 { public: virtual void SetUp() override { - SupplicantHidlTestBase::SetUp(); - EXPECT_TRUE(turnOnExcessiveLogging(supplicant_)); + SupplicantHidlTestBaseV1_1::SetUp(); sta_network_ = createSupplicantStaNetwork_1_1(supplicant_); ASSERT_NE(sta_network_.get(), nullptr); } @@ -59,9 +58,9 @@ class SupplicantStaNetworkHidlTest : public SupplicantHidlTestBase { TEST_P(SupplicantStaNetworkHidlTest, Create) { stopSupplicant(wifi_v1_0_instance_name_); startSupplicantAndWaitForHidlService(wifi_v1_0_instance_name_, - supplicant_v1_1_instance_name_); + supplicant_instance_name_); sp supplicant = - getSupplicant_1_1(supplicant_v1_1_instance_name_, isP2pOn_); + getSupplicant_1_1(supplicant_instance_name_, isP2pOn_); EXPECT_NE(nullptr, createSupplicantStaNetwork_1_1(supplicant).get()); } @@ -101,4 +100,4 @@ INSTANTIATE_TEST_CASE_P( testing::ValuesIn(android::hardware::getAllHalInstanceNames( android::hardware::wifi::supplicant::V1_1::ISupplicant:: descriptor))), - android::hardware::PrintInstanceTupleNameToString<>); \ No newline at end of file + android::hardware::PrintInstanceTupleNameToString<>); diff --git a/wifi/supplicant/1.2/vts/functional/supplicant_hidl_test_utils_1_2.h b/wifi/supplicant/1.2/vts/functional/supplicant_hidl_test_utils_1_2.h index 2a432d075c..b9c5adef74 100644 --- a/wifi/supplicant/1.2/vts/functional/supplicant_hidl_test_utils_1_2.h +++ b/wifi/supplicant/1.2/vts/functional/supplicant_hidl_test_utils_1_2.h @@ -42,35 +42,16 @@ getSupplicantP2pIface_1_2( const android::sp& supplicant); -class SupplicantHidlTestBase - : public ::testing::TestWithParam> { +class SupplicantHidlTestBaseV1_2 : public SupplicantHidlTestBase { public: virtual void SetUp() override { - wifi_v1_0_instance_name_ = std::get<0>(GetParam()); - supplicant_v1_2_instance_name_ = std::get<1>(GetParam()); - isP2pOn_ = - testing::deviceSupportsFeature("android.hardware.wifi.direct"); - // Stop Framework - std::system("/system/bin/stop"); - stopSupplicant(wifi_v1_0_instance_name_); - startSupplicantAndWaitForHidlService(wifi_v1_0_instance_name_, - supplicant_v1_2_instance_name_); - supplicant_ = - getSupplicant_1_2(supplicant_v1_2_instance_name_, isP2pOn_); + SupplicantHidlTestBase::SetUp(); + supplicant_ = getSupplicant_1_2(supplicant_instance_name_, isP2pOn_); ASSERT_NE(supplicant_.get(), nullptr); EXPECT_TRUE(turnOnExcessiveLogging(supplicant_)); } - virtual void TearDown() override { - stopSupplicant(wifi_v1_0_instance_name_); - // Start Framework - std::system("/system/bin/start"); - } - protected: android::sp supplicant_; - bool isP2pOn_ = false; - std::string wifi_v1_0_instance_name_; - std::string supplicant_v1_2_instance_name_; }; diff --git a/wifi/supplicant/1.2/vts/functional/supplicant_p2p_iface_hidl_test.cpp b/wifi/supplicant/1.2/vts/functional/supplicant_p2p_iface_hidl_test.cpp index cab160bc1f..42510c527e 100644 --- a/wifi/supplicant/1.2/vts/functional/supplicant_p2p_iface_hidl_test.cpp +++ b/wifi/supplicant/1.2/vts/functional/supplicant_p2p_iface_hidl_test.cpp @@ -38,11 +38,10 @@ constexpr char kTestPassphrase[] = "P2pWorld1234"; constexpr uint8_t kTestZeroMacAddr[] = {[0 ... 5] = 0x0}; } // namespace -class SupplicantP2pIfaceHidlTest : public SupplicantHidlTestBase { +class SupplicantP2pIfaceHidlTest : public SupplicantHidlTestBaseV1_2 { public: virtual void SetUp() override { - SupplicantHidlTestBase::SetUp(); - EXPECT_TRUE(turnOnExcessiveLogging(supplicant_)); + SupplicantHidlTestBaseV1_2::SetUp(); if (!isP2pOn_) { GTEST_SKIP() << "Wi-Fi Direct is not supported, skip this test."; } diff --git a/wifi/supplicant/1.2/vts/functional/supplicant_sta_iface_hidl_test.cpp b/wifi/supplicant/1.2/vts/functional/supplicant_sta_iface_hidl_test.cpp index 7377f780f2..28d1b32839 100644 --- a/wifi/supplicant/1.2/vts/functional/supplicant_sta_iface_hidl_test.cpp +++ b/wifi/supplicant/1.2/vts/functional/supplicant_sta_iface_hidl_test.cpp @@ -53,11 +53,10 @@ using ::android::hardware::wifi::supplicant::V1_2::ISupplicantStaNetwork; #define TIMEOUT_PERIOD 60 class IfaceDppCallback; -class SupplicantStaIfaceHidlTest : public SupplicantHidlTestBase { +class SupplicantStaIfaceHidlTest : public SupplicantHidlTestBaseV1_2 { public: virtual void SetUp() override { - SupplicantHidlTestBase::SetUp(); - EXPECT_TRUE(turnOnExcessiveLogging(supplicant_)); + SupplicantHidlTestBaseV1_2::SetUp(); sta_iface_ = getSupplicantStaIface_1_2(supplicant_); ASSERT_NE(sta_iface_.get(), nullptr); count_ = 0; diff --git a/wifi/supplicant/1.2/vts/functional/supplicant_sta_network_hidl_test.cpp b/wifi/supplicant/1.2/vts/functional/supplicant_sta_network_hidl_test.cpp index 54ceb20211..679ab137ff 100644 --- a/wifi/supplicant/1.2/vts/functional/supplicant_sta_network_hidl_test.cpp +++ b/wifi/supplicant/1.2/vts/functional/supplicant_sta_network_hidl_test.cpp @@ -37,10 +37,10 @@ using ::android::hardware::wifi::supplicant::V1_2::ISupplicantStaNetwork; // constexpr uint8_t kTestEncryptedIdentity[] = {0x35, 0x37, 0x58, 0x57, 0x26}; //} // namespace -class SupplicantStaNetworkHidlTest : public SupplicantHidlTestBase { +class SupplicantStaNetworkHidlTest : public SupplicantHidlTestBaseV1_2 { public: virtual void SetUp() override { - SupplicantHidlTestBase::SetUp(); + SupplicantHidlTestBaseV1_2::SetUp(); sta_network_ = createSupplicantStaNetwork_1_2(supplicant_); ASSERT_NE(sta_network_.get(), nullptr); } 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 69fc598593..b28c5a486d 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 @@ -34,4 +34,17 @@ getSupplicant_1_3(const std::string& supplicant_instance_name, bool isP2pOn); bool isFilsSupported( android::sp sta_iface); + +class SupplicantHidlTestBaseV1_3 : public SupplicantHidlTestBase { + public: + virtual void SetUp() override { + SupplicantHidlTestBase::SetUp(); + supplicant_ = getSupplicant_1_3(supplicant_instance_name_, isP2pOn_); + ASSERT_NE(supplicant_.get(), nullptr); + } + + protected: + android::sp + supplicant_; +}; #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 011a955983..432ca4a518 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 @@ -55,33 +55,14 @@ using ::android::hardware::wifi::supplicant::V1_3::WpaDriverCapabilitiesMask; #define TIMEOUT_PERIOD 60 class IfaceDppCallback; -class SupplicantStaIfaceHidlTest - : public ::testing::TestWithParam> { +class SupplicantStaIfaceHidlTest : public SupplicantHidlTestBaseV1_3 { public: virtual void SetUp() override { - 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"); - // Stop Framework - std::system("/system/bin/stop"); - - stopSupplicant(wifi_v1_0_instance_name_); - 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_)); + SupplicantHidlTestBaseV1_3::SetUp(); sta_iface_ = getSupplicantStaIface_1_3(supplicant_); ASSERT_NE(sta_iface_.get(), nullptr); } - virtual void TearDown() override { - stopSupplicant(wifi_v1_0_instance_name_); - // Start Framework - std::system("/system/bin/start"); - } - int64_t pmkCacheExpirationTimeInSec; std::vector serializedPmkCacheEntry; @@ -127,10 +108,6 @@ class SupplicantStaIfaceHidlTest 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; 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 5f60746845..03e51ffd77 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 @@ -43,43 +43,20 @@ constexpr OcspType kTestOcspType = OcspType::REQUEST_CERT_STATUS; constexpr OcspType kTestInvalidOcspType = (OcspType)-1; } // namespace -class SupplicantStaNetworkHidlTest - : public ::testing::TestWithParam> { +class SupplicantStaNetworkHidlTest : public SupplicantHidlTestBaseV1_3 { public: virtual void SetUp() override { - 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"); - // Stop Framework - std::system("/system/bin/stop"); - - stopSupplicant(wifi_v1_0_instance_name_); - 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_)); + SupplicantHidlTestBaseV1_3::SetUp(); sta_iface_ = getSupplicantStaIface_1_3(supplicant_); ASSERT_NE(nullptr, sta_iface_.get()); sta_network_ = createSupplicantStaNetwork_1_3(supplicant_); ASSERT_NE(sta_network_.get(), nullptr); } - virtual void TearDown() override { - stopSupplicant(wifi_v1_0_instance_name_); - // Start Framework - std::system("/system/bin/start"); - } - 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;