summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Hefner <ehefner@motorola.com>2020-10-11 10:56:15 -0500
committerEric Hefner <ehefner@motorola.com>2020-10-19 13:34:16 -0500
commit812d9b50f6e16d6b6c63260a133c4b854f0c8fca (patch)
treec6558fadc4fd1333d402149537e819373bf43f72
parent9ac41106d8cd552b9f86781f772eae3c106294f7 (diff)
downloadplatform_hardware_interfaces-812d9b50f6e16d6b6c63260a133c4b854f0c8fca.tar.gz
platform_hardware_interfaces-812d9b50f6e16d6b6c63260a133c4b854f0c8fca.tar.bz2
platform_hardware_interfaces-812d9b50f6e16d6b6c63260a133c4b854f0c8fca.zip
Modify VTS NoStaleEvents test to omit on-change sensors
- add utility function to select non one-shot, non on-change and non special-report sensors - apply to NoStaleEvents test case - remove unnecessary checks related to on-change sensors b/170315229 Change-Id: I349fe8be35fd1fa6f9ff1e0844b09815006a18b8
-rw-r--r--sensors/common/vts/2_X/VtsHalSensorsV2_XTargetTest.h28
1 files changed, 18 insertions, 10 deletions
diff --git a/sensors/common/vts/2_X/VtsHalSensorsV2_XTargetTest.h b/sensors/common/vts/2_X/VtsHalSensorsV2_XTargetTest.h
index 2e5aca49de..e674ddb886 100644
--- a/sensors/common/vts/2_X/VtsHalSensorsV2_XTargetTest.h
+++ b/sensors/common/vts/2_X/VtsHalSensorsV2_XTargetTest.h
@@ -226,6 +226,7 @@ class SensorsHidlTest : public SensorsHidlTestBaseV2_X {
void activateAllSensors(bool enable);
std::vector<SensorInfoType> getNonOneShotSensors();
std::vector<SensorInfoType> getNonOneShotAndNonSpecialSensors();
+ std::vector<SensorInfoType> getNonOneShotAndNonOnChangeAndNonSpecialSensors();
std::vector<SensorInfoType> getOneShotSensors();
std::vector<SensorInfoType> getInjectEventSensors();
int32_t getInvalidSensorHandle();
@@ -326,6 +327,19 @@ std::vector<SensorInfoType> SensorsHidlTest::getNonOneShotAndNonSpecialSensors()
return sensors;
}
+std::vector<SensorInfoType> SensorsHidlTest::getNonOneShotAndNonOnChangeAndNonSpecialSensors() {
+ std::vector<SensorInfoType> sensors;
+ for (const SensorInfoType& info : getSensorsList()) {
+ SensorFlagBits reportMode = extractReportMode(info.flags);
+ if (reportMode != SensorFlagBits::ONE_SHOT_MODE &&
+ reportMode != SensorFlagBits::ON_CHANGE_MODE &&
+ reportMode != SensorFlagBits::SPECIAL_REPORTING_MODE) {
+ sensors.push_back(info);
+ }
+ }
+ return sensors;
+}
+
std::vector<SensorInfoType> SensorsHidlTest::getOneShotSensors() {
std::vector<SensorInfoType> sensors;
for (const SensorInfoType& info : getSensorsList()) {
@@ -726,8 +740,8 @@ TEST_P(SensorsHidlTest, NoStaleEvents) {
EventCallback callback;
getEnvironment()->registerCallback(&callback);
- // This test is not valid for one-shot or special-report-mode sensors
- const std::vector<SensorInfoType> sensors = getNonOneShotAndNonSpecialSensors();
+ // This test is not valid for one-shot, on-change or special-report-mode sensors
+ const std::vector<SensorInfoType> sensors = getNonOneShotAndNonOnChangeAndNonSpecialSensors();
milliseconds maxMinDelay(0);
for (const SensorInfoType& sensor : sensors) {
milliseconds minDelay = duration_cast<milliseconds>(microseconds(sensor.minDelay));
@@ -750,10 +764,7 @@ TEST_P(SensorsHidlTest, NoStaleEvents) {
<< " handle=0x" << std::hex << std::setw(8) << std::setfill('0')
<< sensor.sensorHandle << std::dec << " type=" << static_cast<int>(sensor.type)
<< " name=" << sensor.name);
- // Some on-change sensors may not report an event without stimulus
- if (extractReportMode(sensor.flags) != SensorFlagBits::ON_CHANGE_MODE) {
- ASSERT_GE(callback.getEvents(sensor.sensorHandle).size(), 1);
- }
+
if (callback.getEvents(sensor.sensorHandle).size() >= 1) {
lastEventTimestampMap[sensor.sensorHandle] =
callback.getEvents(sensor.sensorHandle).back().timestamp;
@@ -779,10 +790,7 @@ TEST_P(SensorsHidlTest, NoStaleEvents) {
if (lastEventTimestampMap.find(sensor.sensorHandle) == lastEventTimestampMap.end()) {
continue;
}
- // Skip on-change sensors that do not consistently report an initial event
- if (callback.getEvents(sensor.sensorHandle).size() < 1) {
- continue;
- }
+
// Ensure that the first event received is not stale by ensuring that its timestamp is
// sufficiently different from the previous event
const EventType newEvent = callback.getEvents(sensor.sensorHandle).front();