From 0a43f6dc11f916ac2f2b2ff3c6348c2c14f973d8 Mon Sep 17 00:00:00 2001 From: lesl Date: Tue, 8 Sep 2020 00:06:34 +0800 Subject: [PATCH] wifi: Call terminate in VTS teardown When OEM register different hostapd instance without update the StopHostapd. It will cause VTS clean fail because hostapd process name is the new one. Call terminate to request clean HAL state. Bug: 161682236 Bug: 167636313 Test: atest -c VtsHalWifiHostapdV1_2TargetTest Test: atest -c VtsHalWifiHostapdV1_1TargetTest Test: atest -c VtsHalWifiHostapdV1_0TargetTest Change-Id: If56e5b5351abd31865150bdf97d27674dbbc4257 --- .../1.0/vts/functional/hostapd_hidl_call_util.h | 14 ++++++++++++++ .../1.0/vts/functional/hostapd_hidl_test.cpp | 5 ++++- .../1.1/vts/functional/hostapd_hidl_test.cpp | 5 ++++- .../1.2/vts/functional/hostapd_hidl_test.cpp | 5 ++++- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_call_util.h b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_call_util.h index ec7ebeeb46..b4b0ea604f 100644 --- a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_call_util.h +++ b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_call_util.h @@ -95,6 +95,14 @@ typename functionArgSaver::StorageT invokeMethod( EXPECT_TRUE(res.isOk()); return result_buffer.saved_values; } + +// Invokes |void method| on |object| without arguments. +template +void invokeVoidMethodWithoutArguments(MethodT method, ObjectT object) { + const auto& res = ((*object).*method)(); + EXPECT_TRUE(res.isOk()); +} + } // namespace detail } // namespace @@ -123,3 +131,9 @@ typename functionArgSaver::StorageT invokeMethod( std::remove_reference::type::method##_cb>( \ &std::remove_reference::type::method, \ strong_pointer, ##__VA_ARGS__)) + +// Invokes |void method| on |strong_pointer| without arguments. +#define HIDL_INVOKE_VOID_WITHOUT_ARGUMENTS(strong_pointer, method) \ + (detail::invokeVoidMethodWithoutArguments( \ + &std::remove_reference::type::method, \ + strong_pointer)) diff --git a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test.cpp b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test.cpp index 82c257bf84..1b4eea6d04 100644 --- a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test.cpp +++ b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test.cpp @@ -55,7 +55,10 @@ class HostapdHidlTest ASSERT_NE(hostapd_.get(), nullptr); } - virtual void TearDown() override { stopHostapd(wifi_instance_name_); } + virtual void TearDown() override { + HIDL_INVOKE_VOID_WITHOUT_ARGUMENTS(hostapd_, terminate); + stopHostapd(wifi_instance_name_); + } protected: std::string getPrimaryWlanIfaceName() { diff --git a/wifi/hostapd/1.1/vts/functional/hostapd_hidl_test.cpp b/wifi/hostapd/1.1/vts/functional/hostapd_hidl_test.cpp index 2ff96bdfc1..d823685dab 100644 --- a/wifi/hostapd/1.1/vts/functional/hostapd_hidl_test.cpp +++ b/wifi/hostapd/1.1/vts/functional/hostapd_hidl_test.cpp @@ -58,7 +58,10 @@ class HostapdHidlTest ASSERT_NE(hostapd_.get(), nullptr); } - virtual void TearDown() override { stopHostapd(wifi_instance_name_); } + virtual void TearDown() override { + HIDL_INVOKE_VOID_WITHOUT_ARGUMENTS(hostapd_, terminate); + stopHostapd(wifi_instance_name_); + } protected: std::string getPrimaryWlanIfaceName() { diff --git a/wifi/hostapd/1.2/vts/functional/hostapd_hidl_test.cpp b/wifi/hostapd/1.2/vts/functional/hostapd_hidl_test.cpp index 62e3c16072..99784a469e 100644 --- a/wifi/hostapd/1.2/vts/functional/hostapd_hidl_test.cpp +++ b/wifi/hostapd/1.2/vts/functional/hostapd_hidl_test.cpp @@ -72,7 +72,10 @@ class HostapdHidlTest "wifi_softap_wpa3_sae_supported"); } - virtual void TearDown() override { stopHostapd(wifi_instance_name_); } + virtual void TearDown() override { + HIDL_INVOKE_VOID_WITHOUT_ARGUMENTS(hostapd_, terminate); + stopHostapd(wifi_instance_name_); + } protected: bool isWpa3SaeSupport_ = false;