Adapted logging test to Foxy
Signed-off-by: ahcorde <ahcorde@gmail.com>
This commit is contained in:
parent
d8a691f82c
commit
f08c1a2bdc
1 changed files with 16 additions and 12 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue