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:
brawner 2020-05-22 14:44:11 -07:00 committed by GitHub
parent 30e0536a1d
commit 7146919c3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 591 additions and 19 deletions

View file

@ -113,7 +113,13 @@ TEST_F(TestDefaultStateMachine, zero_init) {
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);
// Because this init method is so complex, the succession of failures caused by a null
// allocator will result in several error messages overwriting themselves.
auto ret = rcl_lifecycle_init_default_state_machine(&state_machine, nullptr);
EXPECT_EQ(RCL_RET_ERROR, ret);
rcutils_reset_error();
ret = rcl_lifecycle_init_default_state_machine(&state_machine, this->allocator);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
ret = rcl_lifecycle_state_machine_fini(&state_machine, this->node_ptr, this->allocator);