[Tests][Threading] Allow 1‰ error in wait times.

Ideally this should not be an issue and we should always return
strictly *after* the time we waited for.  In practice it can
happen, for mathematics related reasons, that the time isn't
entirely precise, so allow a one thou error.

rdar://163661576
This commit is contained in:
Alastair Houghton
2025-10-31 09:55:39 +00:00
parent 46ce02bb5b
commit 7206dfadbf

View File

@@ -67,7 +67,7 @@ TEST(ConditionVariableTest, Timeout) {
ASSERT_FALSE(ret);
});
ASSERT_GE(duration.count(), 0.01);
ASSERT_GE(duration.count(), 0.01 * 0.999);
duration = measureDuration([&] {
ConditionVariable::ScopedLock lock(cond);
@@ -75,7 +75,7 @@ TEST(ConditionVariableTest, Timeout) {
ASSERT_FALSE(ret);
});
ASSERT_GE(duration.count(), 0.1);
ASSERT_GE(duration.count(), 0.1 * 0.999);
duration = measureDuration([&] {
ConditionVariable::ScopedLock lock(cond);
@@ -83,7 +83,7 @@ TEST(ConditionVariableTest, Timeout) {
ASSERT_FALSE(ret);
});
ASSERT_GE(duration.count(), 1.0);
ASSERT_GE(duration.count(), 1.0 * 0.999);
auto deadline = std::chrono::system_clock::now() + 0.5s;
@@ -93,7 +93,7 @@ TEST(ConditionVariableTest, Timeout) {
ASSERT_FALSE(ret);
});
ASSERT_GE(duration.count(), 0.5);
ASSERT_GE(duration.count(), 0.5 * 0.999);
}
// Check that signal() wakes exactly one waiter