summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Evan Brown <ezb@google.com>2023-03-27 23:45:25 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2023-03-27 23:46:38 -0700
commited7c1ee121668acab2d753ecc84ac036bbb8b43f (patch)
treeb037333e1dae3b366f637b957f8ec025b2ca65cd
parent6b4af2497bf3ec56b070fdd6d8c2cf5996c17dbe (diff)
Fix flakiness issues in timing tests.
PiperOrigin-RevId: 519939158 Change-Id: I9b049fa55167ed4064f3909887eec7bc52601677
-rw-r--r--absl/synchronization/internal/waiter_test.cc6
-rw-r--r--absl/synchronization/notification_test.cc2
2 files changed, 4 insertions, 4 deletions
diff --git a/absl/synchronization/internal/waiter_test.cc b/absl/synchronization/internal/waiter_test.cc
index 5de11d26..66b255de 100644
--- a/absl/synchronization/internal/waiter_test.cc
+++ b/absl/synchronization/internal/waiter_test.cc
@@ -48,7 +48,7 @@ class WaiterTest : public ::testing::Test {
TYPED_TEST_SUITE_P(WaiterTest);
-constexpr absl::Duration slop = absl::Milliseconds(2);
+constexpr absl::Duration slop = absl::Milliseconds(10);
TYPED_TEST_P(WaiterTest, WaitNoTimeout) {
absl::synchronization_internal::ThreadPool tp(1);
@@ -84,7 +84,7 @@ TYPED_TEST_P(WaiterTest, WaitDurationWoken) {
absl::synchronization_internal::KernelTimeout(absl::Seconds(10))));
absl::Duration waited = absl::Now() - start;
EXPECT_GE(waited, absl::Milliseconds(500) - slop);
- EXPECT_LT(waited, absl::Seconds(1));
+ EXPECT_LT(waited, absl::Seconds(2));
}
TYPED_TEST_P(WaiterTest, WaitTimeWoken) {
@@ -102,7 +102,7 @@ TYPED_TEST_P(WaiterTest, WaitTimeWoken) {
start + absl::Seconds(10))));
absl::Duration waited = absl::Now() - start;
EXPECT_GE(waited, absl::Milliseconds(500) - slop);
- EXPECT_LT(waited, absl::Seconds(1));
+ EXPECT_LT(waited, absl::Seconds(2));
}
TYPED_TEST_P(WaiterTest, WaitDurationReached) {
diff --git a/absl/synchronization/notification_test.cc b/absl/synchronization/notification_test.cc
index 100ea76f..49ce61a5 100644
--- a/absl/synchronization/notification_test.cc
+++ b/absl/synchronization/notification_test.cc
@@ -79,7 +79,7 @@ static void BasicTests(bool notify_before_waiting, Notification* notification) {
// Allow for a slight early return, to account for quality of implementation
// issues on various platforms.
- const absl::Duration slop = absl::Microseconds(200);
+ const absl::Duration slop = absl::Milliseconds(5);
EXPECT_LE(delay - slop, elapsed)
<< "WaitForNotificationWithTimeout returned " << delay - elapsed
<< " early (with " << slop << " slop), start time was " << start;