From c5fb3eee8ccba420d01cd2ce9565ce26c2445493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Svensson?= Date: Fri, 12 Jan 2024 12:42:09 +0100 Subject: [PATCH] Fix direct and indirect leaks in tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed a couple of testcases that triggered errors by the leak sanitizer. All issues are due to missing actions in the testcases. There are still 2 testcase left that are expected to leak: gt_astf_inter.astf_negative_2 gt_astf_inter.astf_negative_3 so testruns needs to filter out these using: ./bp-sim-64 --ut --gtest_filter='-*.astf_negative*' Signed-off-by: Björn Svensson --- src/bp_gtest.cpp | 1 + src/gtest/bp_tunnel_gtest.cpp | 5 ++++- src/gtest/trex_stateless_gtest.cpp | 6 ++++++ src/gtest/tuple_gen_test.cpp | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/bp_gtest.cpp b/src/bp_gtest.cpp index 6b40d5b3ad..29bd483766 100755 --- a/src/bp_gtest.cpp +++ b/src/bp_gtest.cpp @@ -2884,6 +2884,7 @@ TEST_F(gt_ring, ring1) { uint32_t *p; assert(my.Dequeue(p)==0); EXPECT_EQ_UINT32(*p, i); + delete p; } uint32_t *p; assert(my.Dequeue(p)!=0); diff --git a/src/gtest/bp_tunnel_gtest.cpp b/src/gtest/bp_tunnel_gtest.cpp index 9448776b50..90ecb324fe 100644 --- a/src/gtest/bp_tunnel_gtest.cpp +++ b/src/gtest/bp_tunnel_gtest.cpp @@ -43,6 +43,7 @@ void prepend_ipv4_and_compare(char *buf, uint16_t len, uint32_t teid, uint16_t s CGtpuMan gtpu(TUNNEL_MODE_TX); gtpu.on_tx(0, m); create_pcap_and_compare(m, pcap_file); + rte_pktmbuf_free(m); } @@ -56,6 +57,7 @@ void prepend_ipv6_and_compare(char *buf, uint16_t len, uint32_t teid, uint16_t s CGtpuMan gtpu(TUNNEL_MODE_TX); gtpu.on_tx(0, m); create_pcap_and_compare(m, pcap_file); + rte_pktmbuf_free(m); } @@ -64,6 +66,7 @@ void adjust_and_compare(char *buf, uint16_t len, std::string pcap_file) { CGtpuMan gtpu(TUNNEL_MODE_RX); gtpu.on_rx(0, m); create_pcap_and_compare(m, pcap_file); + rte_pktmbuf_free(m); } @@ -270,4 +273,4 @@ TEST_F(gt_tunnel, tst16) { 0x00, 0x00, 0x02, 0x04, 0x05, 0xB4, 0x01, 0x03, 0x03, 0x00, 0x01, 0x01, 0x08, 0x0A, 0x6B, 0x8B, 0x45, 0xF2, 0x00, 0x00, 0x00, 0x00}; adjust_and_compare((char *)buf, sizeof(buf), "tunnel_adjust_ipv6_with_vlan_ipv4.pcap"); -} \ No newline at end of file +} diff --git a/src/gtest/trex_stateless_gtest.cpp b/src/gtest/trex_stateless_gtest.cpp index 5fcd4af173..b796a2ca9c 100644 --- a/src/gtest/trex_stateless_gtest.cpp +++ b/src/gtest/trex_stateless_gtest.cpp @@ -6382,6 +6382,7 @@ class TPGRxStatsTest : public TaggedPktGroupTest { delete rx_tpg_port; free(port_cntr); + delete tag_mgr; } void TestWithSomeErrors() { @@ -6429,6 +6430,7 @@ class TPGRxStatsTest : public TaggedPktGroupTest { delete rx_tpg_port; free(port_cntr); + delete tag_mgr; } void TestUntagged() { @@ -6474,6 +6476,7 @@ class TPGRxStatsTest : public TaggedPktGroupTest { delete rx_tpg_port; free(port_cntr); + delete tag_mgr; } void TestRxHandleValidTag(bool multicast) { @@ -6553,6 +6556,7 @@ class TPGRxStatsTest : public TaggedPktGroupTest { VALIDATE_STATS_JSON(tag_stats, &exp); rte_pktmbuf_free(m1); + utl_rte_mempool_delete(mp1); delete rx_tpg_port; free(port_cntr); delete tag_mgr; @@ -6626,6 +6630,7 @@ class TPGRxStatsTest : public TaggedPktGroupTest { VALIDATE_STATS_JSON(unknown_stats, &exp); rte_pktmbuf_free(m1); + utl_rte_mempool_delete(mp1); delete rx_tpg_port; free(port_cntr); delete tag_mgr; @@ -6702,6 +6707,7 @@ class TPGRxStatsTest : public TaggedPktGroupTest { VALIDATE_STATS_JSON(untagged, &exp); rte_pktmbuf_free(m1); + utl_rte_mempool_delete(mp1); delete rx_tpg_port; free(port_cntr); delete tag_mgr; diff --git a/src/gtest/tuple_gen_test.cpp b/src/gtest/tuple_gen_test.cpp index c710f4b97f..ba73832f87 100755 --- a/src/gtest/tuple_gen_test.cpp +++ b/src/gtest/tuple_gen_test.cpp @@ -562,6 +562,7 @@ TEST(tuple_gen_2,GenerateTuple2) { EXPECT_EQ(result_src, (uint32_t)(0x10000001+i%15)); EXPECT_EQ(result_dest, (uint32_t) (((0x30000001+i)) ) ); } + gen.Delete(); }