Skip to content

Commit 5eaf3dc

Browse files
Janosch MachowinskiJanosch Machowinski
authored andcommitted
test: Fix TestExecutorNotifyWaitable wait test
The test was adding the same guard condition twice. This not allowed. Signed-off-by: Janosch Machowinski <J.Machowinski@cellumation.com>
1 parent 46bb085 commit 5eaf3dc

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

rclcpp/test/rclcpp/executors/test_executor_notify_waitable.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ TEST_F(TestExecutorNotifyWaitable, wait) {
7676
std::make_shared<rclcpp::executors::ExecutorNotifyWaitable>(on_execute_callback);
7777

7878
auto node = std::make_shared<rclcpp::Node>("my_node", "/ns");
79-
auto notify_guard_condition =
80-
node->get_node_base_interface()->get_shared_notify_guard_condition();
79+
auto notify_guard_condition = std::make_shared<rclcpp::GuardCondition>();
8180
EXPECT_NO_THROW(waitable->add_guard_condition(notify_guard_condition));
8281

8382
auto default_cbg = node->get_node_base_interface()->get_default_callback_group();
@@ -86,12 +85,15 @@ TEST_F(TestExecutorNotifyWaitable, wait) {
8685
auto waitables = node->get_node_waitables_interface();
8786
waitables->add_waitable(std::static_pointer_cast<rclcpp::Waitable>(waitable), default_cbg);
8887

88+
// notify the guard condition, this should trigger the on_execute_callback
89+
notify_guard_condition->trigger();
90+
8991
rclcpp::executors::SingleThreadedExecutor executor;
9092
executor.add_node(node);
9193
executor.spin_all(std::chrono::seconds(1));
9294
EXPECT_EQ(1u, on_execute_calls);
9395

94-
// on_execute_callback doesn't change if the topology doesn't change
96+
// no further trigger, therefore no further callback
9597
executor.spin_all(std::chrono::seconds(1));
9698
EXPECT_EQ(1u, on_execute_calls);
9799
}

0 commit comments

Comments
 (0)