From d78310fe5a82f2e0e6e16509ef8079c8d7e4674e Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 30 Jan 2019 20:33:55 -0800 Subject: Export of internal Abseil changes. -- 2c12ae8d6cbb8cbeb3ff446393578dd0d6d0cf8c by Andy Getzendanner : Fix printf POSIX reference link to point at printf(3) (the C API) instead of printf(1) (the shell utility). PiperOrigin-RevId: 231719473 -- a36b3a0e539b5ca2033bb25438aa325ac84a285a by CJ Johnson : Fixes "correct" but poor semantics `allocator_and_tag_` initializations in InlinedVector to the proper version that gets a reference/const reference to allocator_type PiperOrigin-RevId: 231691608 -- de5eca5c7146a1e4692a201804817d98354d20ec by CJ Johnson : Removes pathologically deleted move constructor and assignment operator from benchmark test type PiperOrigin-RevId: 231680297 -- b2b52859e5f0e14a25047e528c8163b12ea9ca32 by Matt Armstrong : Assert on elapsed time, not absolute time. This is a cosmetic change that aims to make test failures clearer. Human readers no longer need to do as much mental math to deduce the magnitude of the failure. It does not change the semantics of the test assertions. PiperOrigin-RevId: 231644805 GitOrigin-RevId: 2c12ae8d6cbb8cbeb3ff446393578dd0d6d0cf8c Change-Id: Ic121a26a7a6bb7441da6a8c1d7797bee4f705fdc --- absl/synchronization/internal/per_thread_sem_test.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'absl/synchronization/internal') diff --git a/absl/synchronization/internal/per_thread_sem_test.cc b/absl/synchronization/internal/per_thread_sem_test.cc index c29d8403..81cbe957 100644 --- a/absl/synchronization/internal/per_thread_sem_test.cc +++ b/absl/synchronization/internal/per_thread_sem_test.cc @@ -152,12 +152,16 @@ TEST_F(PerThreadSemTest, WithTimeout) { } TEST_F(PerThreadSemTest, Timeouts) { - absl::Time timeout = absl::Now() + absl::Milliseconds(50); + const absl::Duration delay = absl::Milliseconds(50); + const absl::Time start = absl::Now(); + EXPECT_FALSE(Wait(start + delay)); + const absl::Duration elapsed = absl::Now() - start; // 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() + slop); + EXPECT_LE(delay - slop, elapsed) + << "Wait returned " << delay - elapsed + << " early (with " << slop << " slop), start time was " << start; absl::Time negative_timeout = absl::UnixEpoch() - absl::Milliseconds(100); EXPECT_FALSE(Wait(negative_timeout)); -- cgit v1.2.3