Add fault injection macros and unit tests to rcl_lifecycle (#731)
* Add fault injection macros and unit tests to rcl_lifecycle Signed-off-by: Stephen Brawner <brawner@gmail.com> * Address feedback Signed-off-by: Stephen Brawner <brawner@gmail.com> * PR Fixup Signed-off-by: Stephen Brawner <brawner@gmail.com>
This commit is contained in:
parent
b62b83b5cd
commit
dd62d09042
5 changed files with 96 additions and 6 deletions
|
@ -28,6 +28,7 @@
|
|||
#include "rcl/rcl.h"
|
||||
|
||||
#include "rcutils/logging_macros.h"
|
||||
#include "rcutils/testing/fault_injection.h"
|
||||
|
||||
#include "rcl_lifecycle/rcl_lifecycle.h"
|
||||
#include "rcl_lifecycle/default_state_machine.h"
|
||||
|
@ -833,3 +834,19 @@ TEST_F(TestDefaultStateMachine, default_sequence_error_unresolved) {
|
|||
rcl_lifecycle_state_machine_fini(&state_machine, this->node_ptr, this->allocator));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(TestDefaultStateMachine, init_fini_maybe_fail) {
|
||||
rcl_lifecycle_state_machine_t sm = rcl_lifecycle_get_zero_initialized_state_machine();
|
||||
RCUTILS_FAULT_INJECTION_TEST(
|
||||
{
|
||||
rcl_ret_t ret = rcl_lifecycle_init_default_state_machine(&sm, this->allocator);
|
||||
if (RCL_RET_OK == ret) {
|
||||
ret = rcl_lifecycle_state_machine_fini(&sm, this->node_ptr, this->allocator);
|
||||
if (RCL_RET_OK != ret) {
|
||||
EXPECT_EQ(
|
||||
RCL_RET_OK,
|
||||
rcl_lifecycle_state_machine_fini(&sm, this->node_ptr, this->allocator));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue