Skip to content

Commit 1e944fd

Browse files
committed
Fix another failing test on CentOS 7.
Replace the use of inject_on_return with patch_and_return. Signed-off-by: Chris Lalancette <[email protected]>
1 parent df5c8d0 commit 1e944fd

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

rcl/test/rcl/test_node.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,15 +511,21 @@ TEST_F(CLASSNAME(TestNodeFixture, RMW_IMPLEMENTATION), test_rcl_node_init_with_i
511511
EXPECT_EQ(RCL_RET_ERROR, ret);
512512
rcl_reset_error();
513513
}
514+
514515
// Try normal init but force an internal error on fini.
515516
{
516517
ret = rcl_node_init(&node, name, namespace_, &context, &options);
517518
EXPECT_EQ(RCL_RET_OK, ret);
518-
auto mock = mocking_utils::inject_on_return("lib:rcl", rmw_destroy_node, RMW_RET_ERROR);
519-
ret = rcl_node_fini(&node);
520-
EXPECT_EQ(RCL_RET_ERROR, ret);
519+
auto mock = mocking_utils::patch_and_return(
520+
"lib:rcl", rcl_logging_rosout_fini_publisher_for_node, RCL_RET_ERROR);
521+
EXPECT_EQ(RCL_RET_ERROR, rcl_node_fini(&node));
521522
rcl_reset_error();
522523
}
524+
// This takes advantage of the fact that the very first call in
525+
// `rcl_node_fini` (`rcl_logging_rosout_fini_publisher_for_node`) was patched
526+
// for failure. Because of this, we can stop the patching, and just call
527+
// `rcl_node_fini` to really cleanup.
528+
EXPECT_EQ(RCL_RET_OK, rcl_node_fini(&node));
523529

524530
// Battle test node init.
525531
RCUTILS_FAULT_INJECTION_TEST(

0 commit comments

Comments
 (0)