Skip to content
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 for notify guard condition in node #112

Merged
merged 3 commits into from
Apr 5, 2016

Conversation

jacquelinekay
Copy link
Contributor

Connects to ros2/rclcpp#209

@jacquelinekay jacquelinekay added the in progress Actively being worked on (Kanban column) label Mar 17, 2016
@jacquelinekay
Copy link
Contributor Author

I find this test is currently flaky for Connext but no other platform. Looking into it.

timer.cancel();
});

spin_thread.join();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it's worth changing this test, but for the future you might consider using a future here rather than the timer_triggered boolean. Something like this:

std::thread spin_thread(executor_spin_lambda);
std::promise<void> timer_triggered_promise;
std::shared_future<void> timer_triggered_future(timer_triggered_promise.get_future());
auto timer = node->create_wall_timer(
  1_ms,
  [&executor, &timer_triggered_promise](rclcpp::TimerBase & timer)
{
  timer_triggered_promise.set_value();
  timer.cancel();
});

EXPECT_EQ(std::future_status::ready, timer_triggered_future.wait_for(100_ms));
executor.cancel();
spin_thread.join();

The advantage of this approach is that if the timer fails to trigger the test doesn't just hang, but instead it fails an expected check and the test can continue to try other things. Currently the only way this test fails is if the test timeout kills the test.

@jacquelinekay
Copy link
Contributor Author

The test was flaky on Connext; I added a busy_wait_for_subscriber and decided to put it in its own file to share it between multiple tests: 35720ea

@jacquelinekay jacquelinekay merged commit ad0dde5 into master Apr 5, 2016
@jacquelinekay jacquelinekay removed the in progress Actively being worked on (Kanban column) label Apr 5, 2016
@jacquelinekay jacquelinekay deleted the fixed_guard_conditions branch June 14, 2016 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants