Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
  • Loading branch information
ivanpauno committed Feb 26, 2020
1 parent 1ee5325 commit f9cd0e2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 7 additions & 0 deletions rcl/test/rcl/test_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include "rcl/error_handling.h"
#include "rcl/graph.h"
#include "rcl/logging.h"
#include "rcl/rcl.h"

#include "rcutils/logging_macros.h"
Expand Down Expand Up @@ -66,6 +67,7 @@ class CLASSNAME (TestGraphFixture, RMW_IMPLEMENTATION) : public ::testing::Test
void SetUp()
{
rcl_ret_t ret;
rcl_allocator_t allocator = rcl_get_default_allocator();
rcl_init_options_t init_options = rcl_get_zero_initialized_init_options();
ret = rcl_init_options_init(&init_options, rcl_get_default_allocator());
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
Expand All @@ -77,6 +79,10 @@ class CLASSNAME (TestGraphFixture, RMW_IMPLEMENTATION) : public ::testing::Test
*this->old_context_ptr = rcl_get_zero_initialized_context();
ret = rcl_init(0, nullptr, &init_options, this->old_context_ptr);
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
EXPECT_EQ(
RCL_RET_OK,
rcl_logging_configure(&this->old_context_ptr->global_arguments, &allocator)
) << rcl_get_error_string().str;
this->old_node_ptr = new rcl_node_t;
*this->old_node_ptr = rcl_get_zero_initialized_node();
const char * old_name = "old_node_name";
Expand Down Expand Up @@ -127,6 +133,7 @@ class CLASSNAME (TestGraphFixture, RMW_IMPLEMENTATION) : public ::testing::Test
ret = rcl_context_fini(this->old_context_ptr);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
delete this->old_context_ptr;
EXPECT_EQ(RCL_RET_OK, rcl_logging_fini()) << rcl_get_error_string().str;
}
};

Expand Down
10 changes: 9 additions & 1 deletion rcl/test/rcl/test_logging_rosout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "osrf_testing_tools_cpp/scope_exit.hpp"
#include "rcl/error_handling.h"
#include "rcl/logging.h"
#include "rcl/rcl.h"
#include "rcl/subscription.h"
#include "rcl_interfaces/msg/log.h"
Expand Down Expand Up @@ -70,8 +71,9 @@ class TEST_FIXTURE_P_RMW (TestLoggingRosoutFixture)
{
auto param = GetParam();
rcl_ret_t ret;
rcl_allocator_t allocator = rcl_get_default_allocator();
rcl_init_options_t init_options = rcl_get_zero_initialized_init_options();
ret = rcl_init_options_init(&init_options, rcl_get_default_allocator());
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(
{
Expand All @@ -83,6 +85,11 @@ class TEST_FIXTURE_P_RMW (TestLoggingRosoutFixture)
ret = rcl_init(param.argc, param.argv, &init_options, this->context_ptr);
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;

EXPECT_EQ(
RCL_RET_OK,
rcl_logging_configure(&this->context_ptr->global_arguments, &allocator)
) << rcl_get_error_string().str;

// create node
rcl_node_options_t node_options = rcl_node_get_default_options();
if (!param.enable_node_option_rosout) {
Expand Down Expand Up @@ -120,6 +127,7 @@ class TEST_FIXTURE_P_RMW (TestLoggingRosoutFixture)
ret = rcl_context_fini(this->context_ptr);
delete this->context_ptr;
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
EXPECT_EQ(RCL_RET_OK, rcl_logging_fini()) << rcl_get_error_string().str;
}

protected:
Expand Down

0 comments on commit f9cd0e2

Please sign in to comment.