From bd697f2f472290be69ee806557a208efccb20672 Mon Sep 17 00:00:00 2001 From: jparisu Date: Fri, 7 Oct 2022 13:11:36 +0200 Subject: [PATCH 1/2] Fix ASAN errors for non deleting entities in tests Signed-off-by: jparisu --- .../test/unittest/efficiency/FastPayloadPoolTest.cpp | 9 +++++++++ .../test/unittest/efficiency/MapPayloadPoolTest.cpp | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/ddsrouter_core/test/unittest/efficiency/FastPayloadPoolTest.cpp b/ddsrouter_core/test/unittest/efficiency/FastPayloadPoolTest.cpp index 94bcf9522..97c80ab56 100644 --- a/ddsrouter_core/test/unittest/efficiency/FastPayloadPoolTest.cpp +++ b/ddsrouter_core/test/unittest/efficiency/FastPayloadPoolTest.cpp @@ -174,6 +174,8 @@ TEST(FastPayloadPoolTest, get_payload_from_src) // Check payload pool is empty ASSERT_TRUE(pool_->is_clean()); ASSERT_EQ(pool_->pointers_stored(), 0); + + delete pool; } /** @@ -214,6 +216,9 @@ TEST(FastPayloadPoolTest, get_payload_from_src_no_owner) // release payload pool_->release_payload(payload_target); ASSERT_EQ(pool_->pointers_stored(), 0); + + delete pool_aux; + delete pool; } /** @@ -238,6 +243,8 @@ TEST(FastPayloadPoolTest, get_payload_from_src_negative) payload_src, pool_aux, payload_target)); + + delete pool; } } @@ -290,6 +297,8 @@ TEST(FastPayloadPoolTest, release_payload) // Check payload pool is empty ASSERT_TRUE(pool_->is_clean()); ASSERT_EQ(pool_->pointers_stored(), 0); + + delete pool; } /** diff --git a/ddsrouter_core/test/unittest/efficiency/MapPayloadPoolTest.cpp b/ddsrouter_core/test/unittest/efficiency/MapPayloadPoolTest.cpp index 00db8764f..651a459de 100644 --- a/ddsrouter_core/test/unittest/efficiency/MapPayloadPoolTest.cpp +++ b/ddsrouter_core/test/unittest/efficiency/MapPayloadPoolTest.cpp @@ -190,6 +190,8 @@ TEST(MapPayloadPoolTest, get_payload_from_src) // Check payload pool is empty ASSERT_TRUE(pool_->is_clean()); ASSERT_EQ(pool_->pointers_stored(), 0); + + delete pool; } /** @@ -230,6 +232,9 @@ TEST(MapPayloadPoolTest, get_payload_from_src_no_owner) // release payload pool_->release_payload(payload_target); ASSERT_EQ(pool_->pointers_stored(), 0); + + delete pool_aux; + delete pool; } /** @@ -258,6 +263,8 @@ TEST(MapPayloadPoolTest, get_payload_from_src_negative) // END : release payload pool_aux.release_payload(payload_src); + + delete pool; } // Source has size 0 and different owner @@ -274,6 +281,8 @@ TEST(MapPayloadPoolTest, get_payload_from_src_negative) payload_src, pool_aux, payload_target)); + + delete pool; } } @@ -330,6 +339,8 @@ TEST(MapPayloadPoolTest, release_payload) // Check payload pool is empty ASSERT_TRUE(pool_->is_clean()); ASSERT_EQ(pool_->pointers_stored(), 0); + + delete pool; } /** From 8da665e325e298164efc8caa9b703b2dcb7de2d0 Mon Sep 17 00:00:00 2001 From: jparisu Date: Mon, 10 Oct 2022 08:04:41 +0200 Subject: [PATCH 2/2] Fix uninitilized value in test Signed-off-by: jparisu --- ddsrouter_core/test/unittest/efficiency/FastPayloadPoolTest.cpp | 2 +- ddsrouter_core/test/unittest/efficiency/MapPayloadPoolTest.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ddsrouter_core/test/unittest/efficiency/FastPayloadPoolTest.cpp b/ddsrouter_core/test/unittest/efficiency/FastPayloadPoolTest.cpp index 97c80ab56..697af570f 100644 --- a/ddsrouter_core/test/unittest/efficiency/FastPayloadPoolTest.cpp +++ b/ddsrouter_core/test/unittest/efficiency/FastPayloadPoolTest.cpp @@ -233,7 +233,7 @@ TEST(FastPayloadPoolTest, get_payload_from_src_negative) { eprosima::fastrtps::rtps::IPayloadPool* pool = new test::MockFastPayloadPool(); // Requires to be ptr to pass it to get_payload test::MockFastPayloadPool* pool_ = static_cast(pool); - eprosima::fastrtps::rtps::IPayloadPool* pool_aux; // nullptr + eprosima::fastrtps::rtps::IPayloadPool* pool_aux = nullptr; // nullptr Payload payload_src; Payload payload_target; diff --git a/ddsrouter_core/test/unittest/efficiency/MapPayloadPoolTest.cpp b/ddsrouter_core/test/unittest/efficiency/MapPayloadPoolTest.cpp index 651a459de..dcbad4f62 100644 --- a/ddsrouter_core/test/unittest/efficiency/MapPayloadPoolTest.cpp +++ b/ddsrouter_core/test/unittest/efficiency/MapPayloadPoolTest.cpp @@ -271,7 +271,7 @@ TEST(MapPayloadPoolTest, get_payload_from_src_negative) { eprosima::fastrtps::rtps::IPayloadPool* pool = new test::MockMapPayloadPool(); // Requires to be ptr to pass it to get_payload test::MockMapPayloadPool* pool_ = static_cast(pool); - eprosima::fastrtps::rtps::IPayloadPool* pool_aux; // nullptr + eprosima::fastrtps::rtps::IPayloadPool* pool_aux = nullptr; // nullptr Payload payload_src; Payload payload_target;