Allow sensors bleed all remaining events before test starts
After framework shutdown, there may be stall events when sensors vts
target test starts. These events make vts flaky. This CL allows the
test to remove all those events to avoid test results being affected.
Test can run repeatedly > 20 times without failure with this patch.
Test: vts-tradefed run commandAndExit vts
--module SensorsHidlTargetTest
Bug: 33618936
Change-Id: I027e88b2b7425136543b15cf39afb203c315d8bf
diff --git a/sensors/1.0/vts/functional/sensors_hidl_hal_test.cpp b/sensors/1.0/vts/functional/sensors_hidl_hal_test.cpp
index 8e85b23..17c439e 100644
--- a/sensors/1.0/vts/functional/sensors_hidl_hal_test.cpp
+++ b/sensors/1.0/vts/functional/sensors_hidl_hal_test.cpp
@@ -84,6 +84,10 @@
collectionEnabled = false;
startPollingThread();
+
+ // In case framework just stopped for test and there is sensor events in the pipe,
+ // wait some time for those events to be cleared to avoid them messing up the test.
+ std::this_thread::sleep_for(std::chrono::seconds(3));
}
void SensorsHidlEnvironment::TearDown() {