Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 25e47b17 authored by Peng Xu's avatar Peng Xu
Browse files

Fix flakiness of sensor VTS test cases

* Correction of testBatchingOperation wait logic.
* Enlarge buffer size for direct report testing.

Original cl links: ag/3053316 and ag/2759224

Bug: 64732324
Bug: 63529148
Bug: 67439052
Test: testBatchingOperation passes consistently
Test: direct report tests pass on 2016 pixel device

Merged-In: Id4e8075e249f3658f5683d53d6dc8403ee32bc4a
Merged-In: Ibe1d076c24dc2cfe61dfd19aa5055c9075aa9e14
Change-Id: Id4e8075e249f3658f5683d53d6dc8403ee32bc4a
parent ae96eee8
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -1180,16 +1180,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);
@@ -1202,7 +1203,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
@@ -1223,7 +1224,7 @@ TEST_F(SensorsHidlTest, MagnetometerBatchingOperation) {
void SensorsHidlTest::testDirectReportOperation(
    SensorType type, SharedMemType memType, RateLevel rate, const SensorEventsChecker &checker) {
  constexpr size_t kEventSize = static_cast<size_t>(SensorsEventFormatOffset::TOTAL_LENGTH);
  constexpr size_t kNEvent = 500;
  constexpr size_t kNEvent = 4096;
  constexpr size_t kMemSize = kEventSize * kNEvent;

  constexpr float kNormalNominal = 50;