From 2a9b2979a2d6687b7e055da60d7c220007bcac4f Mon Sep 17 00:00:00 2001 From: Abby Xu <30247381+xabxx@users.noreply.github.com> Date: Mon, 20 May 2019 16:12:27 -0700 Subject: [PATCH] fix leak in test_get_actual_qos (#445) Signed-off-by: Abby Xu --- rcl/test/CMakeLists.txt | 2 +- rcl/test/rcl/test_get_actual_qos.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/rcl/test/CMakeLists.txt b/rcl/test/CMakeLists.txt index 9f5907b..9aa5883 100644 --- a/rcl/test/CMakeLists.txt +++ b/rcl/test/CMakeLists.txt @@ -124,7 +124,7 @@ function(test_target_function) ENV ${rmw_implementation_env_var} APPEND_LIBRARY_DIRS ${extra_lib_dirs} LIBRARIES ${PROJECT_NAME} - AMENT_DEPENDENCIES ${rmw_implementation} "test_msgs" + AMENT_DEPENDENCIES ${rmw_implementation} "test_msgs" "osrf_testing_tools_cpp" ) rcl_add_custom_gtest(test_init${target_suffix} diff --git a/rcl/test/rcl/test_get_actual_qos.cpp b/rcl/test/rcl/test_get_actual_qos.cpp index f31d94c..c8570f4 100644 --- a/rcl/test/rcl/test_get_actual_qos.cpp +++ b/rcl/test/rcl/test_get_actual_qos.cpp @@ -21,6 +21,7 @@ #include "rcl/rcl.h" #include "rcl/publisher.h" +#include "osrf_testing_tools_cpp/scope_exit.hpp" #include "rcutils/logging_macros.h" #include "rcutils/macros.h" @@ -82,6 +83,9 @@ public: *this->context_ptr = rcl_get_zero_initialized_context(); ret = rcl_init(0, nullptr, &init_options, this->context_ptr); 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; + }); this->node_ptr = new rcl_node_t; *this->node_ptr = rcl_get_zero_initialized_node(); const char * name = "test_get_actual_qos_node";