From ec5d5b0bfc7fa46246cb183639f0068c5b72d418 Mon Sep 17 00:00:00 2001 From: Yu Shan Date: Mon, 9 Oct 2023 14:43:36 -0700 Subject: [PATCH] Allow CDD required properties to be absent in VTS. Allow CDD required properties not to be supported in VHAL VTS since this is already covered in CTS. We also need to consider special cases where one VHAL instance does not support all required properties. Test: atest VtsHalAutomotiveVehicle_TargetTest Bug: 301577794 (Cherry-picked from commit b84f6f3c68fcd7f613146146821130eb354865c1) Change-Id: I93020e7e024760601bc5a8edf9997cc356a568c6 --- .../VtsHalAutomotiveVehicle_TargetTest.cpp | 45 ++++++++++++++----- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/automotive/vehicle/vts/src/VtsHalAutomotiveVehicle_TargetTest.cpp b/automotive/vehicle/vts/src/VtsHalAutomotiveVehicle_TargetTest.cpp index 6e6d05cd61..bc9a527c40 100644 --- a/automotive/vehicle/vts/src/VtsHalAutomotiveVehicle_TargetTest.cpp +++ b/automotive/vehicle/vts/src/VtsHalAutomotiveVehicle_TargetTest.cpp @@ -115,6 +115,9 @@ class VtsVehicleCallback final : public ISubscriptionCallback { }; class VtsHalAutomotiveVehicleTargetTest : public testing::TestWithParam { + protected: + void checkIsSupported(int32_t propertyId); + public: void verifyProperty(VehicleProperty propId, VehiclePropertyAccess access, VehiclePropertyChangeMode changeMode, VehiclePropertyGroup group, @@ -155,7 +158,7 @@ TEST_P(VtsHalAutomotiveVehicleTargetTest, useHidlBackend) { } } -// Test getAllPropConfig() returns at least 4 property configs. +// Test getAllPropConfigs() returns at least 1 property configs. TEST_P(VtsHalAutomotiveVehicleTargetTest, getAllPropConfigs) { ALOGD("VtsHalAutomotiveVehicleTargetTest::getAllPropConfigs"); @@ -163,25 +166,29 @@ TEST_P(VtsHalAutomotiveVehicleTargetTest, getAllPropConfigs) { ASSERT_TRUE(result.ok()) << "Failed to get all property configs, error: " << result.error().message(); - ASSERT_GE(result.value().size(), 4u) << StringPrintf( - "Expect to get at least 4 property configs, got %zu", result.value().size()); + ASSERT_GE(result.value().size(), 1u) << StringPrintf( + "Expect to get at least 1 property config, got %zu", result.value().size()); } -// Test getPropConfigs() can query all properties listed in CDD. -TEST_P(VtsHalAutomotiveVehicleTargetTest, getRequiredPropConfigs) { +// Test getPropConfigs() can query properties returned by getAllPropConfigs. +TEST_P(VtsHalAutomotiveVehicleTargetTest, getPropConfigsWithValidProps) { ALOGD("VtsHalAutomotiveVehicleTargetTest::getRequiredPropConfigs"); - // Check the properties listed in CDD - std::vector properties = { - toInt(VehicleProperty::GEAR_SELECTION), toInt(VehicleProperty::NIGHT_MODE), - toInt(VehicleProperty::PARKING_BRAKE_ON), toInt(VehicleProperty::PERF_VEHICLE_SPEED)}; + std::vector properties; + auto result = mVhalClient->getAllPropConfigs(); - auto result = mVhalClient->getPropConfigs(properties); + ASSERT_TRUE(result.ok()) << "Failed to get all property configs, error: " + << result.error().message(); + for (const auto& cfgPtr : result.value()) { + properties.push_back(cfgPtr->getPropId()); + } + + result = mVhalClient->getPropConfigs(properties); ASSERT_TRUE(result.ok()) << "Failed to get required property config, error: " << result.error().message(); - ASSERT_EQ(result.value().size(), 4u) - << StringPrintf("Expect to get exactly 4 configs, got %zu", result.value().size()); + ASSERT_EQ(result.value().size(), properties.size()) << StringPrintf( + "Expect to get exactly %zu configs, got %zu", properties.size(), result.value().size()); } // Test getPropConfig() with an invalid propertyId returns an error code. @@ -200,6 +207,7 @@ TEST_P(VtsHalAutomotiveVehicleTargetTest, get) { ALOGD("VtsHalAutomotiveVehicleTargetTest::get"); int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED); + checkIsSupported(propId); auto result = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(propId)); ASSERT_TRUE(result.ok()) << StringPrintf("Failed to get value for property: %" PRId32 @@ -285,6 +293,8 @@ TEST_P(VtsHalAutomotiveVehicleTargetTest, setNotWritableProp) { ALOGD("VtsHalAutomotiveVehicleTargetTest::setNotWritableProp"); int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED); + checkIsSupported(propId); + auto getValueResult = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(propId)); ASSERT_TRUE(getValueResult.ok()) << StringPrintf("Failed to get value for property: %" PRId32 ", error: %s", propId, @@ -325,6 +335,7 @@ TEST_P(VtsHalAutomotiveVehicleTargetTest, subscribeAndUnsubscribe) { ALOGD("VtsHalAutomotiveVehicleTargetTest::subscribeAndUnsubscribe"); int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED); + checkIsSupported(propId); auto propConfigsResult = mVhalClient->getPropConfigs({propId}); @@ -414,6 +425,7 @@ TEST_P(VtsHalAutomotiveVehicleTargetTest, testGetValuesTimestampAIDL) { } int32_t propId = toInt(VehicleProperty::PARKING_BRAKE_ON); + checkIsSupported(propId); auto prop = mVhalClient->createHalPropValue(propId); auto result = mVhalClient->getValueSync(*prop); @@ -871,6 +883,15 @@ TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyClusterHeartbeatConfig) { VehicleArea::GLOBAL, VehiclePropertyType::MIXED); } +void VtsHalAutomotiveVehicleTargetTest::checkIsSupported(int32_t propertyId) { + auto result = mVhalClient->getPropConfigs({propertyId}); + ASSERT_TRUE(result.ok()) << "Failed to get required property config, error: " + << result.error().message(); + if (result.value().size() == 0) { + GTEST_SKIP() << "Property: " << propertyId << " is not supported, skip the test"; + } +} + std::vector getDescriptors() { std::vector descriptors; for (std::string name : getAidlHalInstanceNames(IVehicle::descriptor)) {