expose error handling for state changes (#344)
* remove fprintf, use logging * expose lifecycle error code * address comments
This commit is contained in:
parent
40b09b5b14
commit
0c26dd99b6
5 changed files with 160 additions and 31 deletions
|
@ -35,10 +35,6 @@ struct BadMood
|
|||
{
|
||||
static constexpr rcl_lifecycle_ret_t cb_ret = RCL_LIFECYCLE_RET_FAILURE;
|
||||
};
|
||||
struct VeryBadMood
|
||||
{
|
||||
static constexpr rcl_lifecycle_ret_t cb_ret = RCL_LIFECYCLE_RET_ERROR;
|
||||
};
|
||||
|
||||
class TestDefaultStateMachine : public ::testing::Test
|
||||
{
|
||||
|
@ -144,6 +140,30 @@ TEST_F(TestDefaultStateMachine, trigger_transition) {
|
|||
rclcpp_lifecycle::Transition(Transition::TRANSITION_SHUTDOWN)).id());
|
||||
}
|
||||
|
||||
TEST_F(TestDefaultStateMachine, trigger_transition_with_error_code) {
|
||||
auto test_node = std::make_shared<EmptyLifecycleNode>("testnode");
|
||||
|
||||
rcl_lifecycle_ret_t ret = RCL_LIFECYCLE_RET_ERROR;
|
||||
test_node->configure(ret);
|
||||
EXPECT_EQ(RCL_LIFECYCLE_RET_OK, ret);
|
||||
ret = RCL_LIFECYCLE_RET_ERROR;
|
||||
|
||||
test_node->activate(ret);
|
||||
EXPECT_EQ(RCL_LIFECYCLE_RET_OK, ret);
|
||||
ret = RCL_LIFECYCLE_RET_ERROR;
|
||||
|
||||
test_node->deactivate(ret);
|
||||
EXPECT_EQ(RCL_LIFECYCLE_RET_OK, ret);
|
||||
ret = RCL_LIFECYCLE_RET_ERROR;
|
||||
|
||||
test_node->cleanup(ret);
|
||||
EXPECT_EQ(RCL_LIFECYCLE_RET_OK, ret);
|
||||
ret = RCL_LIFECYCLE_RET_ERROR;
|
||||
|
||||
test_node->shutdown(ret);
|
||||
EXPECT_EQ(RCL_LIFECYCLE_RET_OK, ret);
|
||||
}
|
||||
|
||||
TEST_F(TestDefaultStateMachine, good_mood) {
|
||||
auto test_node = std::make_shared<MoodyLifecycleNode<GoodMood>>("testnode");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue