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

Commit 381685bd authored by Jeremy Wu's avatar Jeremy Wu Committed by Gerrit Code Review
Browse files

Merge "time_util_unittest: remove sleep test for monotonic_raw" into main

parents d4e3f1f4 c33ca3ed
Loading
Loading
Loading
Loading
+0 −22
Original line number Diff line number Diff line
@@ -124,28 +124,6 @@ TEST(TimeTest, test_time_get_os_boottime_us_increases_lower_bound) {
  ASSERT_TRUE((t2 - t1) < TEST_TIME_DELTA_UPPER_BOUND_MS * 1000);
}

//
// Test that the return value of
// bluetooth::common::time_get_os_monotonic_raw_us() is increasing.
//
TEST(TimeTest, test_time_get_os_monotonic_raw_us_increases_lower_bound) {
  static const uint64_t TEST_TIME_SLEEP_US = 100 * 1000;
  struct timespec delay = {};

  delay.tv_sec = TEST_TIME_SLEEP_US / (1000 * 1000);
  delay.tv_nsec = 1000 * (TEST_TIME_SLEEP_US % (1000 * 1000));

  // Take two timestamps with sleep in-between
  uint64_t t1 = bluetooth::common::time_get_os_monotonic_raw_us();
  int err = nanosleep(&delay, &delay);
  uint64_t t2 = bluetooth::common::time_get_os_monotonic_raw_us();

  ASSERT_EQ(err, 0);
  ASSERT_GT(t2, t1);
  ASSERT_TRUE((t2 - t1) >= TEST_TIME_SLEEP_US);
  ASSERT_TRUE((t2 - t1) < TEST_TIME_DELTA_UPPER_BOUND_MS * 1000);
}

//
// Test that the return value of bluetooth::common::time_gettimeofday_us() is
// not zero.