diff options
-rw-r--r-- | absl/synchronization/internal/waiter_test.cc | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/absl/synchronization/internal/waiter_test.cc b/absl/synchronization/internal/waiter_test.cc index 9a933940..992db29b 100644 --- a/absl/synchronization/internal/waiter_test.cc +++ b/absl/synchronization/internal/waiter_test.cc @@ -72,7 +72,7 @@ class WaiterTest : public ::testing::Test { TYPED_TEST_SUITE_P(WaiterTest); -constexpr absl::Duration slop = absl::Milliseconds(10); +absl::Duration WithTolerance(absl::Duration d) { return d * 0.95; } TYPED_TEST_P(WaiterTest, WaitNoTimeout) { absl::synchronization_internal::ThreadPool tp(1); @@ -90,7 +90,7 @@ TYPED_TEST_P(WaiterTest, WaitNoTimeout) { EXPECT_TRUE( waiter.Wait(absl::synchronization_internal::KernelTimeout::Never())); absl::Duration waited = absl::Now() - start; - EXPECT_GE(waited, absl::Seconds(2) - slop); + EXPECT_GE(waited, WithTolerance(absl::Seconds(2))); } TYPED_TEST_P(WaiterTest, WaitDurationWoken) { @@ -107,7 +107,7 @@ TYPED_TEST_P(WaiterTest, WaitDurationWoken) { EXPECT_TRUE(waiter.Wait( absl::synchronization_internal::KernelTimeout(absl::Seconds(10)))); absl::Duration waited = absl::Now() - start; - EXPECT_GE(waited, absl::Milliseconds(500) - slop); + EXPECT_GE(waited, WithTolerance(absl::Milliseconds(500))); EXPECT_LT(waited, absl::Seconds(2)); } @@ -125,7 +125,7 @@ TYPED_TEST_P(WaiterTest, WaitTimeWoken) { EXPECT_TRUE(waiter.Wait(absl::synchronization_internal::KernelTimeout( start + absl::Seconds(10)))); absl::Duration waited = absl::Now() - start; - EXPECT_GE(waited, absl::Milliseconds(500) - slop); + EXPECT_GE(waited, WithTolerance(absl::Milliseconds(500))); EXPECT_LT(waited, absl::Seconds(2)); } @@ -135,7 +135,7 @@ TYPED_TEST_P(WaiterTest, WaitDurationReached) { EXPECT_FALSE(waiter.Wait( absl::synchronization_internal::KernelTimeout(absl::Milliseconds(500)))); absl::Duration waited = absl::Now() - start; - EXPECT_GE(waited, absl::Milliseconds(500) - slop); + EXPECT_GE(waited, WithTolerance(absl::Milliseconds(500))); EXPECT_LT(waited, absl::Seconds(1)); } @@ -145,7 +145,7 @@ TYPED_TEST_P(WaiterTest, WaitTimeReached) { EXPECT_FALSE(waiter.Wait(absl::synchronization_internal::KernelTimeout( start + absl::Milliseconds(500)))); absl::Duration waited = absl::Now() - start; - EXPECT_GE(waited, absl::Milliseconds(500) - slop); + EXPECT_GE(waited, WithTolerance(absl::Milliseconds(500))); EXPECT_LT(waited, absl::Seconds(1)); } |