Compare commits

...

1 Commits

Author SHA1 Message Date
Tomoya Fujita
0047a550a8 clear handles before node destruction in test_memory_strategy.
Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
2025-10-20 15:11:32 +09:00

View File

@@ -129,6 +129,8 @@ TEST_F(TestMemoryStrategy, get_subscription_by_handle) {
EXPECT_EQ(
nullptr,
memory_strategy()->get_subscription_by_handle(subscription_handle, weak_groups_to_nodes));
// Clear all handles to cleanup when node is destroyed
memory_strategy()->clear_handles();
} // Node goes out of scope
EXPECT_EQ(
nullptr,
@@ -181,6 +183,8 @@ TEST_F(TestMemoryStrategy, get_service_by_handle) {
EXPECT_EQ(
nullptr,
memory_strategy()->get_service_by_handle(service_handle, weak_groups_to_nodes));
// Clear all handles to cleanup when node is destroyed
memory_strategy()->clear_handles();
} // Node goes out of scope
EXPECT_EQ(
nullptr,
@@ -228,6 +232,11 @@ TEST_F(TestMemoryStrategy, get_client_by_handle) {
EXPECT_EQ(
nullptr,
memory_strategy()->get_client_by_handle(client_handle, weak_groups_to_nodes));
// Clear all handles to cleanup when node is destroyed
memory_strategy()->clear_handles();
// reset client handle before node destruction, otherwise it tries to access node
// via weak_ptr in its deleter
client_handle.reset();
} // Node goes out of scope
EXPECT_EQ(
nullptr,
@@ -276,6 +285,8 @@ TEST_F(TestMemoryStrategy, get_timer_by_handle) {
EXPECT_EQ(
nullptr,
memory_strategy()->get_timer_by_handle(timer_handle, weak_groups_to_nodes));
// Clear all handles to cleanup when node is destroyed
memory_strategy()->clear_handles();
} // Node goes out of scope
EXPECT_EQ(
nullptr,
@@ -375,6 +386,8 @@ TEST_F(TestMemoryStrategy, get_group_by_subscription) {
EXPECT_EQ(
callback_group,
memory_strategy()->get_group_by_subscription(subscription, weak_groups_to_nodes));
// Clear all handles to cleanup when node is destroyed
memory_strategy()->clear_handles();
} // Node goes out of scope
// NodeBase(SubscriptionBase->rcl_node_t->NodeBase) is still alive.
EXPECT_EQ(
@@ -420,6 +433,8 @@ TEST_F(TestMemoryStrategy, get_group_by_service) {
EXPECT_EQ(
nullptr,
memory_strategy()->get_group_by_service(service, weak_groups_to_nodes));
// Clear all handles to cleanup when node is destroyed
memory_strategy()->clear_handles();
} // Node goes out of scope
EXPECT_EQ(
nullptr,
@@ -459,6 +474,8 @@ TEST_F(TestMemoryStrategy, get_group_by_client) {
EXPECT_EQ(
nullptr,
memory_strategy()->get_group_by_client(client, weak_groups_to_nodes));
// Clear all handles to cleanup when node is destroyed
memory_strategy()->clear_handles();
} // Node goes out of scope
EXPECT_EQ(
nullptr,
@@ -498,6 +515,8 @@ TEST_F(TestMemoryStrategy, get_group_by_timer) {
EXPECT_EQ(
nullptr,
memory_strategy()->get_group_by_timer(timer, weak_groups_to_nodes));
// Clear all handles to cleanup when node is destroyed
memory_strategy()->clear_handles();
} // Node goes out of scope
EXPECT_EQ(
nullptr,
@@ -536,6 +555,8 @@ TEST_F(TestMemoryStrategy, get_group_by_waitable) {
EXPECT_EQ(
nullptr,
memory_strategy()->get_group_by_waitable(waitable, weak_groups_to_nodes));
// Clear all handles to cleanup when node is destroyed
memory_strategy()->clear_handles();
} // Node goes out of scope
EXPECT_EQ(
nullptr,