Increase rcl_lifecycle test coverage and add more safety checks (#649)
* Increase test coverage and add more safety checks Signed-off-by: Stephen Brawner <brawner@gmail.com> * More coverage Signed-off-by: Stephen Brawner <brawner@gmail.com> * Concatenating error messages Signed-off-by: Stephen Brawner <stephenbrawner@verbsurgical.com> * PR Fixup Signed-off-by: Stephen Brawner <stephenbrawner@verbsurgical.com> * Forgot a Signed-off-by: Stephen Brawner <stephenbrawner@verbsurgical.com> * PR Fixup Signed-off-by: Stephen Brawner <stephenbrawner@verbsurgical.com> * Moving var to top Signed-off-by: Stephen Brawner <stephenbrawner@verbsurgical.com> Co-authored-by: Stephen Brawner <stephenbrawner@verbsurgical.com>
This commit is contained in:
parent
30e0536a1d
commit
7146919c3f
7 changed files with 591 additions and 19 deletions
|
@ -650,13 +650,15 @@ _register_transitions(
|
|||
return ret;
|
||||
}
|
||||
|
||||
// default implementation as despicted on
|
||||
// default implementation as depicted on
|
||||
// design.ros2.org
|
||||
rcl_ret_t
|
||||
rcl_lifecycle_init_default_state_machine(
|
||||
rcl_lifecycle_state_machine_t * state_machine, const rcutils_allocator_t * allocator)
|
||||
{
|
||||
rcl_ret_t ret = RCL_RET_ERROR;
|
||||
// Used for concatenating error messages in the fail: block.
|
||||
const char * fail_error_message = "";
|
||||
|
||||
// ***************************
|
||||
// register all primary states
|
||||
|
@ -691,8 +693,26 @@ rcl_lifecycle_init_default_state_machine(
|
|||
return ret;
|
||||
|
||||
fail:
|
||||
// If rcl_lifecycle_transition_map_fini() fails, it will clobber the error string here.
|
||||
// Concatenate the error strings if that happens
|
||||
if (rcl_error_is_set()) {
|
||||
fail_error_message = rcl_get_error_string().str;
|
||||
}
|
||||
|
||||
if (rcl_lifecycle_transition_map_fini(&state_machine->transition_map, allocator) != RCL_RET_OK) {
|
||||
RCL_SET_ERROR_MSG("could not free lifecycle transition map. Leaking memory!\n");
|
||||
const char * fini_error = "";
|
||||
if (rcl_error_is_set()) {
|
||||
fini_error = rcl_get_error_string().str;
|
||||
rcl_reset_error();
|
||||
}
|
||||
RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(
|
||||
"Freeing transition map failed while handling a previous error. Leaking memory!"
|
||||
"\nOriginal error:\n\t%s\nError encountered in rcl_lifecycle_transition_map_fini():\n\t%s\n",
|
||||
fail_error_message, fini_error);
|
||||
}
|
||||
|
||||
if (!rcl_error_is_set()) {
|
||||
RCL_SET_ERROR_MSG("Unspecified error in default_state_machine _register_transitions()");
|
||||
}
|
||||
return RCL_RET_ERROR;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue