[DO NOT MERGE] Handle unavailable properties
Accommodate the case in which `set()` for an unavailable property is
called as the VHAL may return OK or NOT_AVAILABLE.
Also, it may be the case that certain properties aren't available
while testing and thus, setting a value and getting it right after
might not always work.
Bug: 290882809
Change-Id: I7b7b3f144c4fbd786bf673a86fcac110ec8f79b5
diff --git a/automotive/vehicle/2.0/vts/functional/Android.bp b/automotive/vehicle/2.0/vts/functional/Android.bp
index e64e942..04d895f 100644
--- a/automotive/vehicle/2.0/vts/functional/Android.bp
+++ b/automotive/vehicle/2.0/vts/functional/Android.bp
@@ -22,6 +22,7 @@
],
static_libs: [
"android.hardware.automotive.vehicle@2.0",
+ "libgmock",
],
test_suites: [
"vts",
diff --git a/automotive/vehicle/2.0/vts/functional/VtsHalAutomotiveVehicleV2_0TargetTest.cpp b/automotive/vehicle/2.0/vts/functional/VtsHalAutomotiveVehicleV2_0TargetTest.cpp
index 8adec84..2133012 100644
--- a/automotive/vehicle/2.0/vts/functional/VtsHalAutomotiveVehicleV2_0TargetTest.cpp
+++ b/automotive/vehicle/2.0/vts/functional/VtsHalAutomotiveVehicleV2_0TargetTest.cpp
@@ -20,6 +20,7 @@
#include <utils/Log.h>
#include <unordered_set>
+#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <hidl/GtestPrinter.h>
#include <hidl/ServiceManagement.h>
@@ -203,16 +204,30 @@
if (cfg.access == VehiclePropertyAccess::READ_WRITE && isBooleanGlobalProp(cfg.prop) &&
!hvacProps.count(cfg.prop)) {
invokeGet(cfg.prop, 0);
+
+ if (mActualStatusCode == StatusCode::NOT_AVAILABLE ||
+ mActualValue.status == VehiclePropertyStatus::UNAVAILABLE) {
+ ALOGD("Property %i isn't available", cfg.prop);
+ continue;
+ }
int setValue = mActualValue.value.int32Values[0] == 1 ? 0 : 1;
VehiclePropValue propToSet = mActualValue;
propToSet.value.int32Values[0] = setValue;
- ASSERT_EQ(StatusCode::OK, mVehicle->set(propToSet))
- << "Invalid status code for setting property: " << cfg.prop;
+
+ StatusCode setResult = mVehicle->set(propToSet);
+ ASSERT_THAT(setResult, testing::AnyOf(StatusCode::OK, StatusCode::NOT_AVAILABLE))
+ << "Invalid status code for setting unavailable property: " << cfg.prop;
+
// check set success
invokeGet(cfg.prop, 0);
ASSERT_EQ(StatusCode::OK, mActualStatusCode);
- ASSERT_EQ(setValue, mActualValue.value.int32Values[0])
- << "Failed to set value for property: " << cfg.prop;
+
+ // If the property isn't available, it doesn't make sense to check
+ // the returned value.
+ if (mActualValue.status == VehiclePropertyStatus::AVAILABLE) {
+ ASSERT_EQ(setValue, mActualValue.value.int32Values[0])
+ << "Failed to set value for property: " << cfg.prop;
+ }
}
}
}