diff options
Diffstat (limited to 'absl/synchronization/notification_test.cc')
-rw-r--r-- | absl/synchronization/notification_test.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/absl/synchronization/notification_test.cc b/absl/synchronization/notification_test.cc index 9b3b6a5a9e84..d8708d551a15 100644 --- a/absl/synchronization/notification_test.cc +++ b/absl/synchronization/notification_test.cc @@ -71,10 +71,13 @@ static void BasicTests(bool notify_before_waiting, Notification* notification) { notification->WaitForNotificationWithTimeout(absl::Milliseconds(0))); EXPECT_FALSE(notification->WaitForNotificationWithDeadline(absl::Now())); + const absl::Duration delay = 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); absl::Time start = absl::Now(); - EXPECT_FALSE( - notification->WaitForNotificationWithTimeout(absl::Milliseconds(50))); - EXPECT_LE(start + absl::Milliseconds(50), absl::Now()); + EXPECT_FALSE(notification->WaitForNotificationWithTimeout(delay)); + EXPECT_LE(start + delay, absl::Now() + slop); ThreadSafeCounter ready_counter; ThreadSafeCounter done_counter; |