From 2aef4b48f0be3db69e5cee9006bdf3cecc662e91 Mon Sep 17 00:00:00 2001 From: Peng Xu Date: Fri, 18 Aug 2017 17:50:57 -0700 Subject: [PATCH] Sensor VTS testBatchingOperation flakiness fix This CL is cherry-picked from internal branch oc-dev. Bug: 64732324 Bug: 63529148 Test: testBatchingOperation passes consistently Merged-In: Id4e8075e249f3658f5683d53d6dc8403ee32bc4a Change-Id: Id4e8075e249f3658f5683d53d6dc8403ee32bc4a --- .../functional/VtsHalSensorsV1_0TargetTest.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp b/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp index 19265c2916..d3323e1f26 100644 --- a/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp +++ b/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp @@ -1221,16 +1221,17 @@ void SensorsHidlTest::testBatchingOperation(SensorType type) { usleep(batchingPeriodInNs / 1000 * 8 / 10); SensorsHidlEnvironment::Instance()->setCollection(true); - // 0.8 + 0.3 times the batching period - // plus some time for the event to deliver - events = collectEvents( - batchingPeriodInNs / 1000 * 3 / 10, - minFifoCount, true /*clearBeforeStart*/, false /*change collection*/); + // clean existing collections + collectEvents(0 /*timeLimitUs*/, 0/*nEventLimit*/, + true /*clearBeforeStart*/, false /*change collection*/); + // 0.8 + 0.2 times the batching period + usleep(batchingPeriodInNs / 1000 * 8 / 10); ASSERT_EQ(flush(handle), Result::OK); + // plus some time for the event to deliver events = collectEvents(allowedBatchDeliverTimeNs / 1000, - minFifoCount, true /*clearBeforeStart*/, false /*change collection*/); + minFifoCount, false /*clearBeforeStart*/, false /*change collection*/); SensorsHidlEnvironment::Instance()->setCollection(false); ASSERT_EQ(activate(handle, 0), Result::OK); @@ -1243,7 +1244,7 @@ void SensorsHidlTest::testBatchingOperation(SensorType type) { } // at least reach 90% of advertised capacity - ASSERT_GT(nEvent, (size_t)(batchingPeriodInNs / minSamplingPeriodInNs * 9 / 10)); + ASSERT_GT(nEvent, (size_t)(minFifoCount * 9 / 10)); } // Test if sensor hal can do accelerometer batching properly