Skip to content

Commit 28b21cb

Browse files
committed
Update tests
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
1 parent e5aa77d commit 28b21cb

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

rcl/test/rcl/test_graph.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#include "rcl/error_handling.h"
3232
#include "rcl/graph.h"
33+
#include "rcl/logging.h"
3334
#include "rcl/rcl.h"
3435

3536
#include "rcutils/logging_macros.h"
@@ -66,6 +67,7 @@ class CLASSNAME (TestGraphFixture, RMW_IMPLEMENTATION) : public ::testing::Test
6667
void SetUp()
6768
{
6869
rcl_ret_t ret;
70+
rcl_allocator_t allocator = rcl_get_default_allocator();
6971
rcl_init_options_t init_options = rcl_get_zero_initialized_init_options();
7072
ret = rcl_init_options_init(&init_options, rcl_get_default_allocator());
7173
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
@@ -77,6 +79,10 @@ class CLASSNAME (TestGraphFixture, RMW_IMPLEMENTATION) : public ::testing::Test
7779
*this->old_context_ptr = rcl_get_zero_initialized_context();
7880
ret = rcl_init(0, nullptr, &init_options, this->old_context_ptr);
7981
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
82+
EXPECT_EQ(
83+
RCL_RET_OK,
84+
rcl_logging_configure(&this->old_context_ptr->global_arguments, &allocator)
85+
) << rcl_get_error_string().str;
8086
this->old_node_ptr = new rcl_node_t;
8187
*this->old_node_ptr = rcl_get_zero_initialized_node();
8288
const char * old_name = "old_node_name";
@@ -127,6 +133,7 @@ class CLASSNAME (TestGraphFixture, RMW_IMPLEMENTATION) : public ::testing::Test
127133
ret = rcl_context_fini(this->old_context_ptr);
128134
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
129135
delete this->old_context_ptr;
136+
EXPECT_EQ(RCL_RET_OK, rcl_logging_fini()) << rcl_get_error_string().str;
130137
}
131138
};
132139

rcl/test/rcl/test_logging_rosout.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include "osrf_testing_tools_cpp/scope_exit.hpp"
2121
#include "rcl/error_handling.h"
22+
#include "rcl/logging.h"
2223
#include "rcl/rcl.h"
2324
#include "rcl/subscription.h"
2425
#include "rcl_interfaces/msg/log.h"
@@ -70,8 +71,9 @@ class TEST_FIXTURE_P_RMW (TestLoggingRosoutFixture)
7071
{
7172
auto param = GetParam();
7273
rcl_ret_t ret;
74+
rcl_allocator_t allocator = rcl_get_default_allocator();
7375
rcl_init_options_t init_options = rcl_get_zero_initialized_init_options();
74-
ret = rcl_init_options_init(&init_options, rcl_get_default_allocator());
76+
ret = rcl_init_options_init(&init_options, allocator);
7577
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
7678
OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT(
7779
{
@@ -83,6 +85,11 @@ class TEST_FIXTURE_P_RMW (TestLoggingRosoutFixture)
8385
ret = rcl_init(param.argc, param.argv, &init_options, this->context_ptr);
8486
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
8587

88+
EXPECT_EQ(
89+
RCL_RET_OK,
90+
rcl_logging_configure(&this->context_ptr->global_arguments, &allocator)
91+
) << rcl_get_error_string().str;
92+
8693
// create node
8794
rcl_node_options_t node_options = rcl_node_get_default_options();
8895
if (!param.enable_node_option_rosout) {
@@ -120,6 +127,7 @@ class TEST_FIXTURE_P_RMW (TestLoggingRosoutFixture)
120127
ret = rcl_context_fini(this->context_ptr);
121128
delete this->context_ptr;
122129
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
130+
EXPECT_EQ(RCL_RET_OK, rcl_logging_fini()) << rcl_get_error_string().str;
123131
}
124132

125133
protected:

0 commit comments

Comments
 (0)