-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Topic fix rcl lifecycle test issue #715
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,14 +133,23 @@ TEST(TestRclLifecycle, lifecycle_transition) { | |
|
||
ret = rcl_lifecycle_transition_init( | ||
&transition, expected_id, &expected_label[0], nullptr, nullptr, &allocator); | ||
EXPECT_EQ(ret, RCL_RET_OK); | ||
EXPECT_EQ(ret, RCL_RET_OK) << rcl_get_error_string().str; | ||
Karsten1987 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
rcutils_reset_error(); | ||
ret = rcl_lifecycle_transition_fini(&transition, &allocator); | ||
EXPECT_EQ(ret, RCL_RET_OK) << rcl_get_error_string().str; | ||
rcutils_reset_error(); | ||
|
||
ret = rcl_lifecycle_transition_init( | ||
&transition, expected_id, &expected_label[0], start, nullptr, &allocator); | ||
EXPECT_EQ(ret, RCL_RET_OK); | ||
EXPECT_EQ(ret, RCL_RET_OK) << rcl_get_error_string().str; | ||
rcutils_reset_error(); | ||
ret = rcl_lifecycle_transition_fini(&transition, &allocator); | ||
EXPECT_EQ(ret, RCL_RET_OK) << rcl_get_error_string().str; | ||
rcutils_reset_error(); | ||
|
||
start = reinterpret_cast<rcl_lifecycle_state_t *>( | ||
allocator.allocate(sizeof(rcl_lifecycle_state_t), allocator.state)); | ||
*start = rcl_lifecycle_get_zero_initialized_state(); | ||
Karsten1987 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
rcl_allocator_t bad_allocator = rcl_get_default_allocator(); | ||
bad_allocator.allocate = bad_malloc; | ||
bad_allocator.reallocate = bad_realloc; | ||
|
@@ -190,15 +199,16 @@ TEST(TestRclLifecycle, state_machine) { | |
ret = rcl_init(0, nullptr, &init_options, &context); | ||
EXPECT_EQ(ret, RCL_RET_OK) << rcl_get_error_string().str; | ||
|
||
ret = rcl_node_init(&node, "node", "namespace", &context, &options); | ||
EXPECT_EQ(ret, RCL_RET_OK) << rcl_get_error_string().str; | ||
|
||
OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT( | ||
{ | ||
ASSERT_EQ(RCL_RET_OK, rcl_shutdown(&context)); | ||
ASSERT_EQ(RCL_RET_OK, rcl_context_fini(&context)); | ||
ASSERT_EQ(RCL_RET_OK, rcl_node_fini(&node)) << rcl_get_error_string().str; | ||
ASSERT_EQ(RCL_RET_OK, rcl_shutdown(&context)) << rcl_get_error_string().str; | ||
ASSERT_EQ(RCL_RET_OK, rcl_context_fini(&context)) << rcl_get_error_string().str; | ||
}); | ||
|
||
ret = rcl_node_init(&node, "node", "namespace", &context, &options); | ||
EXPECT_EQ(ret, RCL_RET_OK) << rcl_get_error_string().str; | ||
|
||
const rosidl_message_type_support_t * pn = | ||
ROSIDL_GET_MSG_TYPE_SUPPORT(lifecycle_msgs, msg, TransitionEvent); | ||
const rosidl_service_type_support_t * cs = | ||
|
@@ -326,6 +336,7 @@ TEST(TestRclLifecycle, state_machine) { | |
// Node is null | ||
ret = rcl_lifecycle_state_machine_fini(&state_machine, nullptr, &allocator); | ||
EXPECT_EQ(ret, RCL_RET_ERROR); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would expect to see There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It means rcl_get_error_string().str is output if ret != RCL_RET_ERROR. |
||
rcutils_reset_error(); | ||
std::cout << "state_machine: " << __LINE__ << std::endl; | ||
} | ||
|
||
|
@@ -349,15 +360,16 @@ TEST(TestRclLifecycle, state_transitions) { | |
ret = rcl_init(0, nullptr, &init_options, &context); | ||
EXPECT_EQ(ret, RCL_RET_OK) << rcl_get_error_string().str; | ||
|
||
ret = rcl_node_init(&node, "node", "namespace", &context, &options); | ||
EXPECT_EQ(ret, RCL_RET_OK) << rcl_get_error_string().str; | ||
|
||
OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT( | ||
{ | ||
ASSERT_EQ(RCL_RET_OK, rcl_shutdown(&context)); | ||
ASSERT_EQ(RCL_RET_OK, rcl_context_fini(&context)); | ||
ASSERT_EQ(RCL_RET_OK, rcl_node_fini(&node)) << rcl_get_error_string().str; | ||
ASSERT_EQ(RCL_RET_OK, rcl_shutdown(&context)) << rcl_get_error_string().str; | ||
ASSERT_EQ(RCL_RET_OK, rcl_context_fini(&context)) << rcl_get_error_string().str; | ||
}); | ||
|
||
ret = rcl_node_init(&node, "node", "namespace", &context, &options); | ||
EXPECT_EQ(ret, RCL_RET_OK) << rcl_get_error_string().str; | ||
|
||
const rosidl_message_type_support_t * pn = | ||
ROSIDL_GET_MSG_TYPE_SUPPORT(lifecycle_msgs, msg, TransitionEvent); | ||
const rosidl_service_type_support_t * cs = | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not initializing it directly? That would say it later on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default_allocator
is only used in failure case.I think it happens seldom.
So need not call
rcl_get_default_allocator()
each time.What do you think ?