Skip to content

Commit

Permalink
Fix direct and indirect leaks in tests
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
bjosv committed Jan 12, 2024
1 parent 50d86c1 commit c5fb3ee
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/bp_gtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion src/gtest/bp_tunnel_gtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand All @@ -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);
}


Expand All @@ -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);
}


Expand Down Expand Up @@ -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");
}
}
6 changes: 6 additions & 0 deletions src/gtest/trex_stateless_gtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6382,6 +6382,7 @@ class TPGRxStatsTest : public TaggedPktGroupTest {

delete rx_tpg_port;
free(port_cntr);
delete tag_mgr;
}

void TestWithSomeErrors() {
Expand Down Expand Up @@ -6429,6 +6430,7 @@ class TPGRxStatsTest : public TaggedPktGroupTest {

delete rx_tpg_port;
free(port_cntr);
delete tag_mgr;
}

void TestUntagged() {
Expand Down Expand Up @@ -6474,6 +6476,7 @@ class TPGRxStatsTest : public TaggedPktGroupTest {

delete rx_tpg_port;
free(port_cntr);
delete tag_mgr;
}

void TestRxHandleValidTag(bool multicast) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/gtest/tuple_gen_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}


Expand Down

0 comments on commit c5fb3ee

Please sign in to comment.