|
39 | 39 | #include "rclcpp/time_source.hpp" |
40 | 40 |
|
41 | 41 | #include "test_msgs/msg/empty.hpp" |
| 42 | +#include "test_msgs/srv/empty.hpp" |
42 | 43 |
|
43 | 44 | #include "./executor_types.hpp" |
44 | 45 |
|
@@ -878,6 +879,7 @@ TEST(TestExecutors, testSpinWithNonDefaultContext) |
878 | 879 | rclcpp::shutdown(non_default_context); |
879 | 880 | } |
880 | 881 |
|
| 882 | +<<<<<<< HEAD |
881 | 883 | template<typename T> |
882 | 884 | class TestBusyWaiting : public ::testing::Test |
883 | 885 | { |
@@ -1028,4 +1030,28 @@ TYPED_TEST(TestBusyWaiting, test_spin) |
1028 | 1030 | this->check_for_busy_waits(start_time); |
1029 | 1031 | // this should get the initial trigger, and the follow up from in the callback |
1030 | 1032 | 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)) |
1031 | 1057 | } |
0 commit comments