-
Notifications
You must be signed in to change notification settings - Fork 163
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
Add tests checking when a graph guard condition is triggered #736
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 | ||||
---|---|---|---|---|---|---|
|
@@ -1295,6 +1295,32 @@ TEST_F(CLASSNAME(TestGraphFixture, RMW_IMPLEMENTATION), test_graph_guard_conditi | |||||
ASSERT_GE(graph_changes_count, 4ul); | ||||||
} | ||||||
|
||||||
/* Test the graph when guard condition is triggered. | ||||||
*/ | ||||||
TEST_F(CLASSNAME(TestGraphFixture, RMW_IMPLEMENTATION), test_graph_guard_condition_triggered) { | ||||||
rcl_ret_t ret; | ||||||
int64_t wait_time_out = -1; | ||||||
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.
Suggested change
Or consider getting rid of it completely, since it never changes. |
||||||
const rcl_guard_condition_t * graph_guard_condition = | ||||||
rcl_node_get_graph_guard_condition(this->node_ptr); | ||||||
ASSERT_NE(nullptr, graph_guard_condition) << rcl_get_error_string().str; | ||||||
ret = rcl_wait_set_clear(this->wait_set_ptr); | ||||||
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; | ||||||
ret = rcl_wait_set_add_guard_condition(this->wait_set_ptr, graph_guard_condition, NULL); | ||||||
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; | ||||||
|
||||||
std::thread trigger_thread( | ||||||
[ = ]() { | ||||||
std::this_thread::sleep_for(std::chrono::milliseconds(200)); | ||||||
rcl_ret_t ret = | ||||||
rcl_trigger_guard_condition(const_cast<rcl_guard_condition_t *>(graph_guard_condition)); | ||||||
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.
Suggested change
|
||||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; | ||||||
}); | ||||||
|
||||||
ret = rcl_wait(this->wait_set_ptr, wait_time_out); | ||||||
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; | ||||||
trigger_thread.join(); | ||||||
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. What is the higher level purpose of this test? From my perspective it's essentially testing that triggering a guard condition will wake up a wait set, but is the goal to do something specific to the graph guard condition? Reading #574, I don't think this test really addresses it, because it doesn't check that the graph guard condition is triggered by certain events, nor does it assert anything about behavior that utilizes the graph guard condition (e.g. the GraphListener in rclcpp). @ivanpauno perhaps you could explain what kind of test you were expecting from #574? 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.
Sorry, my description of the issue in #574 is a bit poor.
I think that the only existing test is this one.
I also don't see value in the test added here. 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 have edited #574 to make its purpose more clear. |
||||||
} | ||||||
|
||||||
/* Test the rcl_service_server_is_available function. | ||||||
*/ | ||||||
TEST_F(CLASSNAME(TestGraphFixture, RMW_IMPLEMENTATION), test_rcl_service_server_is_available) { | ||||||
|
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.