diff --git a/rcl_action/CMakeLists.txt b/rcl_action/CMakeLists.txt index 620c9aac8..b32b8ed28 100644 --- a/rcl_action/CMakeLists.txt +++ b/rcl_action/CMakeLists.txt @@ -170,6 +170,7 @@ if(BUILD_TESTING) ${PROJECT_NAME} ) ament_target_dependencies(test_action_server + "osrf_testing_tools_cpp" "rcl" "test_msgs" ) diff --git a/rcl_action/test/rcl_action/test_action_client.cpp b/rcl_action/test/rcl_action/test_action_client.cpp index 9686e253f..4de1fd894 100644 --- a/rcl_action/test/rcl_action/test_action_client.cpp +++ b/rcl_action/test/rcl_action/test_action_client.cpp @@ -52,6 +52,8 @@ class TestActionClientBaseFixture : public ::testing::Test EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; ret = rcl_shutdown(&this->context); EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; + ret = rcl_context_fini(&this->context); + EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; } rcl_context_t context; diff --git a/rcl_action/test/rcl_action/test_action_communication.cpp b/rcl_action/test/rcl_action/test_action_communication.cpp index 07ab08a63..25947c76f 100644 --- a/rcl_action/test/rcl_action/test_action_communication.cpp +++ b/rcl_action/test/rcl_action/test_action_communication.cpp @@ -13,6 +13,8 @@ // limitations under the License. #include +#include "osrf_testing_tools_cpp/scope_exit.hpp" + #include "rcl_action/action_client.h" #include "rcl_action/action_server.h" #include "rcl_action/wait.h" @@ -41,6 +43,9 @@ class CLASSNAME (TestActionCommunication, RMW_IMPLEMENTATION) : public ::testing rcl_init_options_t init_options = rcl_get_zero_initialized_init_options(); ret = rcl_init_options_init(&init_options, allocator); ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; + OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({ + EXPECT_EQ(RCL_RET_OK, rcl_init_options_fini(&init_options)) << rcl_get_error_string().str; + }); context = rcl_get_zero_initialized_context(); ret = rcl_init(0, nullptr, &init_options, &context); ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; @@ -119,6 +124,8 @@ class CLASSNAME (TestActionCommunication, RMW_IMPLEMENTATION) : public ::testing EXPECT_EQ(ret, RCL_RET_OK) << rcl_get_error_string().str; ret = rcl_shutdown(&context); EXPECT_EQ(ret, RCL_RET_OK) << rcl_get_error_string().str; + ret = rcl_context_fini(&this->context); + EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; } void init_test_uuid0(uint8_t * uuid) diff --git a/rcl_action/test/rcl_action/test_action_interaction.cpp b/rcl_action/test/rcl_action/test_action_interaction.cpp index 49dc35178..7b3813229 100644 --- a/rcl_action/test/rcl_action/test_action_interaction.cpp +++ b/rcl_action/test/rcl_action/test_action_interaction.cpp @@ -13,6 +13,8 @@ // limitations under the License. #include +#include "osrf_testing_tools_cpp/scope_exit.hpp" + #include "rcl_action/action_client.h" #include "rcl_action/action_server.h" #include "rcl_action/wait.h" @@ -53,6 +55,9 @@ class CLASSNAME (TestActionClientServerInteraction, RMW_IMPLEMENTATION) : public rcl_init_options_t init_options = rcl_get_zero_initialized_init_options(); ret = rcl_init_options_init(&init_options, allocator); ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; + OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({ + EXPECT_EQ(RCL_RET_OK, rcl_init_options_fini(&init_options)) << rcl_get_error_string().str; + }); context = rcl_get_zero_initialized_context(); ret = rcl_init(0, nullptr, &init_options, &context); ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; @@ -141,6 +146,8 @@ class CLASSNAME (TestActionClientServerInteraction, RMW_IMPLEMENTATION) : public EXPECT_EQ(ret, RCL_RET_OK) << rcl_get_error_string().str; ret = rcl_shutdown(&context); EXPECT_EQ(ret, RCL_RET_OK) << rcl_get_error_string().str; + ret = rcl_context_fini(&this->context); + EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; } void init_test_uuid0(uint8_t * uuid) diff --git a/rcl_action/test/rcl_action/test_action_server.cpp b/rcl_action/test/rcl_action/test_action_server.cpp index aa6fe75e5..67dc438ba 100644 --- a/rcl_action/test/rcl_action/test_action_server.cpp +++ b/rcl_action/test/rcl_action/test_action_server.cpp @@ -19,6 +19,8 @@ #include "action_msgs/srv/cancel_goal.h" +#include "osrf_testing_tools_cpp/scope_exit.hpp" + #include "rcl_action/action_server.h" #include "rcl/error_handling.h" @@ -137,12 +139,21 @@ TEST(TestActionServerInitFini, test_action_server_init_fini) ret = rcl_clock_fini(&clock); EXPECT_EQ(ret, RCL_RET_OK) << rcl_get_error_string().str; + // Finalize init_options + ret = rcl_init_options_fini(&init_options); + EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; + // Finalize node ret = rcl_node_fini(&node); EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; + // Shutdown node ret = rcl_shutdown(&context); EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; + + // Finalize context + ret = rcl_context_fini(&context); + EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; } class TestActionServer : public ::testing::Test @@ -155,6 +166,9 @@ class TestActionServer : public ::testing::Test rcl_init_options_t init_options = rcl_get_zero_initialized_init_options(); ret = rcl_init_options_init(&init_options, allocator); ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; + OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({ + EXPECT_EQ(RCL_RET_OK, rcl_init_options_fini(&init_options)) << rcl_get_error_string().str; + }); context = rcl_get_zero_initialized_context(); ret = rcl_init(0, nullptr, &init_options, &context); ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; @@ -185,6 +199,8 @@ class TestActionServer : public ::testing::Test EXPECT_EQ(ret, RCL_RET_OK) << rcl_get_error_string().str; ret = rcl_shutdown(&context); EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; + ret = rcl_context_fini(&this->context); + EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; } void init_test_uuid0(uint8_t * uuid)