mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user