From e8e273d0738e0339a9b56e28390c093b9b1c9a5e Mon Sep 17 00:00:00 2001 From: Roger Strain Date: Wed, 20 Nov 2019 21:47:16 +0000 Subject: [PATCH] Adjusted spin_some test due to new behavior Previously would constantly trigger based on a 0ms delay timer; now only evaluates a single timer once per spin_some call. Test now adds multiple timers with a short delay to simulate performing work. Relies on behavior change from ros2/rclcpp#844, addressing ros2/rclcpp#471 Distribution Statement A; OPSEC #2893 Signed-off-by: Roger Strain --- test_rclcpp/test/test_executor.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/test_rclcpp/test/test_executor.cpp b/test_rclcpp/test/test_executor.cpp index c2e52c0e..d18de25a 100644 --- a/test_rclcpp/test/test_executor.cpp +++ b/test_rclcpp/test/test_executor.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "gtest/gtest.h" @@ -59,11 +60,16 @@ TEST(CLASSNAME(test_executor, RMW_IMPLEMENTATION), spin_some_max_duration) { if (!rclcpp::ok()) {rclcpp::init(0, nullptr);} rclcpp::executors::SingleThreadedExecutor executor; auto node = rclcpp::Node::make_shared("spin_some_max_duration"); - auto timer = node->create_wall_timer( - 0s, - []() { - // Do nothing - }); + auto lambda = []() { + std::this_thread::sleep_for(1ms); + }; + std::vector>> timers; + // creating 20 timers which will try to do 1 ms of work each + // only about 10ms worth of them should actually be performed + for (int i = 0; i < 20; i++) { + auto timer = node->create_wall_timer(0s, lambda); + timers.push_back(timer); + } executor.add_node(node); const auto max_duration = 10ms;