From e821380d69a549dc64900693942789d21aa4df5e Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Thu, 4 Oct 2018 08:55:32 -0700 Subject: Export of internal Abseil changes. -- e09635c907d471ab46e14fb8091988c92cb4e78e by Abseil Team : Fix syntax error in documentation '}' -> ')' PiperOrigin-RevId: 215744854 -- a9e2d036850748137355f4a07083f1052d5c3766 by Abseil Team : WrapUnique's comment about avoiding explicit template specification doesn't make clear what alternative there is when this hurts readability. Add a comment about the approved alternative. PiperOrigin-RevId: 215634917 -- 596b8ff41ff70b27bff3a2369038c0fe7d13ae85 by Greg Falcon : Allow for a small amount of slop in timeout tests, as not all OSs we support give us the perfect timing behavior we're testing for here. PiperOrigin-RevId: 215615172 GitOrigin-RevId: e09635c907d471ab46e14fb8091988c92cb4e78e Change-Id: I30721294bac86510a49bb7f405149fc74c532abb --- absl/synchronization/internal/per_thread_sem_test.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'absl/synchronization/internal/per_thread_sem_test.cc') diff --git a/absl/synchronization/internal/per_thread_sem_test.cc b/absl/synchronization/internal/per_thread_sem_test.cc index 2b52ea7..c29d840 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, -- cgit v1.2.3