Make failed rcl_node_init to clean up fully, to allow recreating a node.
Update tests to not mask the improper cleanup.
This commit is contained in:
parent
02cc077145
commit
7e578a8fd6
2 changed files with 1 additions and 6 deletions
|
@ -107,6 +107,7 @@ fail:
|
||||||
if (node->impl) {
|
if (node->impl) {
|
||||||
allocator->deallocate(node->impl, allocator->state);
|
allocator->deallocate(node->impl, allocator->state);
|
||||||
}
|
}
|
||||||
|
*node = rcl_get_zero_initialized_node();
|
||||||
return fail_ret;
|
return fail_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -261,7 +261,6 @@ TEST_F(TestNodeFixture, test_rcl_node_life_cycle) {
|
||||||
ret = rcl_node_init(&node, name, &options_with_invalid_allocator);
|
ret = rcl_node_init(&node, name, &options_with_invalid_allocator);
|
||||||
EXPECT_EQ(RCL_RET_INVALID_ARGUMENT, ret) << "Expected RCL_RET_INVALID_ARGUMENT";
|
EXPECT_EQ(RCL_RET_INVALID_ARGUMENT, ret) << "Expected RCL_RET_INVALID_ARGUMENT";
|
||||||
rcl_reset_error();
|
rcl_reset_error();
|
||||||
node = rcl_get_zero_initialized_node();
|
|
||||||
// Try with failing allocator.
|
// Try with failing allocator.
|
||||||
rcl_node_options_t options_with_failing_allocator = rcl_node_get_default_options();
|
rcl_node_options_t options_with_failing_allocator = rcl_node_get_default_options();
|
||||||
options_with_failing_allocator.allocator.allocate = failing_malloc;
|
options_with_failing_allocator.allocator.allocate = failing_malloc;
|
||||||
|
@ -270,7 +269,6 @@ TEST_F(TestNodeFixture, test_rcl_node_life_cycle) {
|
||||||
ret = rcl_node_init(&node, name, &options_with_failing_allocator);
|
ret = rcl_node_init(&node, name, &options_with_failing_allocator);
|
||||||
EXPECT_EQ(RCL_RET_BAD_ALLOC, ret) << "Expected RCL_RET_BAD_ALLOC";
|
EXPECT_EQ(RCL_RET_BAD_ALLOC, ret) << "Expected RCL_RET_BAD_ALLOC";
|
||||||
rcl_reset_error();
|
rcl_reset_error();
|
||||||
node = rcl_get_zero_initialized_node();
|
|
||||||
// Try fini with invalid arguments.
|
// Try fini with invalid arguments.
|
||||||
ret = rcl_node_fini(nullptr);
|
ret = rcl_node_fini(nullptr);
|
||||||
EXPECT_EQ(RCL_RET_INVALID_ARGUMENT, ret) << "Expected RCL_RET_INVALID_ARGUMENT";
|
EXPECT_EQ(RCL_RET_INVALID_ARGUMENT, ret) << "Expected RCL_RET_INVALID_ARGUMENT";
|
||||||
|
@ -283,7 +281,6 @@ TEST_F(TestNodeFixture, test_rcl_node_life_cycle) {
|
||||||
EXPECT_EQ(RCL_RET_OK, ret);
|
EXPECT_EQ(RCL_RET_OK, ret);
|
||||||
ret = rcl_node_fini(&node);
|
ret = rcl_node_fini(&node);
|
||||||
EXPECT_EQ(RCL_RET_OK, ret);
|
EXPECT_EQ(RCL_RET_OK, ret);
|
||||||
node = rcl_get_zero_initialized_node();
|
|
||||||
// Try repeated init and fini calls.
|
// Try repeated init and fini calls.
|
||||||
ret = rcl_node_init(&node, name, &default_options);
|
ret = rcl_node_init(&node, name, &default_options);
|
||||||
EXPECT_EQ(RCL_RET_OK, ret);
|
EXPECT_EQ(RCL_RET_OK, ret);
|
||||||
|
@ -293,7 +290,6 @@ TEST_F(TestNodeFixture, test_rcl_node_life_cycle) {
|
||||||
EXPECT_EQ(RCL_RET_OK, ret);
|
EXPECT_EQ(RCL_RET_OK, ret);
|
||||||
ret = rcl_node_fini(&node);
|
ret = rcl_node_fini(&node);
|
||||||
EXPECT_EQ(RCL_RET_OK, ret);
|
EXPECT_EQ(RCL_RET_OK, ret);
|
||||||
node = rcl_get_zero_initialized_node();
|
|
||||||
// Try with a specific domain id.
|
// Try with a specific domain id.
|
||||||
rcl_node_options_t options_with_custom_domain_id = rcl_node_get_default_options();
|
rcl_node_options_t options_with_custom_domain_id = rcl_node_get_default_options();
|
||||||
options_with_custom_domain_id.domain_id = 42;
|
options_with_custom_domain_id.domain_id = 42;
|
||||||
|
@ -301,12 +297,10 @@ TEST_F(TestNodeFixture, test_rcl_node_life_cycle) {
|
||||||
if (is_windows && is_opensplice) {
|
if (is_windows && is_opensplice) {
|
||||||
// A custom domain id is not expected to work on Windows with Opensplice.
|
// A custom domain id is not expected to work on Windows with Opensplice.
|
||||||
EXPECT_NE(RCL_RET_OK, ret);
|
EXPECT_NE(RCL_RET_OK, ret);
|
||||||
node = rcl_get_zero_initialized_node();
|
|
||||||
} else {
|
} else {
|
||||||
// This is the normal check.
|
// This is the normal check.
|
||||||
EXPECT_EQ(RCL_RET_OK, ret);
|
EXPECT_EQ(RCL_RET_OK, ret);
|
||||||
ret = rcl_node_fini(&node);
|
ret = rcl_node_fini(&node);
|
||||||
EXPECT_EQ(RCL_RET_OK, ret);
|
EXPECT_EQ(RCL_RET_OK, ret);
|
||||||
node = rcl_get_zero_initialized_node();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue