From f08c1a2bdcb738a1b4263dd92e4f61ba708bf164 Mon Sep 17 00:00:00 2001 From: ahcorde Date: Tue, 3 Nov 2020 10:51:57 +0100 Subject: [PATCH] Adapted logging test to Foxy Signed-off-by: ahcorde --- rcl/test/rcl/test_logging.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/rcl/test/rcl/test_logging.cpp b/rcl/test/rcl/test_logging.cpp index 5ffb95e..e51ba6d 100644 --- a/rcl/test/rcl/test_logging.cpp +++ b/rcl/test/rcl/test_logging.cpp @@ -24,12 +24,14 @@ #include "rcl/rcl.h" #include "rcl/subscription.h" #include "rcl_interfaces/msg/log.h" -#include "rcl_logging_interface/rcl_logging_interface.h" +#include "rcl/logging_external_interface.h" #include "rcutils/logging_macros.h" #include "../mocking_utils/patch.hpp" +#define RCL_LOGGING_RET_ERROR 2 + // Define dummy comparison operators for rcutils_allocator_t type // to use with the Mimick mocking library MOCKING_UTILS_BOOL_OPERATOR_RETURNS_FALSE(rcutils_allocator_t, ==) @@ -173,7 +175,7 @@ TEST(TestLogging, test_failing_external_logging_configure) { TEST(TestLogging, test_failing_logger_level_configure) { const char * argv[] = { "test_logging", RCL_ROS_ARGS_FLAG, - RCL_LOG_LEVEL_FLAG, ROS_PACKAGE_NAME ":=info"}; + RCL_LOG_LEVEL_FLAG, "info"}; const int argc = sizeof(argv) / sizeof(argv[0]); rcl_allocator_t default_allocator = rcl_get_default_allocator(); rcl_arguments_t global_arguments = rcl_get_zero_initialized_arguments(); @@ -184,15 +186,17 @@ TEST(TestLogging, test_failing_logger_level_configure) { EXPECT_EQ(RCL_RET_OK, rcl_arguments_fini(&global_arguments)) << rcl_get_error_string().str; }); - { - auto mock = mocking_utils::patch_to_fail( - "lib:rcl", rcutils_logging_set_logger_level, "failed to allocate", RCUTILS_RET_ERROR); - EXPECT_EQ(RCL_RET_ERROR, rcl_logging_configure(&global_arguments, &default_allocator)); - EXPECT_TRUE(rcl_error_is_set()); - rcl_reset_error(); - - EXPECT_EQ(RCL_RET_OK, rcl_logging_fini()) << rcl_get_error_string().str; - } + // TODO(anyone): This part of the API is not backported to Foxy. Uncomment this block if + // someone backports this API. + // { + // auto mock = mocking_utils::patch_to_fail( + // "lib:rcl", rcutils_logging_set_logger_level, "failed to allocate", RCUTILS_RET_ERROR); + // EXPECT_EQ(RCL_RET_ERROR, rcl_logging_configure(&global_arguments, &default_allocator)); + // EXPECT_TRUE(rcl_error_is_set()); + // rcl_reset_error(); + // + // EXPECT_EQ(RCL_RET_OK, rcl_logging_fini()) << rcl_get_error_string().str; + // } } TEST(TestLogging, test_failing_external_logging) { @@ -200,7 +204,7 @@ TEST(TestLogging, test_failing_external_logging) { "test_logging", RCL_ROS_ARGS_FLAG, "--disable-" RCL_LOG_STDOUT_FLAG_SUFFIX, "--enable-" RCL_LOG_EXT_LIB_FLAG_SUFFIX, - RCL_LOG_LEVEL_FLAG, ROS_PACKAGE_NAME ":=DEBUG" + RCL_LOG_LEVEL_FLAG, "debug" }; const int argc = sizeof(argv) / sizeof(argv[0]); rcl_allocator_t default_allocator = rcl_get_default_allocator();