Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions rclcpp/test/rclcpp/executors/test_executors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ to_nanoseconds_helper(DurationT duration)
// - works nominally (it can execute entities)
// - it can execute multiple items at once
// - it does not wait for work to be available before returning
TYPED_TEST(TestExecutors, spin_some)
TYPED_TEST(TestExecutors, spinSome)
{
using ExecutorType = TypeParam;

Expand Down Expand Up @@ -484,7 +484,7 @@ TYPED_TEST(TestExecutors, spin_some)
// do not properly implement max_duration (it seems), so disable this test
// for them in the meantime.
// see: https://github.com/ros2/rclcpp/issues/2462
TYPED_TEST(TestExecutorsStable, spin_some_max_duration)
TYPED_TEST(TestExecutorsStable, spinSomeMaxDuration)
{
using ExecutorType = TypeParam;

Expand Down Expand Up @@ -834,7 +834,7 @@ TEST(TestExecutors, testSpinWithNonDefaultContext)
rclcpp::shutdown(non_default_context);
}

TYPED_TEST(TestExecutors, release_ownership_entity_after_spinning_cancel)
TYPED_TEST(TestExecutors, releaseOwnershipEntityAfterSpinningCancel)
{
using ExecutorType = TypeParam;
ExecutorType executor;
Expand Down Expand Up @@ -870,19 +870,20 @@ TYPED_TEST(TestExecutors, testRaceDropCallbackGroupFromSecondThread)
}

// Create an executor
auto executor = std::make_shared<ExecutorType>();
executor->add_node(this->node);
ExecutorType executor;
executor.add_node(this->node);

// Start spinning
auto executor_thread = std::thread(
[executor]() {
executor->spin();
[&executor]() {
executor.spin();
});

// As the problem is a race, we do this multiple times,
// to raise our chances of hitting the problem
for(size_t i = 0; i < 10; i++) {
auto cg = this->node->create_callback_group(rclcpp::CallbackGroupType::MutuallyExclusive);
for (size_t i = 0; i < 10; i++) {
auto cg = this->node->create_callback_group(
rclcpp::CallbackGroupType::MutuallyExclusive);
auto timer = this->node->create_timer(1s, [] {}, cg);
// sleep a bit, so that the spin thread can pick up the callback group
// and add it to the executor
Expand All @@ -893,6 +894,6 @@ TYPED_TEST(TestExecutors, testRaceDropCallbackGroupFromSecondThread)
// If the executor has a race, we will experience a segfault at this point.
}

executor->cancel();
executor.cancel();
executor_thread.join();
}