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
|
@ -69,6 +69,15 @@ TEST_F(TestCallbackExceptions, positive_on_error) {
|
|||
EXPECT_EQ(static_cast<size_t>(2), test_node->number_of_callbacks);
|
||||
}
|
||||
|
||||
TEST_F(TestCallbackExceptions, positive_on_error_with_code) {
|
||||
auto test_node = std::make_shared<PositiveCallbackExceptionNode>("testnode");
|
||||
|
||||
EXPECT_EQ(State::PRIMARY_STATE_UNCONFIGURED, test_node->get_current_state().id());
|
||||
rcl_lifecycle_ret_t ret = RCL_LIFECYCLE_RET_OK;
|
||||
test_node->configure(ret);
|
||||
EXPECT_EQ(RCL_LIFECYCLE_RET_ERROR, ret);
|
||||
}
|
||||
|
||||
class NegativeCallbackExceptionNode : public rclcpp_lifecycle::LifecycleNode
|
||||
{
|
||||
public:
|
||||
|
@ -91,6 +100,7 @@ protected:
|
|||
return RCL_LIFECYCLE_RET_FAILURE;
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(TestCallbackExceptions, negative_on_error) {
|
||||
auto test_node = std::make_shared<NegativeCallbackExceptionNode>("testnode");
|
||||
|
||||
|
@ -100,3 +110,12 @@ TEST_F(TestCallbackExceptions, negative_on_error) {
|
|||
// check if all callbacks were successfully overwritten
|
||||
EXPECT_EQ(static_cast<size_t>(2), test_node->number_of_callbacks);
|
||||
}
|
||||
|
||||
TEST_F(TestCallbackExceptions, negative_on_error_with_code) {
|
||||
auto test_node = std::make_shared<NegativeCallbackExceptionNode>("testnode");
|
||||
|
||||
EXPECT_EQ(State::PRIMARY_STATE_UNCONFIGURED, test_node->get_current_state().id());
|
||||
rcl_lifecycle_ret_t ret = RCL_RET_OK;
|
||||
test_node->configure(ret);
|
||||
EXPECT_EQ(RCL_LIFECYCLE_RET_ERROR, ret);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue