From 9beec7e3afe22dff0fe8c2501a924af1d83c62ff Mon Sep 17 00:00:00 2001 From: Jack Wu Date: Thu, 2 Feb 2023 11:27:58 +0800 Subject: [PATCH] health: fix vts test failed in aidl v2 Add a check before executing the test to determine whether the health HAL is indeed the V2 version. Bug: 266665472 Test: vts test Change-Id: I43c7d0139037701f0ef2e8f3925272470684a50e Signed-off-by: Jack Wu --- .../vts/functional/VtsHalHealthTargetTest.cpp | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/health/aidl/vts/functional/VtsHalHealthTargetTest.cpp b/health/aidl/vts/functional/VtsHalHealthTargetTest.cpp index dd0bd81a8a..6506ea2359 100644 --- a/health/aidl/vts/functional/VtsHalHealthTargetTest.cpp +++ b/health/aidl/vts/functional/VtsHalHealthTargetTest.cpp @@ -229,8 +229,14 @@ TEST_P(HealthAidl, getChargeStatus) { * Tests the values returned by getChargingPolicy() from interface IHealth. */ TEST_P(HealthAidl, getChargingPolicy) { + int32_t version = 0; + auto status = health->getInterfaceVersion(&version); + ASSERT_TRUE(status.isOk()) << status; + if (version < 2) { + GTEST_SKIP() << "Support in health hal v2 for EU Ecodesign"; + } BatteryChargingPolicy value; - auto status = health->getChargingPolicy(&value); + status = health->getChargingPolicy(&value); ASSERT_THAT(status, AnyOf(IsOk(), ExceptionIs(EX_UNSUPPORTED_OPERATION))); if (!status.isOk()) return; ASSERT_THAT(value, IsValidEnum()); @@ -241,10 +247,17 @@ TEST_P(HealthAidl, getChargingPolicy) { * value by getChargingPolicy() from interface IHealth. */ TEST_P(HealthAidl, setChargingPolicy) { + int32_t version = 0; + auto status = health->getInterfaceVersion(&version); + ASSERT_TRUE(status.isOk()) << status; + if (version < 2) { + GTEST_SKIP() << "Support in health hal v2 for EU Ecodesign"; + } + BatteryChargingPolicy value; /* set ChargingPolicy*/ - auto status = health->setChargingPolicy(static_cast(2)); // LONG_LIFE + status = health->setChargingPolicy(static_cast(2)); // LONG_LIFE ASSERT_THAT(status, AnyOf(IsOk(), ExceptionIs(EX_UNSUPPORTED_OPERATION))); if (!status.isOk()) return; @@ -273,8 +286,15 @@ MATCHER(IsValidHealthData, "") { * Tests the values returned by getBatteryHealthData() from interface IHealth. */ TEST_P(HealthAidl, getBatteryHealthData) { + int32_t version = 0; + auto status = health->getInterfaceVersion(&version); + ASSERT_TRUE(status.isOk()) << status; + if (version < 2) { + GTEST_SKIP() << "Support in health hal v2 for EU Ecodesign"; + } + BatteryHealthData value; - auto status = health->getBatteryHealthData(&value); + status = health->getBatteryHealthData(&value); ASSERT_THAT(status, AnyOf(IsOk(), ExceptionIs(EX_UNSUPPORTED_OPERATION))); if (!status.isOk()) return; ASSERT_THAT(value, IsValidHealthData());