From 2c3b63f04f5972b4c52929ef63ffa1a5a4672e65 Mon Sep 17 00:00:00 2001 From: jimmyshiu Date: Tue, 19 Mar 2024 08:56:42 +0000 Subject: [PATCH] VTSHalPowerTarget: Add condition check for FMQAidl teardown While FMQAidl Setup() was skipped, some uninitialized objects would be used in FMQAidl Teardown() which caused the test failed. Add some condition check to prevent from using uninitialized objects. Test: atest VTSHalPowerTarget Bug: 328330332 Change-Id: I83081cbef66da1d74d87e191f266cb16fb559b85 (cherry picked from commit d3753ec91db5416f939e633e5020f50ced84c0e9) --- power/aidl/vts/VtsHalPowerTargetTest.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/power/aidl/vts/VtsHalPowerTargetTest.cpp b/power/aidl/vts/VtsHalPowerTargetTest.cpp index 53fcef1a41..db777c5e78 100644 --- a/power/aidl/vts/VtsHalPowerTargetTest.cpp +++ b/power/aidl/vts/VtsHalPowerTargetTest.cpp @@ -175,8 +175,12 @@ class FMQAidl : public PowerAidl { ASSERT_NE(mEventFlag, nullptr); } virtual void TearDown() { - mSession->close(); - ASSERT_TRUE(power->closeSessionChannel(getpid(), getuid()).isOk()); + if (mSession) { + mSession->close(); + if (mChannel->isValid()) { + ASSERT_TRUE(power->closeSessionChannel(getpid(), getuid()).isOk()); + } + } } protected: