Skip to content

Commit bf89dc0

Browse files
author
Michael Carroll
authored
Further expand test tolerance to address flakiness. (#501)
* Further expand test tolerance to address flakiness. * Remove newline.
1 parent 62c8c5b commit bf89dc0

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

rclcpp/test/executors/test_multi_threaded_executor.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,11 @@ TEST_F(TestMultiThreadedExecutor, timer_over_take) {
7171
std::atomic_int timer_count {0};
7272

7373
auto timer_callback = [&timer_count, &executor, &system_clock, &last_mutex, &last]() {
74+
// While this tolerance is a little wide, if the bug occurs, the next step will
75+
// happen almost instantly. The purpose of this test is not to measure the jitter
76+
// in timers, just assert that a reasonable amount of time has passed.
7477
const double PERIOD = 0.1f;
75-
const double TOLERANCE = 0.01f;
78+
const double TOLERANCE = 0.025f;
7679

7780
rclcpp::Time now = system_clock.now();
7881
timer_count++;
@@ -88,8 +91,8 @@ TEST_F(TestMultiThreadedExecutor, timer_over_take) {
8891

8992
if (diff < PERIOD - TOLERANCE || diff > PERIOD + TOLERANCE) {
9093
executor.cancel();
91-
ASSERT_TRUE(diff > PERIOD - TOLERANCE);
92-
ASSERT_TRUE(diff < PERIOD + TOLERANCE);
94+
ASSERT_GT(diff, PERIOD - TOLERANCE);
95+
ASSERT_LT(diff, PERIOD + TOLERANCE);
9396
}
9497
}
9598
};

0 commit comments

Comments
 (0)