Skip to content

Commit 806dd64

Browse files
Fix lifecycle warning in test (#262)
* Call rclcpp::shutdown() * Shut down the node
1 parent f0d4400 commit 806dd64

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

test/pid_parameters_tests.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,9 @@ TEST(PidParametersTest, MultiplePidInstances)
392392

393393
int main(int argc, char ** argv)
394394
{
395-
testing::InitGoogleTest(&argc, argv);
396-
rclcpp::init(0, nullptr);
397-
398-
return RUN_ALL_TESTS();
395+
::testing::InitGoogleTest(&argc, argv);
396+
rclcpp::init(argc, argv);
397+
int result = RUN_ALL_TESTS();
398+
rclcpp::shutdown();
399+
return result;
399400
}

test/pid_publisher_tests.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ TEST(PidPublisherTest, PublishTestLifecycle)
7575
auto state_pub_lifecycle_ =
7676
std::dynamic_pointer_cast<rclcpp_lifecycle::LifecyclePublisher<control_msgs::msg::PidState>>(
7777
pid_ros.getPidStatePublisher());
78-
// state_pub_lifecycle_->on_activate();
7978

8079
pid_ros.initPid(1.0, 1.0, 1.0, 5.0, -5.0, false);
8180

@@ -97,13 +96,16 @@ TEST(PidPublisherTest, PublishTestLifecycle)
9796
rclcpp::spin_some(node->get_node_base_interface());
9897
std::this_thread::sleep_for(DELAY);
9998
}
100-
10199
ASSERT_TRUE(callback_called);
100+
101+
node->shutdown(); // won't be called in destructor
102102
}
103103

104104
int main(int argc, char ** argv)
105105
{
106-
testing::InitGoogleTest(&argc, argv);
107-
rclcpp::init(0, nullptr);
108-
return RUN_ALL_TESTS();
106+
::testing::InitGoogleTest(&argc, argv);
107+
rclcpp::init(argc, argv);
108+
int result = RUN_ALL_TESTS();
109+
rclcpp::shutdown();
110+
return result;
109111
}

0 commit comments

Comments
 (0)