Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sanitizer errors in testcases #1096

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
}
}
21 changes: 12 additions & 9 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 @@ -6524,7 +6527,7 @@ class TPGRxStatsTest : public TaggedPktGroupTest {
bcopy(test_pkt, p1, sizeof(test_pkt));
EXPECT_EQ(m1->pkt_len, sizeof(test_pkt));

uint8_t tmp_buf[sizeof(struct flow_stat_payload_header)];
uint8_t tmp_buf[sizeof(struct tpg_payload_header)];
struct tpg_payload_header* tpg_header = (tpg_payload_header*)
utl_rte_pktmbuf_get_last_bytes(m1, sizeof(struct tpg_payload_header), tmp_buf);

Expand All @@ -6533,8 +6536,6 @@ class TPGRxStatsTest : public TaggedPktGroupTest {

rx_tpg_port->handle_pkt(m1);

rte_pktmbuf_free(m1);

Json::Value stats;
rx_tpg_port->get_tpg_stats(stats, tpg_header->tpgid, 0, 1, false, false);

Expand All @@ -6554,6 +6555,8 @@ 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 @@ -6603,7 +6606,7 @@ class TPGRxStatsTest : public TaggedPktGroupTest {
bcopy(test_pkt, p1, sizeof(test_pkt));
EXPECT_EQ(m1->pkt_len, sizeof(test_pkt));

uint8_t tmp_buf[sizeof(struct flow_stat_payload_header)];
uint8_t tmp_buf[sizeof(struct tpg_payload_header)];
struct tpg_payload_header* tpg_header = (tpg_payload_header*)
utl_rte_pktmbuf_get_last_bytes(m1, sizeof(struct tpg_payload_header), tmp_buf);

Expand All @@ -6612,8 +6615,6 @@ class TPGRxStatsTest : public TaggedPktGroupTest {

rx_tpg_port->handle_pkt(m1);

rte_pktmbuf_free(m1);

// let's see the stats are successfully parsed

Json::Value stats;
Expand All @@ -6628,6 +6629,8 @@ class TPGRxStatsTest : public TaggedPktGroupTest {
exp.set_cntrs(1, sizeof(test_pkt) + 4, 0, 0, 0, 0, 0);
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 @@ -6674,7 +6677,7 @@ class TPGRxStatsTest : public TaggedPktGroupTest {
bcopy(test_pkt, p1, sizeof(test_pkt));
EXPECT_EQ(m1->pkt_len, sizeof(test_pkt));

uint8_t tmp_buf[sizeof(struct flow_stat_payload_header)];
uint8_t tmp_buf[sizeof(struct tpg_payload_header)];
struct tpg_payload_header* tpg_header = (tpg_payload_header*)
utl_rte_pktmbuf_get_last_bytes(m1, sizeof(struct tpg_payload_header), tmp_buf);

Expand All @@ -6683,8 +6686,6 @@ class TPGRxStatsTest : public TaggedPktGroupTest {

rx_tpg_port->handle_pkt(m1);

rte_pktmbuf_free(m1);

Json::Value stats;
rx_tpg_port->get_tpg_stats(stats, tpg_header->tpgid, 0, 1, true, true);

Expand All @@ -6705,6 +6706,8 @@ 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