Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
267c898
Add bad arguments tests for coverage (#698)
Blast545 Jul 3, 2020
ff1ab5f
Add coverage tests for `rcl` (#703)
Blast545 Jul 7, 2020
83b7aa0
Move rcl_remap_copy to public header (#709)
Blast545 Jul 16, 2020
cfdb3c3
Make public ini/fini rosout publisher (#704)
Blast545 Jul 20, 2020
5f0d665
Add remap needed null check (#711)
Blast545 Jul 20, 2020
39a3929
Make sure to call rcl_arguments_fini at the end of the test.
clalancette Jul 21, 2020
da0a6b6
Reformat rmw_impl_id_check to call a testable function (#725)
Blast545 Jul 27, 2020
8d20848
Add mock tests, publisher 95% coverage (#732)
Blast545 Aug 10, 2020
25ee6ca
Complete subscription API test coverage (#734)
hidmic Aug 12, 2020
d03ebf6
Fix bug error handling get_param_files (#743)
Blast545 Aug 13, 2020
a19e816
Fix allocation arguments copy (#748)
Blast545 Aug 18, 2020
0c7ebba
Adding tests to arguments.c (#752)
Blast545 Aug 20, 2020
d0c9b56
Add fault injection macros to rcl functions (#727)
brawner Aug 25, 2020
a622f44
Add coverage tests wait module (#769)
Blast545 Sep 1, 2020
4952237
Bump rcl arguments' API test coverage. (#777)
hidmic Sep 1, 2020
e35436a
Fix rcl arguments' API memory leaks and bugs. (#778)
hidmic Sep 1, 2020
1417130
Implement a generic way to change logging levels (#664)
Jul 8, 2020
37a0b83
Fix wait allocation cleanup (#770)
Blast545 Aug 31, 2020
ba78b26
Add missing calls to rcl_convert_rmw_ret_to_rcl_ret (#738)
Blast545 Aug 11, 2020
a6c5ac2
Add function rcl_event_is_valid (#720)
Blast545 Jul 22, 2020
881324b
Add test for subscription message lost event (#705)
Blast545 Jul 22, 2020
0ec13a2
Add message lost event (#673)
ivanpauno Jun 17, 2020
257ddfc
Add extra check for invalid event implementation (#726)
Blast545 Jul 27, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions rcl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ set(${PROJECT_NAME}_sources
src/rcl/localhost.c
src/rcl/logging_rosout.c
src/rcl/logging.c
src/rcl/log_level.c
src/rcl/node.c
src/rcl/node_options.c
src/rcl/publisher.c
Expand Down Expand Up @@ -83,6 +84,10 @@ ament_target_dependencies(${PROJECT_NAME}
target_compile_definitions(${PROJECT_NAME} PRIVATE "RCL_BUILDING_DLL")
rcl_set_symbol_visibility_hidden(${PROJECT_NAME} LANGUAGE "C")

if(BUILD_TESTING AND NOT RCUTILS_DISABLE_FAULT_INJECTION)
target_compile_definitions(${PROJECT_NAME} PUBLIC RCUTILS_ENABLE_FAULT_INJECTION)
endif()

install(
TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}
ARCHIVE DESTINATION lib
Expand Down
33 changes: 30 additions & 3 deletions rcl/include/rcl/arguments.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define RCL__ARGUMENTS_H_

#include "rcl/allocator.h"
#include "rcl/log_level.h"
#include "rcl/macros.h"
#include "rcl/types.h"
#include "rcl/visibility_control.h"
Expand Down Expand Up @@ -77,9 +78,9 @@ rcl_get_zero_initialized_arguments(void);
* Parameter override rule parsing is supported via `-p/--param` flags e.g. `--param name:=value`
* or `-p name:=value`.
*
* The default log level will be parsed as `--log-level level`, where `level` is a name
* representing one of the log levels in the `RCUTILS_LOG_SEVERITY` enum, e.g. `info`, `debug`,
* `warn`, not case sensitive.
* The default log level will be parsed as `--log-level level` and logger levels will be parsed as
* multiple `--log-level name:=level`, where `level` is a name representing one of the log levels
* in the `RCUTILS_LOG_SEVERITY` enum, e.g. `info`, `debug`, `warn`, not case sensitive.
* If multiple of these rules are found, the last one parsed will be used.
*
* If an argument does not appear to be a valid ROS argument e.g. a `-r/--remap` flag followed by
Expand Down Expand Up @@ -343,6 +344,32 @@ rcl_remove_ros_arguments(
int * nonros_argc,
const char ** nonros_argv[]);

/// Return log levels parsed from the command line.
/**
* Log levels are parsed directly from command line arguments.
*
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | Yes
*
* \param[in] arguments An arguments structure that has been parsed.
* \param[out] log_levels Log levels as parsed from command line arguments.
* The output must be finished by the caller if the function successes.
* \return `RCL_RET_OK` if everything goes correctly, or
* \return `RCL_RET_INVALID_ARGUMENT` if any function arguments are invalid, or
* \return `RCL_RET_BAD_ALLOC` if allocating memory failed.
*/
RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_arguments_get_log_levels(
const rcl_arguments_t * arguments,
rcl_log_levels_t * log_levels);

/// Copy one arguments structure into another.
/**
* <hr>
Expand Down
23 changes: 23 additions & 0 deletions rcl/include/rcl/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ typedef enum rcl_subscription_event_type_t
RCL_SUBSCRIPTION_REQUESTED_DEADLINE_MISSED,
RCL_SUBSCRIPTION_LIVELINESS_CHANGED,
RCL_SUBSCRIPTION_REQUESTED_INCOMPATIBLE_QOS,
RCL_SUBSCRIPTION_MESSAGE_LOST,
} rcl_subscription_event_type_t;

/// rmw struct.
Expand Down Expand Up @@ -170,6 +171,28 @@ RCL_WARN_UNUSED
rmw_event_t *
rcl_event_get_rmw_handle(const rcl_event_t * event);

/// Check that the event is valid.
/**
* The bool returned is `false` if `event` is invalid.
* The bool returned is `true` otherwise.
* In the case where `false` is to be returned, an error message is set.
* This function cannot fail.
*
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | No
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | Yes
*
* \param[in] event pointer to the rcl event
* \return `true` if `event` is valid, otherwise `false`
*/
RCL_PUBLIC
bool
rcl_event_is_valid(const rcl_event_t * event);

#ifdef __cplusplus
}
#endif
Expand Down
191 changes: 191 additions & 0 deletions rcl/include/rcl/log_level.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
// Copyright 2020 Open Source Robotics Foundation, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef RCL__LOG_LEVEL_H_
#define RCL__LOG_LEVEL_H_

#include "rcl/allocator.h"
#include "rcl/macros.h"
#include "rcl/types.h"
#include "rcl/visibility_control.h"

#ifdef __cplusplus
extern "C"
{
#endif

/// typedef for RCUTILS_LOG_SEVERITY;
typedef enum RCUTILS_LOG_SEVERITY rcl_log_severity_t;

/// A logger item to specify a name and a log level.
typedef struct rcl_logger_setting_t
{
/// Name for the logger.
const char * name;
/// Minimum log level severity of the logger.
rcl_log_severity_t level;
} rcl_logger_setting_t;

/// Hold default logger level and other logger setting.
typedef struct rcl_log_levels_t
{
/// Minimum default logger level severity.
rcl_log_severity_t default_logger_level;
/// Array of logger setting.
struct rcl_logger_setting_t * logger_settings;
/// Number of logger settings.
size_t num_logger_settings;
/// Capacity of logger settings.
size_t capacity_logger_settings;
/// Allocator used to allocate objects in this struct.
rcl_allocator_t allocator;
} rcl_log_levels_t;

/// Return a rcl_log_levels_t struct with members initialized to zero value.
/**
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | No
* Thread-Safe | Yes
* Uses Atomics | No
* Lock-Free | Yes
*
* \return a rcl_log_levels_t struct with members initialized to zero value.
*/
RCL_PUBLIC
RCL_WARN_UNUSED
rcl_log_levels_t
rcl_get_zero_initialized_log_levels();

/// Initialize a log levels structure.
/**
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | Yes
*
* \param[in] log_levels The structure to be initialized.
* \param[in] allocator Memory allocator to be used and assigned into log_levels.
* \param[in] logger_count Number of logger settings to be allocated.
* This reserves memory for logger_settings, but doesn't initialize it.
* \return `RCL_RET_OK` if the structure was initialized successfully, or
* \return `RCL_RET_INVALID_ARGUMENT` if log_levels is NULL, or
* log_levels contains initialized memory, or
* allocator is invalid, or
* \return `RCL_RET_BAD_ALLOC` if allocating memory failed.
*/
RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_log_levels_init(
rcl_log_levels_t * log_levels, const rcl_allocator_t * allocator, size_t logger_count);

/// Copy one log levels structure into another.
/**
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | Yes
*
* \param[in] src The structure to be copied.
* Its allocator is used to copy memory into the new structure.
* \param[out] dst A log levels structure to be copied into.
* \return `RCL_RET_OK` if the structure was copied successfully, or
* \return `RCL_RET_INVALID_ARGUMENT` if src is NULL, or
* if src allocator is invalid, or
* if dst is NULL, or
* if dst contains already allocated memory, or
* \return `RCL_RET_BAD_ALLOC` if allocating memory failed.
*/
RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_log_levels_copy(const rcl_log_levels_t * src, rcl_log_levels_t * dst);

/// Reclaim resources held inside rcl_log_levels_t structure.
/**
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | No
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | Yes
*
* \param[in] log_levels The structure which its resources have to be deallocated.
* \return `RCL_RET_OK` if the memory was successfully freed, or
* \return `RCL_RET_INVALID_ARGUMENT` if log_levels is NULL, or
* if ist allocator is invalid and the structure contains initialized memory.
*/
RCL_PUBLIC
rcl_ret_t
rcl_log_levels_fini(rcl_log_levels_t * log_levels);

/// Shrink log levels structure.
/**
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | Yes
*
* \param[in] log_levels The structure to be shrunk.
* \return `RCL_RET_OK` if the memory was successfully shrunk, or
* \return `RCL_RET_INVALID_ARGUMENT` if log_levels is NULL or if its allocator is invalid, or
* \return `RCL_RET_BAD_ALLOC` if reallocating memory failed.
*/
RCL_PUBLIC
rcl_ret_t
rcl_log_levels_shrink_to_size(rcl_log_levels_t * log_levels);

/// Add logger setting with a name and a level.
/**
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | Yes
*
* \param[in] log_levels The structure where to set the logger log level.
* \param[in] logger_name Name for the logger, a copy of it will be stored in the structure.
* \param[in] log_level Minimum log level severity to be set for logger_name.
* \return `RCL_RET_OK` if add logger setting successfully, or
* \return `RCL_RET_BAD_ALLOC` if allocating memory failed, or
* \return `RCL_RET_INVALID_ARGUMENT` if log_levels is NULL, or
* if log_levels was not initialized, or
* if log_levels allocator is invalid, or
* if logger_name is NULL, or
* \return `RCL_RET_ERROR` if the log_levels structure is already full.
*/
RCL_PUBLIC
rcl_ret_t
rcl_log_levels_add_logger_setting(
rcl_log_levels_t * log_levels, const char * logger_name, rcl_log_severity_t log_level);

#ifdef __cplusplus
}
#endif

#endif // RCL__LOG_LEVEL_H_
4 changes: 2 additions & 2 deletions rcl/include/rcl/logging_rosout.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ rcl_logging_rosout_fini();
* \return `RCL_RET_BAD_ALLOC` if allocating memory failed, or
* \return `RCL_RET_ERROR` if an unspecified error occurs.
*/
RCL_LOCAL
RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_logging_rosout_init_publisher_for_node(
Expand All @@ -124,7 +124,7 @@ rcl_logging_rosout_init_publisher_for_node(
* \return `RCL_RET_BAD_ALLOC` if allocating memory failed, or
* \return `RCL_RET_ERROR` if an unspecified error occurs.
*/
RCL_LOCAL
RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_logging_rosout_fini_publisher_for_node(
Expand Down
25 changes: 25 additions & 0 deletions rcl/include/rcl/remap.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,31 @@ rcl_remap_node_namespace(
rcl_allocator_t allocator,
char ** output_namespace);

/// Copy one remap structure into another.
/**
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | Yes
*
* \param[in] rule The structure to be copied.
* Its allocator is used to copy memory into the new structure.
* \param[out] rule_out A zero-initialized rcl_remap_t structure to be copied into.
* \return `RCL_RET_OK` if the structure was copied successfully, or
* \return `RCL_RET_INVALID_ARGUMENT` if any function arguments are invalid, or
* \return `RCL_RET_BAD_ALLOC` if allocating memory failed, or
* \return `RCL_RET_ERROR` if an unspecified error occurs.
*/
RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_remap_copy(
const rcl_remap_t * rule,
rcl_remap_t * rule_out);

/// Reclaim resources held inside rcl_remap_t structure.
/**
* <hr>
Expand Down
35 changes: 35 additions & 0 deletions rcl/include/rcl/rmw_implementation_identifier_check.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2020 Open Source Robotics Foundation, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef RCL__RMW_IMPLEMENTATION_IDENTIFIER_CHECK_H_
#define RCL__RMW_IMPLEMENTATION_IDENTIFIER_CHECK_H_

#ifdef __cplusplus
extern "C"
{
#endif

#include "rcl/visibility_control.h"

#define RMW_IMPLEMENTATION_ENV_VAR_NAME "RMW_IMPLEMENTATION"
#define RCL_ASSERT_RMW_ID_MATCHES_ENV_VAR_NAME "RCL_ASSERT_RMW_ID_MATCHES"

RCL_PUBLIC
rcl_ret_t rcl_rmw_implementation_identifier_check(void);

#ifdef __cplusplus
}
#endif

#endif // RCL__RMW_IMPLEMENTATION_IDENTIFIER_CHECK_H_
Loading