Skip to content

Commit 29c3020

Browse files
Fix backport issue (#2581)
Signed-off-by: Barry Xu <[email protected]>
1 parent a1eea43 commit 29c3020

File tree

1 file changed

+24
-25
lines changed

1 file changed

+24
-25
lines changed

rclcpp/test/rclcpp/executors/test_executors.cpp

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,30 @@ TEST(TestExecutors, testSpinWithNonDefaultContext)
879879
rclcpp::shutdown(non_default_context);
880880
}
881881

882-
<<<<<<< HEAD
882+
TYPED_TEST(TestExecutors, release_ownership_entity_after_spinning_cancel)
883+
{
884+
using ExecutorType = TypeParam;
885+
ExecutorType executor;
886+
887+
auto future = std::async(std::launch::async, [&executor] {executor.spin();});
888+
889+
auto node = std::make_shared<rclcpp::Node>("test_node");
890+
auto callback = [](
891+
const test_msgs::srv::Empty::Request::SharedPtr, test_msgs::srv::Empty::Response::SharedPtr) {
892+
};
893+
auto server = node->create_service<test_msgs::srv::Empty>("test_service", callback);
894+
while (!executor.is_spinning()) {
895+
std::this_thread::sleep_for(50ms);
896+
}
897+
executor.add_node(node);
898+
std::this_thread::sleep_for(50ms);
899+
executor.cancel();
900+
std::future_status future_status = future.wait_for(1s);
901+
EXPECT_EQ(future_status, std::future_status::ready);
902+
903+
EXPECT_EQ(server.use_count(), 1);
904+
}
905+
883906
template<typename T>
884907
class TestBusyWaiting : public ::testing::Test
885908
{
@@ -1030,28 +1053,4 @@ TYPED_TEST(TestBusyWaiting, test_spin)
10301053
this->check_for_busy_waits(start_time);
10311054
// this should get the initial trigger, and the follow up from in the callback
10321055
ASSERT_EQ(this->waitable->get_count(), 2u);
1033-
=======
1034-
TYPED_TEST(TestExecutors, release_ownership_entity_after_spinning_cancel)
1035-
{
1036-
using ExecutorType = TypeParam;
1037-
ExecutorType executor;
1038-
1039-
auto future = std::async(std::launch::async, [&executor] {executor.spin();});
1040-
1041-
auto node = std::make_shared<rclcpp::Node>("test_node");
1042-
auto callback = [](
1043-
const test_msgs::srv::Empty::Request::SharedPtr, test_msgs::srv::Empty::Response::SharedPtr) {
1044-
};
1045-
auto server = node->create_service<test_msgs::srv::Empty>("test_service", callback);
1046-
while (!executor.is_spinning()) {
1047-
std::this_thread::sleep_for(50ms);
1048-
}
1049-
executor.add_node(node);
1050-
std::this_thread::sleep_for(50ms);
1051-
executor.cancel();
1052-
std::future_status future_status = future.wait_for(1s);
1053-
EXPECT_EQ(future_status, std::future_status::ready);
1054-
1055-
EXPECT_EQ(server.use_count(), 1);
1056-
>>>>>>> 069a0018 (Release ownership of entities after spinning cancelled (#2556))
10571056
}

0 commit comments

Comments
 (0)