about summary refs log tree commit diff
path: root/absl/synchronization/internal/per_thread_sem_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'absl/synchronization/internal/per_thread_sem_test.cc')
-rw-r--r--absl/synchronization/internal/per_thread_sem_test.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/absl/synchronization/internal/per_thread_sem_test.cc b/absl/synchronization/internal/per_thread_sem_test.cc
index 2b52ea76ab0e..c29d8403df43 100644
--- a/absl/synchronization/internal/per_thread_sem_test.cc
+++ b/absl/synchronization/internal/per_thread_sem_test.cc
@@ -153,12 +153,15 @@ TEST_F(PerThreadSemTest, WithTimeout) {
 
 TEST_F(PerThreadSemTest, Timeouts) {
   absl::Time timeout = absl::Now() + absl::Milliseconds(50);
+  // Allow for a slight early return, to account for quality of implementation
+  // issues on various platforms.
+  const absl::Duration slop = absl::Microseconds(200);
   EXPECT_FALSE(Wait(timeout));
-  EXPECT_LE(timeout, absl::Now());
+  EXPECT_LE(timeout, absl::Now() + slop);
 
   absl::Time negative_timeout = absl::UnixEpoch() - absl::Milliseconds(100);
   EXPECT_FALSE(Wait(negative_timeout));
-  EXPECT_LE(negative_timeout, absl::Now());  // trivially true :)
+  EXPECT_LE(negative_timeout, absl::Now() + slop);  // trivially true :)
 
   Post(GetOrCreateCurrentThreadIdentity());
   // The wait here has an expired timeout, but we have a wake to consume,