Skip to content

Commit

Permalink
Make test multi threaded executor more reliable (#1105)
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
  • Loading branch information
ivanpauno authored May 14, 2020
1 parent 9f04391 commit 0dd14ba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 0 additions & 1 deletion rclcpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,6 @@ if(BUILD_TESTING)
ament_target_dependencies(test_multi_threaded_executor
"rcl")
target_link_libraries(test_multi_threaded_executor ${PROJECT_NAME})
ament_add_test_label(test_multi_threaded_executor xfail)
endif()

ament_add_gtest(test_guard_condition test/test_guard_condition.cpp
Expand Down
9 changes: 5 additions & 4 deletions rclcpp/test/executors/test_multi_threaded_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ class TestMultiThreadedExecutor : public ::testing::Test
}
};

constexpr std::chrono::milliseconds PERIOD_MS = 1000ms;
constexpr double PERIOD = PERIOD_MS.count() / 1000.0;
constexpr double TOLERANCE = PERIOD / 4.0;

/*
Test that timers are not taken multiple times when using reentrant callback groups.
*/
Expand Down Expand Up @@ -70,9 +74,6 @@ TEST_F(TestMultiThreadedExecutor, timer_over_take) {
// While this tolerance is a little wide, if the bug occurs, the next step will
// happen almost instantly. The purpose of this test is not to measure the jitter
// in timers, just assert that a reasonable amount of time has passed.
const double PERIOD = 0.1f;
const double TOLERANCE = 0.025f;

rclcpp::Time now = system_clock.now();
timer_count++;

Expand All @@ -92,7 +93,7 @@ TEST_F(TestMultiThreadedExecutor, timer_over_take) {
}
};

auto timer = node->create_wall_timer(100ms, timer_callback, cbg);
auto timer = node->create_wall_timer(PERIOD_MS, timer_callback, cbg);
executor.add_node(node);
executor.spin();
}

0 comments on commit 0dd14ba

Please sign in to comment.