use new error handling API from rcutils (#314)
* use new error handling API from rcutils Signed-off-by: William Woodall <william@osrfoundation.org> * use semicolons after macros Signed-off-by: William Woodall <william@osrfoundation.org> * use new error handling API from rcutils Signed-off-by: William Woodall <william@osrfoundation.org> * minimize vertical whitespace Signed-off-by: William Woodall <william@osrfoundation.org> * use semicolons after macros Signed-off-by: William Woodall <william@osrfoundation.org>
This commit is contained in:
parent
765de78140
commit
4d8cb487f8
64 changed files with 1131 additions and 1314 deletions
|
@ -67,21 +67,16 @@ rcl_lifecycle_com_interface_init(
|
|||
const rosidl_service_type_support_t * ts_srv_get_state,
|
||||
const rosidl_service_type_support_t * ts_srv_get_available_states,
|
||||
const rosidl_service_type_support_t * ts_srv_get_available_transitions,
|
||||
const rosidl_service_type_support_t * ts_srv_get_transition_graph,
|
||||
const rcl_allocator_t * allocator)
|
||||
const rosidl_service_type_support_t * ts_srv_get_transition_graph)
|
||||
{
|
||||
RCL_CHECK_ARGUMENT_FOR_NULL(allocator, RCL_RET_INVALID_ARGUMENT, rcl_get_default_allocator())
|
||||
RCL_CHECK_ARGUMENT_FOR_NULL(com_interface, RCL_RET_INVALID_ARGUMENT, *allocator)
|
||||
RCL_CHECK_ARGUMENT_FOR_NULL(node_handle, RCL_RET_INVALID_ARGUMENT, *allocator)
|
||||
RCL_CHECK_ARGUMENT_FOR_NULL(ts_pub_notify, RCL_RET_INVALID_ARGUMENT, *allocator)
|
||||
RCL_CHECK_ARGUMENT_FOR_NULL(ts_srv_change_state, RCL_RET_INVALID_ARGUMENT, *allocator)
|
||||
RCL_CHECK_ARGUMENT_FOR_NULL(ts_srv_get_state, RCL_RET_INVALID_ARGUMENT, *allocator)
|
||||
RCL_CHECK_ARGUMENT_FOR_NULL(
|
||||
ts_srv_get_available_states, RCL_RET_INVALID_ARGUMENT, *allocator)
|
||||
RCL_CHECK_ARGUMENT_FOR_NULL(
|
||||
ts_srv_get_available_transitions, RCL_RET_INVALID_ARGUMENT, *allocator)
|
||||
RCL_CHECK_ARGUMENT_FOR_NULL(
|
||||
ts_srv_get_transition_graph, RCL_RET_INVALID_ARGUMENT, *allocator)
|
||||
RCL_CHECK_ARGUMENT_FOR_NULL(com_interface, RCL_RET_INVALID_ARGUMENT);
|
||||
RCL_CHECK_ARGUMENT_FOR_NULL(node_handle, RCL_RET_INVALID_ARGUMENT);
|
||||
RCL_CHECK_ARGUMENT_FOR_NULL(ts_pub_notify, RCL_RET_INVALID_ARGUMENT);
|
||||
RCL_CHECK_ARGUMENT_FOR_NULL(ts_srv_change_state, RCL_RET_INVALID_ARGUMENT);
|
||||
RCL_CHECK_ARGUMENT_FOR_NULL(ts_srv_get_state, RCL_RET_INVALID_ARGUMENT);
|
||||
RCL_CHECK_ARGUMENT_FOR_NULL(ts_srv_get_available_states, RCL_RET_INVALID_ARGUMENT);
|
||||
RCL_CHECK_ARGUMENT_FOR_NULL(ts_srv_get_available_transitions, RCL_RET_INVALID_ARGUMENT);
|
||||
RCL_CHECK_ARGUMENT_FOR_NULL(ts_srv_get_transition_graph, RCL_RET_INVALID_ARGUMENT);
|
||||
|
||||
// initialize publisher
|
||||
{
|
||||
|
|
|
@ -37,8 +37,7 @@ rcl_lifecycle_com_interface_init(
|
|||
const rosidl_service_type_support_t * ts_srv_get_state,
|
||||
const rosidl_service_type_support_t * ts_srv_get_available_states,
|
||||
const rosidl_service_type_support_t * ts_srv_get_available_transitions,
|
||||
const rosidl_service_type_support_t * ts_srv_get_transition_graph,
|
||||
const rcl_allocator_t * allocator);
|
||||
const rosidl_service_type_support_t * ts_srv_get_transition_graph);
|
||||
|
||||
rcl_ret_t
|
||||
RCL_WARN_UNUSED
|
||||
|
|
|
@ -692,8 +692,7 @@ rcl_lifecycle_init_default_state_machine(
|
|||
|
||||
fail:
|
||||
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",
|
||||
rcl_get_default_allocator());
|
||||
RCL_SET_ERROR_MSG("could not free lifecycle transition map. Leaking memory!\n");
|
||||
}
|
||||
return RCL_RET_ERROR;
|
||||
}
|
||||
|
|
|
@ -51,19 +51,18 @@ rcl_lifecycle_state_init(
|
|||
const rcl_allocator_t * allocator)
|
||||
{
|
||||
if (!allocator) {
|
||||
RCL_SET_ERROR_MSG("can't initialize state, no allocator given\n",
|
||||
rcl_get_default_allocator());
|
||||
RCL_SET_ERROR_MSG("can't initialize state, no allocator given\n");
|
||||
return RCL_RET_ERROR;
|
||||
}
|
||||
if (!state) {
|
||||
RCL_SET_ERROR_MSG("state pointer is null\n", *allocator);
|
||||
RCL_SET_ERROR_MSG("state pointer is null\n");
|
||||
return RCL_RET_ERROR;
|
||||
}
|
||||
|
||||
state->id = id;
|
||||
state->label = rcutils_strndup(label, strlen(label), *allocator);
|
||||
if (!state->label) {
|
||||
RCL_SET_ERROR_MSG("failed to duplicate label for rcl_lifecycle_state_t\n", *allocator);
|
||||
RCL_SET_ERROR_MSG("failed to duplicate label for rcl_lifecycle_state_t\n");
|
||||
return RCL_RET_ERROR;
|
||||
}
|
||||
|
||||
|
@ -76,8 +75,7 @@ rcl_lifecycle_state_fini(
|
|||
const rcl_allocator_t * allocator)
|
||||
{
|
||||
if (!allocator) {
|
||||
RCL_SET_ERROR_MSG("can't free state, no allocator given\n",
|
||||
rcl_get_default_allocator());
|
||||
RCL_SET_ERROR_MSG("can't free state, no allocator given\n");
|
||||
return RCL_RET_ERROR;
|
||||
}
|
||||
// it is already NULL
|
||||
|
@ -114,13 +112,12 @@ rcl_lifecycle_transition_init(
|
|||
const rcl_allocator_t * allocator)
|
||||
{
|
||||
if (!allocator) {
|
||||
RCL_SET_ERROR_MSG("can't initialize transition, no allocator given\n",
|
||||
rcl_get_default_allocator());
|
||||
RCL_SET_ERROR_MSG("can't initialize transition, no allocator given\n");
|
||||
return RCL_RET_ERROR;
|
||||
}
|
||||
|
||||
if (!transition) {
|
||||
RCL_SET_ERROR_MSG("transition pointer is null\n", *allocator);
|
||||
RCL_SET_ERROR_MSG("transition pointer is null\n");
|
||||
return RCL_RET_OK;
|
||||
}
|
||||
|
||||
|
@ -130,7 +127,7 @@ rcl_lifecycle_transition_init(
|
|||
transition->id = id;
|
||||
transition->label = rcutils_strndup(label, strlen(label), *allocator);
|
||||
if (!transition->label) {
|
||||
RCL_SET_ERROR_MSG("failed to duplicate label for rcl_lifecycle_transition_t\n", *allocator);
|
||||
RCL_SET_ERROR_MSG("failed to duplicate label for rcl_lifecycle_transition_t\n");
|
||||
return RCL_RET_ERROR;
|
||||
}
|
||||
|
||||
|
@ -143,8 +140,7 @@ rcl_lifecycle_transition_fini(
|
|||
const rcl_allocator_t * allocator)
|
||||
{
|
||||
if (!allocator) {
|
||||
RCL_SET_ERROR_MSG("can't initialize transition, no allocator given\n",
|
||||
rcl_get_default_allocator());
|
||||
RCL_SET_ERROR_MSG("can't initialize transition, no allocator given\n");
|
||||
return RCL_RET_ERROR;
|
||||
}
|
||||
// it is already NULL
|
||||
|
@ -197,8 +193,7 @@ rcl_lifecycle_state_machine_init(
|
|||
const rcl_allocator_t * allocator)
|
||||
{
|
||||
if (!allocator) {
|
||||
RCL_SET_ERROR_MSG("can't initialize state machine, no allocator given\n",
|
||||
rcl_get_default_allocator());
|
||||
RCL_SET_ERROR_MSG("can't initialize state machine, no allocator given\n");
|
||||
return RCL_RET_ERROR;
|
||||
}
|
||||
|
||||
|
@ -206,8 +201,7 @@ rcl_lifecycle_state_machine_init(
|
|||
&state_machine->com_interface, node_handle,
|
||||
ts_pub_notify,
|
||||
ts_srv_change_state, ts_srv_get_state,
|
||||
ts_srv_get_available_states, ts_srv_get_available_transitions, ts_srv_get_transition_graph,
|
||||
allocator);
|
||||
ts_srv_get_available_states, ts_srv_get_available_transitions, ts_srv_get_transition_graph);
|
||||
if (ret != RCL_RET_OK) {
|
||||
return RCL_RET_ERROR;
|
||||
}
|
||||
|
@ -235,24 +229,21 @@ rcl_lifecycle_state_machine_fini(
|
|||
const rcl_allocator_t * allocator)
|
||||
{
|
||||
if (!allocator) {
|
||||
RCL_SET_ERROR_MSG("can't free state machine, no allocator given\n",
|
||||
rcl_get_default_allocator());
|
||||
RCL_SET_ERROR_MSG("can't free state machine, no allocator given\n");
|
||||
return RCL_RET_ERROR;
|
||||
}
|
||||
|
||||
rcl_ret_t fcn_ret = RCL_RET_OK;
|
||||
|
||||
if (rcl_lifecycle_com_interface_fini(&state_machine->com_interface, node_handle) != RCL_RET_OK) {
|
||||
RCL_SET_ERROR_MSG(
|
||||
"could not free lifecycle com interface. Leaking memory!\n", rcl_get_default_allocator());
|
||||
RCL_SET_ERROR_MSG("could not free lifecycle com interface. Leaking memory!\n");
|
||||
fcn_ret = RCL_RET_ERROR;
|
||||
}
|
||||
|
||||
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", rcl_get_default_allocator());
|
||||
RCL_SET_ERROR_MSG("could not free lifecycle transition map. Leaking memory!\n");
|
||||
fcn_ret = RCL_RET_ERROR;
|
||||
}
|
||||
|
||||
|
@ -263,15 +254,15 @@ rcl_ret_t
|
|||
rcl_lifecycle_state_machine_is_initialized(const rcl_lifecycle_state_machine_t * state_machine)
|
||||
{
|
||||
if (!state_machine->com_interface.srv_get_state.impl) {
|
||||
RCL_SET_ERROR_MSG("get_state service is null", rcl_get_default_allocator());
|
||||
RCL_SET_ERROR_MSG("get_state service is null");
|
||||
return RCL_RET_ERROR;
|
||||
}
|
||||
if (!state_machine->com_interface.srv_change_state.impl) {
|
||||
RCL_SET_ERROR_MSG("change_state service is null", rcl_get_default_allocator());
|
||||
RCL_SET_ERROR_MSG("change_state service is null");
|
||||
return RCL_RET_ERROR;
|
||||
}
|
||||
if (rcl_lifecycle_transition_map_is_initialized(&state_machine->transition_map) != RCL_RET_OK) {
|
||||
RCL_SET_ERROR_MSG("transition map is null", rcl_get_default_allocator());
|
||||
RCL_SET_ERROR_MSG("transition map is null");
|
||||
return RCL_RET_ERROR;
|
||||
}
|
||||
return RCL_RET_OK;
|
||||
|
@ -282,8 +273,7 @@ rcl_lifecycle_get_transition_by_id(
|
|||
const rcl_lifecycle_state_t * state,
|
||||
uint8_t id)
|
||||
{
|
||||
RCL_CHECK_FOR_NULL_WITH_MSG(state,
|
||||
"state pointer is null", return NULL, rcl_get_default_allocator());
|
||||
RCL_CHECK_FOR_NULL_WITH_MSG(state, "state pointer is null", return NULL);
|
||||
|
||||
for (unsigned int i = 0; i < state->valid_transition_size; ++i) {
|
||||
if (state->valid_transitions[i].id == id) {
|
||||
|
@ -304,8 +294,7 @@ rcl_lifecycle_get_transition_by_label(
|
|||
const rcl_lifecycle_state_t * state,
|
||||
const char * label)
|
||||
{
|
||||
RCL_CHECK_FOR_NULL_WITH_MSG(state,
|
||||
"state pointer is null", return NULL, rcl_get_default_allocator());
|
||||
RCL_CHECK_FOR_NULL_WITH_MSG(state, "state pointer is null", return NULL);
|
||||
|
||||
for (unsigned int i = 0; i < state->valid_transition_size; ++i) {
|
||||
if (strcmp(state->valid_transitions[i].label, label) == 0) {
|
||||
|
@ -329,7 +318,7 @@ _trigger_transition(
|
|||
{
|
||||
// If we have a faulty transition pointer
|
||||
if (!transition) {
|
||||
RCL_SET_ERROR_MSG("Transition is not registered.", rcl_get_default_allocator());
|
||||
RCL_SET_ERROR_MSG("Transition is not registered.");
|
||||
return RCL_RET_ERROR;
|
||||
}
|
||||
|
||||
|
@ -344,7 +333,7 @@ _trigger_transition(
|
|||
rcl_ret_t ret = rcl_lifecycle_com_interface_publish_notification(
|
||||
&state_machine->com_interface, transition->start, state_machine->current_state);
|
||||
if (ret != RCL_RET_OK) {
|
||||
RCL_SET_ERROR_MSG("Could not publish transition", rcl_get_default_allocator());
|
||||
RCL_SET_ERROR_MSG("Could not publish transition");
|
||||
return RCL_RET_ERROR;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,8 +72,7 @@ rcl_lifecycle_register_state(
|
|||
const rcutils_allocator_t * allocator)
|
||||
{
|
||||
if (rcl_lifecycle_get_state(transition_map, state.id) != NULL) {
|
||||
RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(rcutils_get_default_allocator(),
|
||||
"state %u is already registered\n", state.id);
|
||||
RCL_SET_ERROR_MSG_WITH_FORMAT_STRING("state %u is already registered\n", state.id);
|
||||
return RCL_RET_ERROR;
|
||||
}
|
||||
|
||||
|
@ -87,8 +86,7 @@ rcl_lifecycle_register_state(
|
|||
transition_map->states_size * sizeof(rcl_lifecycle_state_t),
|
||||
allocator->state);
|
||||
if (!new_states) {
|
||||
RCL_SET_ERROR_MSG(
|
||||
"failed to reallocate memory for new states", rcl_get_default_allocator());
|
||||
RCL_SET_ERROR_MSG("failed to reallocate memory for new states");
|
||||
return RCL_RET_ERROR;
|
||||
}
|
||||
transition_map->states = new_states;
|
||||
|
@ -108,8 +106,7 @@ rcl_lifecycle_register_transition(
|
|||
|
||||
rcl_lifecycle_state_t * state = rcl_lifecycle_get_state(transition_map, transition.start->id);
|
||||
if (!state) {
|
||||
RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(rcl_get_default_allocator(),
|
||||
"state %u is not registered\n", transition.start->id);
|
||||
RCL_SET_ERROR_MSG_WITH_FORMAT_STRING("state %u is not registered\n", transition.start->id);
|
||||
return RCL_RET_ERROR;
|
||||
}
|
||||
|
||||
|
@ -120,9 +117,7 @@ rcl_lifecycle_register_transition(
|
|||
transition_map->transitions_size * sizeof(rcl_lifecycle_transition_t),
|
||||
allocator->state);
|
||||
if (!new_transitions) {
|
||||
RCL_SET_ERROR_MSG(
|
||||
"failed to reallocate memory for new transitions",
|
||||
rcl_get_default_allocator());
|
||||
RCL_SET_ERROR_MSG("failed to reallocate memory for new transitions");
|
||||
return RCL_RET_BAD_ALLOC;
|
||||
}
|
||||
transition_map->transitions = new_transitions;
|
||||
|
@ -138,9 +133,7 @@ rcl_lifecycle_register_transition(
|
|||
state->valid_transition_size * sizeof(rcl_lifecycle_transition_t),
|
||||
allocator->state);
|
||||
if (!new_valid_transitions) {
|
||||
RCL_SET_ERROR_MSG(
|
||||
"failed to reallocate memory for new transitions on state",
|
||||
rcl_get_default_allocator());
|
||||
RCL_SET_ERROR_MSG("failed to reallocate memory for new transitions on state");
|
||||
return RCL_RET_ERROR;
|
||||
}
|
||||
state->valid_transitions = new_valid_transitions;
|
||||
|
|
|
@ -40,13 +40,13 @@ protected:
|
|||
{
|
||||
rcl_ret_t ret;
|
||||
ret = rcl_init(0, nullptr, rcl_get_default_allocator());
|
||||
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||
this->node_ptr = new rcl_node_t;
|
||||
*this->node_ptr = rcl_get_zero_initialized_node();
|
||||
const char * name = "test_state_machine_node";
|
||||
rcl_node_options_t node_options = rcl_node_get_default_options();
|
||||
ret = rcl_node_init(this->node_ptr, name, "", &node_options);
|
||||
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||
const rcl_node_options_t * node_ops = rcl_node_get_options(this->node_ptr);
|
||||
this->allocator = &node_ops->allocator;
|
||||
}
|
||||
|
@ -55,9 +55,9 @@ protected:
|
|||
{
|
||||
rcl_ret_t ret = rcl_node_fini(this->node_ptr);
|
||||
delete this->node_ptr;
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||
ret = rcl_shutdown();
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -91,17 +91,17 @@ TEST_F(TestDefaultStateMachine, zero_init) {
|
|||
EXPECT_EQ(transition_map->transitions, nullptr);
|
||||
|
||||
auto ret = rcl_lifecycle_state_machine_fini(&state_machine, this->node_ptr, this->allocator);
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||
}
|
||||
|
||||
TEST_F(TestDefaultStateMachine, default_init) {
|
||||
rcl_lifecycle_state_machine_t state_machine = rcl_lifecycle_get_zero_initialized_state_machine();
|
||||
|
||||
auto ret = rcl_lifecycle_init_default_state_machine(&state_machine, this->allocator);
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||
|
||||
ret = rcl_lifecycle_state_machine_fini(&state_machine, this->node_ptr, this->allocator);
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||
}
|
||||
|
||||
TEST_F(TestDefaultStateMachine, default_sequence) {
|
||||
|
@ -109,7 +109,7 @@ TEST_F(TestDefaultStateMachine, default_sequence) {
|
|||
|
||||
rcl_lifecycle_state_machine_t state_machine = rcl_lifecycle_get_zero_initialized_state_machine();
|
||||
ret = rcl_lifecycle_init_default_state_machine(&state_machine, this->allocator);
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||
|
||||
test_trigger_transition(
|
||||
&state_machine,
|
||||
|
@ -180,7 +180,7 @@ TEST_F(TestDefaultStateMachine, wrong_default_sequence) {
|
|||
|
||||
rcl_lifecycle_state_machine_t state_machine = rcl_lifecycle_get_zero_initialized_state_machine();
|
||||
ret = rcl_lifecycle_init_default_state_machine(&state_machine, this->allocator);
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||
|
||||
std::vector<uint8_t> transition_ids =
|
||||
{
|
||||
|
@ -394,7 +394,7 @@ TEST_F(TestDefaultStateMachine, default_in_a_loop) {
|
|||
|
||||
rcl_lifecycle_state_machine_t state_machine = rcl_lifecycle_get_zero_initialized_state_machine();
|
||||
ret = rcl_lifecycle_init_default_state_machine(&state_machine, this->allocator);
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||
|
||||
for (auto i = 0; i < 5; ++i) {
|
||||
test_trigger_transition(
|
||||
|
@ -467,7 +467,7 @@ TEST_F(TestDefaultStateMachine, default_sequence_failure) {
|
|||
|
||||
rcl_lifecycle_state_machine_t state_machine = rcl_lifecycle_get_zero_initialized_state_machine();
|
||||
ret = rcl_lifecycle_init_default_state_machine(&state_machine, this->allocator);
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||
|
||||
test_trigger_transition(
|
||||
&state_machine,
|
||||
|
@ -583,7 +583,7 @@ TEST_F(TestDefaultStateMachine, default_sequence_error_resolved) {
|
|||
|
||||
rcl_lifecycle_state_machine_t state_machine = rcl_lifecycle_get_zero_initialized_state_machine();
|
||||
ret = rcl_lifecycle_init_default_state_machine(&state_machine, this->allocator);
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||
|
||||
test_trigger_transition(
|
||||
&state_machine,
|
||||
|
@ -732,7 +732,7 @@ TEST_F(TestDefaultStateMachine, default_sequence_error_unresolved) {
|
|||
rcl_lifecycle_state_machine_t state_machine =
|
||||
rcl_lifecycle_get_zero_initialized_state_machine();
|
||||
ret = rcl_lifecycle_init_default_state_machine(&state_machine, this->allocator);
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||
|
||||
test_trigger_transition(
|
||||
&state_machine,
|
||||
|
@ -760,7 +760,7 @@ TEST_F(TestDefaultStateMachine, default_sequence_error_unresolved) {
|
|||
rcl_lifecycle_state_machine_t state_machine =
|
||||
rcl_lifecycle_get_zero_initialized_state_machine();
|
||||
ret = rcl_lifecycle_init_default_state_machine(&state_machine, this->allocator);
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||
|
||||
test_trigger_transition(
|
||||
&state_machine,
|
||||
|
|
|
@ -37,13 +37,13 @@ protected:
|
|||
{
|
||||
rcl_ret_t ret;
|
||||
ret = rcl_init(0, nullptr, rcl_get_default_allocator());
|
||||
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||
this->node_ptr = new rcl_node_t;
|
||||
*this->node_ptr = rcl_get_zero_initialized_node();
|
||||
const char * name = "test_multiple_instances_node";
|
||||
rcl_node_options_t node_options = rcl_node_get_default_options();
|
||||
ret = rcl_node_init(this->node_ptr, name, "", &node_options);
|
||||
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||
const rcl_node_options_t * node_ops = rcl_node_get_options(this->node_ptr);
|
||||
this->allocator = &node_ops->allocator;
|
||||
}
|
||||
|
@ -52,9 +52,9 @@ protected:
|
|||
{
|
||||
rcl_ret_t ret = rcl_node_fini(this->node_ptr);
|
||||
delete this->node_ptr;
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||
ret = rcl_shutdown();
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -80,24 +80,24 @@ TEST_F(TestMultipleInstances, default_sequence_error_unresolved) {
|
|||
rcl_lifecycle_state_machine_t state_machine1 =
|
||||
rcl_lifecycle_get_zero_initialized_state_machine();
|
||||
ret = rcl_lifecycle_init_default_state_machine(&state_machine1, this->allocator);
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||
|
||||
rcl_lifecycle_state_machine_t state_machine2 =
|
||||
rcl_lifecycle_get_zero_initialized_state_machine();
|
||||
ret = rcl_lifecycle_init_default_state_machine(&state_machine2, this->allocator);
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||
|
||||
rcl_lifecycle_state_machine_t state_machine3 =
|
||||
rcl_lifecycle_get_zero_initialized_state_machine();
|
||||
ret = rcl_lifecycle_init_default_state_machine(&state_machine3, this->allocator);
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||
|
||||
test_trigger_transition(
|
||||
&state_machine1,
|
||||
lifecycle_msgs__msg__Transition__TRANSITION_CONFIGURE,
|
||||
lifecycle_msgs__msg__State__PRIMARY_STATE_UNCONFIGURED,
|
||||
lifecycle_msgs__msg__State__TRANSITION_STATE_CONFIGURING);
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||
|
||||
EXPECT_EQ(
|
||||
lifecycle_msgs__msg__State__TRANSITION_STATE_CONFIGURING, state_machine1.current_state->id);
|
||||
|
@ -107,9 +107,9 @@ TEST_F(TestMultipleInstances, default_sequence_error_unresolved) {
|
|||
lifecycle_msgs__msg__State__PRIMARY_STATE_UNCONFIGURED, state_machine3.current_state->id);
|
||||
|
||||
ret = rcl_lifecycle_state_machine_fini(&state_machine1, this->node_ptr, this->allocator);
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||
ret = rcl_lifecycle_state_machine_fini(&state_machine2, this->node_ptr, this->allocator);
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||
ret = rcl_lifecycle_state_machine_fini(&state_machine3, this->node_ptr, this->allocator);
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ TEST_F(TestTransitionMap, initialized) {
|
|||
EXPECT_EQ(RCL_RET_OK, rcl_lifecycle_transition_map_is_initialized(&transition_map));
|
||||
|
||||
ret = rcl_lifecycle_register_state(&transition_map, state0, &allocator);
|
||||
EXPECT_EQ(RCL_RET_ERROR, ret) << rcl_get_error_string_safe();
|
||||
EXPECT_EQ(RCL_RET_ERROR, ret) << rcl_get_error_string().str;
|
||||
|
||||
rcl_lifecycle_state_t state1 = {"my_state_1", 1, NULL, 0};
|
||||
ret = rcl_lifecycle_register_state(&transition_map, state1, &allocator);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue