summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIdo Barnea <ibarnea@cisco.com>2017-01-10 19:04:51 +0200
committerIdo Barnea <ibarnea@cisco.com>2017-01-10 19:04:51 +0200
commitcf0b463e9f2aa5313550a28be03efa1843723959 (patch)
tree83e875c07aac3ce3ff8df67602b617aaa5fe39dd /src
parentb3c544bd3d3e150660774d4588419e75058bdf97 (diff)
Make bpsim unit tests independant of each other (will always pass, without regard to running order)
Signed-off-by: Ido Barnea <ibarnea@cisco.com>
Diffstat (limited to 'src')
-rwxr-xr-xsrc/bp_gtest.cpp373
-rw-r--r--src/bp_gtest.h10
2 files changed, 152 insertions, 231 deletions
diff --git a/src/bp_gtest.cpp b/src/bp_gtest.cpp
index be601957..57cf2ffa 100755
--- a/src/bp_gtest.cpp
+++ b/src/bp_gtest.cpp
@@ -20,6 +20,7 @@ limitations under the License.
*/
#include "bp_sim.h"
+#include <stdlib.h>
#include <common/gtest.h>
#include <common/basic_utils.h>
#include "utl_cpuu.h"
@@ -71,9 +72,9 @@ int test_priorty_queue(void){
for (i=0; i<10; i++) {
node = new CGenNode();
printf(" +%p \n",node);
- node->m_flow_id = 10-i;
- node->m_pkt_info = (CFlowPktInfo *)(uintptr_t)i;
- node->m_time = (double)i+0.1;
+ node->m_flow_id = 10-i;
+ node->m_pkt_info = (CFlowPktInfo *)(uintptr_t)i;
+ node->m_time = (double)i+0.1;
p_queue.push(node);
}
while (!p_queue.empty()) {
@@ -114,25 +115,8 @@ int test_human_p(){
return (0);
}
-class basic : public testing::Test {
- protected:
- virtual void SetUp() {
- }
- virtual void TearDown() {
- }
-public:
-};
-
-class cpu : public testing::Test {
- protected:
- virtual void SetUp() {
- }
- virtual void TearDown() {
- }
-public:
-};
-
-
+class basic : public trexTest {};
+class cpu : public trexTest {};
TEST_F(basic, limit_single_pkt) {
@@ -156,7 +140,7 @@ TEST_F(basic, limit_multi_pkt) {
po->out_file ="exp/limit_multi_pkt";
bool res=t1.init();
EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
-}
+}
TEST_F(basic, imix) {
@@ -273,7 +257,6 @@ TEST_F(basic, dns_ipv6) {
bool res=t1.init();
EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
EXPECT_EQ_UINT32(t1.get_padd_offset_first_packet(),0);
- po->preview.set_ipv6_mode_enable(false);
}
TEST_F(basic, dns_json) {
@@ -445,7 +428,6 @@ TEST_F(basic, ipv6_convert) {
po->out_file ="exp/imix_v6";
bool res=t1.init();
EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
- po->preview.set_ipv6_mode_enable(false);
}
TEST_F(basic, ipv6) {
@@ -459,7 +441,6 @@ TEST_F(basic, ipv6) {
po->out_file ="exp/ipv6";
bool res=t1.init();
EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
- po->preview.set_ipv6_mode_enable(false);
}
TEST_F(basic, ipv4_vlan) {
@@ -485,7 +466,6 @@ TEST_F(basic, ipv6_vlan) {
po->out_file ="exp/ipv6_vlan";
bool res=t1.init();
EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
- po->preview.set_ipv6_mode_enable(false);
}
@@ -498,7 +478,7 @@ TEST_F(basic, test_pcap_mode1) {
po->preview.setFileWrite(true);
po->cfg_file ="cap2/test_pcap_mode1.yaml";
po->out_file ="exp/pcap_mode1";
- t1.m_time_diff = 0.000005; // 5 nsec
+ t1.m_time_diff = 0.000005; // 5 nsec
bool res=t1.init();
EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
}
@@ -512,7 +492,7 @@ TEST_F(basic, test_pcap_mode2) {
po->preview.setFileWrite(true);
po->cfg_file ="cap2/test_pcap_mode2.yaml";
po->out_file ="exp/pcap_mode2";
- t1.m_time_diff = 0.000005; // 5 nsec
+ t1.m_time_diff = 0.000005; // 5 nsec
bool res=t1.init();
EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
}
@@ -565,10 +545,10 @@ bool
verify_latency_pkt(uint8_t *p, uint8_t proto, uint16_t icmp_seq, uint8_t icmp_type) {
EthernetHeader *eth = (EthernetHeader *)p;
IPHeader *ip = (IPHeader *)(p + 14);
- uint8_t srcmac[]={0x10,0x10,0x10,0x10,0x10,0x10};
+ uint8_t srcmac[]={0x10,0x10,0x10,0x10,0x10,0x10};
//uint8_t dstmac[]={0x0,0x0,0x0,0x0,0x0,0x0};
latency_header * h;
-
+
// eth
EXPECT_EQ_UINT32(eth->getNextProtocol(), 0x0800)<< "Failed ethernet next protocol check";
EXPECT_EQ_UINT32(memcmp(p, srcmac, 6), 0)<< "Failed ethernet source MAC check";
@@ -580,7 +560,7 @@ verify_latency_pkt(uint8_t *p, uint8_t proto, uint16_t icmp_seq, uint8_t icmp_ty
EXPECT_EQ_UINT32(ip->isChecksumOK()?0:1, 0)<< "Failed IP checksum check";
EXPECT_EQ_UINT32(ip->getTimeToLive(), 0xff)<< "Failed IP ttl check";
EXPECT_EQ_UINT32(ip->getTotalLength(), 48)<< "Failed IP total length check";
-
+
// payload
h=(latency_header *)(p+42);
EXPECT_EQ_UINT32(h->magic, LATENCY_MAGIC)<< "Failed latency magic check";
@@ -721,7 +701,7 @@ public:
virtual int tx_latency(rte_mbuf_t *m) {
return tx(m);
}
-
+
virtual rte_mbuf_t * rx(){
//printf(" rx on port %d \n",m_port_id);
rte_mbuf_t * m=0;
@@ -736,7 +716,7 @@ public:
return ( m );
}
- virtual uint16_t rx_burst(struct rte_mbuf **rx_pkts,
+ virtual uint16_t rx_burst(struct rte_mbuf **rx_pkts,
uint16_t nb_pkts){
//printf(" rx on port %d \n",m_port_id);
rte_mbuf_t * m=rx();
@@ -818,7 +798,7 @@ TEST_F(basic, rtsp1) {
po->out_file ="exp/rtsp_short1";
bool res=t1.init();
EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
-}
+}
TEST_F(basic, rtsp2) {
@@ -830,7 +810,7 @@ TEST_F(basic, rtsp2) {
po->out_file ="exp/rtsp_short2";
bool res=t1.init();
EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
-}
+}
TEST_F(basic, rtsp3) {
@@ -843,7 +823,7 @@ TEST_F(basic, rtsp3) {
t1.m_req_ports = 32000;
bool res=t1.init();
EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
-}
+}
TEST_F(basic, rtsp1_ipv6) {
@@ -857,8 +837,7 @@ TEST_F(basic, rtsp1_ipv6) {
po->out_file ="exp/rtsp_short1_v6";
bool res=t1.init();
EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
- po->preview.set_ipv6_mode_enable(false);
-}
+}
TEST_F(basic, rtsp2_ipv6) {
@@ -871,8 +850,7 @@ TEST_F(basic, rtsp2_ipv6) {
po->out_file ="exp/rtsp_short2_v6";
bool res=t1.init();
EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
- po->preview.set_ipv6_mode_enable(false);
-}
+}
TEST_F(basic, rtsp3_ipv6) {
@@ -886,8 +864,7 @@ TEST_F(basic, rtsp3_ipv6) {
t1.m_req_ports = 32000;
bool res=t1.init();
EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
- po->preview.set_ipv6_mode_enable(false);
-}
+}
TEST_F(basic, sip1) {
@@ -900,7 +877,7 @@ TEST_F(basic, sip1) {
po->out_file ="exp/sip_short1";
bool res=t1.init();
EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
-}
+}
TEST_F(basic, sip2) {
@@ -913,7 +890,7 @@ TEST_F(basic, sip2) {
po->out_file ="exp/sip_short2";
bool res=t1.init();
EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
-}
+}
TEST_F(basic, sip3) {
@@ -926,7 +903,7 @@ TEST_F(basic, sip3) {
t1.m_req_ports = 32000;
bool res=t1.init();
EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
-}
+}
TEST_F(basic, sip1_ipv6) {
@@ -940,8 +917,7 @@ TEST_F(basic, sip1_ipv6) {
po->out_file ="exp/sip_short1_v6";
bool res=t1.init();
EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
- po->preview.set_ipv6_mode_enable(false);
-}
+}
TEST_F(basic, sip2_ipv6) {
@@ -955,8 +931,7 @@ TEST_F(basic, sip2_ipv6) {
po->out_file ="exp/sip_short2_v6";
bool res=t1.init();
EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
- po->preview.set_ipv6_mode_enable(false);
-}
+}
TEST_F(basic, sip3_ipv6) {
@@ -970,21 +945,21 @@ TEST_F(basic, sip3_ipv6) {
t1.m_req_ports = 32000;
bool res=t1.init();
EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
- po->preview.set_ipv6_mode_enable(false);
-}
+}
TEST_F(basic, dyn1) {
CTestBasic t1;
CParserOption * po =&CGlobalInfo::m_options;
+ srand(1);
po->preview.setVMode(3);
po->preview.setFileWrite(true);
po->cfg_file ="cap2/dyn_pyld1.yaml";
po->out_file ="exp/dyn_pyld1";
bool res=t1.init();
EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
-}
+}
TEST_F(basic, http1) {
@@ -996,7 +971,7 @@ TEST_F(basic, http1) {
po->out_file ="exp/http_plugin";
bool res=t1.init();
EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
-}
+}
TEST_F(basic, http1_ipv6) {
@@ -1009,8 +984,7 @@ TEST_F(basic, http1_ipv6) {
po->out_file ="exp/http_plugin_v6";
bool res=t1.init();
EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
- po->preview.set_ipv6_mode_enable(false);
-}
+}
@@ -1077,7 +1051,7 @@ TEST_F(cpu, cpu3) {
printf(" cpu %2.0f \n",c1);
int s=( c1<11 && c1>8)?1:0;
EXPECT_EQ(s,1);
- }
+ }
delay(1);
if ((i%10)==1) {
cpu_dp.commit();
@@ -1089,35 +1063,25 @@ TEST_F(cpu, cpu3) {
}
#endif
-
-class timerwl : public testing::Test {
- protected:
- virtual void SetUp() {
- }
- virtual void TearDown() {
- }
-public:
-};
-
-
+class timerwl : public trexTest {};
void flow_callback(CFlowTimerHandle * timer_handle);
class CTestFlow {
public:
- CTestFlow(){
- flow_id = 0;
+ CTestFlow(){
+ flow_id = 0;
m_timer_handle.m_callback=flow_callback;
- m_timer_handle.m_object = (void *)this;
- m_timer_handle.m_id = 0x1234;
- }
+ m_timer_handle.m_object = (void *)this;
+ m_timer_handle.m_id = 0x1234;
+ }
- uint32_t flow_id;
- CFlowTimerHandle m_timer_handle;
+ uint32_t flow_id;
+ CFlowTimerHandle m_timer_handle;
public:
- void OnTimeOut(){
+ void OnTimeOut(){
printf(" timeout %d \n",flow_id);
- }
+ }
};
void flow_callback(CFlowTimerHandle * t){
@@ -1267,7 +1231,7 @@ TEST_F(timerwl, many_timers) {
CTimerWheel my_tw;
- int i;
+ int i;
for (i=0; i<100; i++) {
CTestFlow * f= new CTestFlow();
f->m_timer_handle.m_callback=many_timers_flow_callback;
@@ -1276,17 +1240,17 @@ TEST_F(timerwl, many_timers) {
}
many_timers_flow_id=99;
- double time;
+ double time;
double ex_time=1.0;
while (true) {
if ( my_tw.peek_top_time(time) ){
assert(time==ex_time);
ex_time+=1.0;
assert(my_tw.handle());
- }
- else{
- break;
- }
+ }
+ else{
+ break;
+ }
}
my_tw.Dump(stdout);
@@ -1295,7 +1259,7 @@ TEST_F(timerwl, many_timers) {
EXPECT_EQ(my_tw.m_st_alloc ,100);
EXPECT_EQ(my_tw.m_st_free ,100);
EXPECT_EQ(my_tw.m_st_start ,100);
-
+
}
void many_timers_stop_flow_callback(CFlowTimerHandle * t){
@@ -1338,13 +1302,12 @@ TEST_F(timerwl, many_timers_with_stop) {
EXPECT_EQ(my_tw.m_st_start ,300);
}
-
//////////////////////////////////////////////
-class rx_check : public testing::Test {
+class rx_check : public trexTest {
protected:
virtual void SetUp() {
+ trexTest::SetUp();
m_rx_check.Create();
-
}
virtual void TearDown() {
m_rx_check.Delete();
@@ -1422,100 +1385,100 @@ TEST_F(rx_check, rx_check_drop) {
TEST_F(rx_check, rx_check_ooo) {
- m_rx_check.Create();
- int i;
+ m_rx_check.Create();
+ int i;
- for (i=0; i<10; i++) {
- CRx_check_header rxh;
+ for (i=0; i<10; i++) {
+ CRx_check_header rxh;
rxh.clean();
rxh.m_option_type=RX_CHECK_V4_OPT_TYPE;
rxh.m_option_len=RX_CHECK_V4_OPT_LEN;
- rxh.m_time_stamp=0;
- rxh.m_magic=RX_CHECK_MAGIC;
+ rxh.m_time_stamp=0;
+ rxh.m_magic=RX_CHECK_MAGIC;
rxh.m_aging_sec=10;
rxh.set_dir(0);
rxh.set_both_dir(0);
- /* out of order */
- if (i==4) {
- rxh.m_pkt_id=5;
- }else{
- if (i==5) {
- rxh.m_pkt_id=4;
- }else{
- rxh.m_pkt_id=i;
- }
- }
+ /* out of order */
+ if (i==4) {
+ rxh.m_pkt_id=5;
+ }else{
+ if (i==5) {
+ rxh.m_pkt_id=4;
+ }else{
+ rxh.m_pkt_id=i;
+ }
+ }
- rxh.m_flow_size=10;
+ rxh.m_flow_size=10;
- rxh.m_flow_id=7;
+ rxh.m_flow_id=7;
- rxh.m_flags=0;
+ rxh.m_flags=0;
m_rx_check.handle_packet(&rxh);
- }
- m_rx_check.tw_drain();
+ }
+ m_rx_check.tw_drain();
EXPECT_EQ(m_rx_check.m_stats.m_err_oo_early,1);
EXPECT_EQ(m_rx_check.m_stats.m_err_oo_late,2);
- m_rx_check.Dump(stdout);
+ m_rx_check.Dump(stdout);
}
TEST_F(rx_check, rx_check_ooo_1) {
- int i;
+ int i;
- for (i=0; i<10; i++) {
- CRx_check_header rxh;
+ for (i=0; i<10; i++) {
+ CRx_check_header rxh;
rxh.clean();
rxh.m_option_type=RX_CHECK_V4_OPT_TYPE;
rxh.m_option_len=RX_CHECK_V4_OPT_LEN;
- rxh.m_time_stamp=0;
+ rxh.m_time_stamp=0;
rxh.set_dir(0);
rxh.set_both_dir(0);
- rxh.m_magic=RX_CHECK_MAGIC;
+ rxh.m_magic=RX_CHECK_MAGIC;
rxh.m_aging_sec=10;
- /* out of order */
- if (i==4) {
- rxh.m_pkt_id=56565;
- }else{
- if (i==5) {
- rxh.m_pkt_id=4;
- }else{
- rxh.m_pkt_id=i;
- }
- }
- rxh.m_flow_size=10;
- rxh.m_flow_id=7;
- rxh.m_flags=0;
- m_rx_check.handle_packet(&rxh);
- }
- m_rx_check.tw_drain();
+ /* out of order */
+ if (i==4) {
+ rxh.m_pkt_id=56565;
+ }else{
+ if (i==5) {
+ rxh.m_pkt_id=4;
+ }else{
+ rxh.m_pkt_id=i;
+ }
+ }
+ rxh.m_flow_size=10;
+ rxh.m_flow_id=7;
+ rxh.m_flags=0;
+ m_rx_check.handle_packet(&rxh);
+ }
+ m_rx_check.tw_drain();
EXPECT_EQ(m_rx_check.m_stats.m_err_wrong_pkt_id,1);
EXPECT_EQ(m_rx_check.m_stats.m_err_oo_late,1);
- m_rx_check.Dump(stdout);
+ m_rx_check.Dump(stdout);
}
// start without first packet ( not FIF */
TEST_F(rx_check, rx_check_ooo_2) {
- int i;
+ int i;
- for (i=0; i<10; i++) {
- CRx_check_header rxh;
+ for (i=0; i<10; i++) {
+ CRx_check_header rxh;
rxh.clean();
rxh.m_option_type=RX_CHECK_V4_OPT_TYPE;
rxh.m_option_len=RX_CHECK_V4_OPT_LEN;
- rxh.m_time_stamp=0;
- rxh.m_magic=RX_CHECK_MAGIC;
+ rxh.m_time_stamp=0;
+ rxh.m_magic=RX_CHECK_MAGIC;
rxh.m_aging_sec=10;
- /* out of order */
+ /* out of order */
rxh.set_dir(0);
rxh.set_both_dir(0);
@@ -1530,15 +1493,15 @@ TEST_F(rx_check, rx_check_ooo_2) {
}
}
- rxh.m_flow_size=10;
- rxh.m_flow_id=7;
- rxh.m_flags=0;
- m_rx_check.handle_packet(&rxh);
- }
- m_rx_check.tw_drain();
+ rxh.m_flow_size=10;
+ rxh.m_flow_id=7;
+ rxh.m_flags=0;
+ m_rx_check.handle_packet(&rxh);
+ }
+ m_rx_check.tw_drain();
EXPECT_EQ(m_rx_check.m_stats.m_err_open_with_no_fif_pkt,1);
EXPECT_EQ(m_rx_check.m_stats. m_err_oo_late,1);
- m_rx_check.Dump(stdout);
+ m_rx_check.Dump(stdout);
}
@@ -1880,9 +1843,8 @@ TEST_F(rx_check, rx_check_normal_no_aging) {
EXPECT_EQ(m_rx_check.m_stats.m_remove,0);
}
-
///////////////////////////////////////////////////////////////
-// check the generation of template and check sample of it
+// check the generation of template and check sample of it
class CRxCheckCallbackBase {
@@ -1918,10 +1880,10 @@ public:
/**
* send one packet
- *
+ *
* @param node
- *
- * @return
+ *
+ * @return
*/
virtual int send_node(CGenNode * node);
@@ -1932,9 +1894,9 @@ public:
/**
- * flush all pending packets into the stream
- *
- * @return
+ * flush all pending packets into the stream
+ *
+ * @return
*/
virtual int flush_tx_queue(void){
return (0);
@@ -1969,16 +1931,16 @@ int CRxCheckIF::send_node(CGenNode * node){
m_raw->time_nsec = t_c.m_time_nsec;
m_raw->time_sec = t_c.m_time_sec;
m_raw->setInterface(node->m_pkt_info->m_pkt_indication.m_desc.IsInitSide());
-
+
if (m_store_pcfg) {
erf_vif.write_pkt(m_raw);
}
-
+
if ((m_callback) && (node->is_rx_check_enabled()) ) {
m_callback->handle_packet(m);
}
- // just free it
+ // just free it
rte_pktmbuf_free(m);
return (0);
}
@@ -2031,18 +1993,18 @@ public:
};
-class rx_check_system : public testing::Test {
+class rx_check_system : public trexTest {
protected:
virtual void SetUp() {
-
- m_rx_check.m_callback=&m_callback;
- m_callback.mg =&m_mg;
+ trexTest::SetUp();
+ m_rx_check.m_callback = &m_callback;
+ m_callback.mg = &m_mg;
m_mg.Create();
CParserOption * po =&CGlobalInfo::m_options;
po->preview.setVMode(0);
po->preview.setFileWrite(true);
po->preview.set_rx_check_enable(true);
-
+ po->m_run_mode = CParserOption::RUN_MODE_BATCH;
}
virtual void TearDown() {
@@ -2057,7 +2019,7 @@ public:
};
-// check DNS yaml with sample of 1/2 check that there is no errors
+// check DNS yaml with sample of 1/2 check that there is no errors
TEST_F(rx_check_system, rx_system1) {
m_rxcs.lpVf=&m_rx_check;
@@ -2075,7 +2037,7 @@ TEST_F(rx_check_system, rx_system1) {
EXPECT_EQ(m_mg.m_stats.get_total_err(),0);
}
-// check DNS with rxcheck and write results out to capture file
+// check DNS with rxcheck and write results out to capture file
TEST_F(rx_check_system, rx_system1_dns) {
m_rxcs.lpVf=&m_rx_check;
@@ -2098,7 +2060,7 @@ TEST_F(rx_check_system, rx_system1_dns) {
EXPECT_EQ(cmp.compare("exp/dns_rxcheck.erf","exp/dns_rxcheck-ex.erf"),true);
}
-// check DNS yaml with sample of 1/4 using IPv6 packets
+// check DNS yaml with sample of 1/4 using IPv6 packets
TEST_F(rx_check_system, rx_system1_ipv6) {
m_rxcs.lpVf=&m_rx_check;
@@ -2119,7 +2081,7 @@ TEST_F(rx_check_system, rx_system1_ipv6) {
}
// check DNS with rxcheck using IPv6 packets
-// and write results out to capture file
+// and write results out to capture file
TEST_F(rx_check_system, rx_system1_dns_ipv6) {
m_rxcs.lpVf=&m_rx_check;
@@ -2161,7 +2123,7 @@ TEST_F(rx_check_system, rx_system2_plugin_one_dir) {
EXPECT_EQ(m_mg.m_stats.get_total_err(),0);
}
-// check HTTP with rxcheck and write results out to capture file
+// check HTTP with rxcheck and write results out to capture file
TEST_F(rx_check_system, rx_system2_plugin) {
m_rxcs.lpVf=&m_rx_check;
@@ -2185,7 +2147,7 @@ TEST_F(rx_check_system, rx_system2_plugin) {
}
// check DNS with rxcheck using IPv6 packets
-// and write results out to capture file
+// and write results out to capture file
TEST_F(rx_check_system, rx_system2_plugin_ipv6) {
m_rxcs.lpVf=&m_rx_check;
@@ -2312,8 +2274,8 @@ public:
/* ip option packet */
printf(" rx got ip option packet ! \n");
mg->handle_packet_ipv4(option, ipv4, true);
- delay(10); // delay for queue flush
- mg->handle_aging(); // flush the RxRing
+ delay(10); // delay for queue flush
+ mg->handle_aging(); // flush the RxRing
}
}
CNatRxManager * mg;
@@ -2321,9 +2283,10 @@ public:
-class nat_check_system : public testing::Test {
+class nat_check_system : public trexTest {
protected:
virtual void SetUp() {
+ trexTest::SetUp();
m_rx_check.m_callback=&m_callback;
m_callback.mg =&m_mg;
m_mg.Create();
@@ -2365,10 +2328,11 @@ TEST_F(nat_check_system, nat_system1) {
//////////////////////////////////////////////////////////////
-class file_flow_info : public testing::Test {
+class file_flow_info : public trexTest {
protected:
virtual void SetUp() {
+ trexTest::SetUp();
assert(m_flow_info.Create());
}
@@ -2571,10 +2535,11 @@ TEST_F(file_flow_info, load_cap_file_errors) {
//////////////////////////////////////////////////////////////
-class time_histogram : public testing::Test {
+class time_histogram : public trexTest {
protected:
virtual void SetUp() {
+ trexTest::SetUp();
m_hist.Create();
}
@@ -2599,7 +2564,7 @@ TEST_F(time_histogram, test_average) {
EXPECT_EQ(m_hist.get_high_count(), 2001 * (j+1) - (11 * (j+1)));
EXPECT_EQ(m_hist.get_max_latency(), 2000);
}
-
+
m_hist.Dump(stdout);
}
@@ -2622,35 +2587,16 @@ TEST_F(time_histogram, test_json) {
printf(" %s \n",json.c_str());
}
-
-
-class gt_jitter : public testing::Test {
-
-protected:
- virtual void SetUp() {
- }
-
- virtual void TearDown() {
- }
+class gt_jitter : public trexTest {
public:
CJitter m_jitter;
};
-
-class gt_jitter_uint : public testing::Test {
-
-protected:
- virtual void SetUp() {
- }
-
- virtual void TearDown() {
- }
+class gt_jitter_uint : public trexTest {
public:
CJitterUint m_jitter;
};
-
-
TEST_F(gt_jitter, jitter1) {
int i;
double a=0.000030;
@@ -2679,17 +2625,7 @@ TEST_F(gt_jitter_uint, jitter2) {
EXPECT_EQ((uint32_t)(m_jitter.get_jitter()), 19);
}
-
-class gt_ring : public testing::Test {
-
-protected:
- virtual void SetUp() {
- }
-
- virtual void TearDown() {
- }
-public:
-};
+class gt_ring : public trexTest {};
TEST_F(gt_ring, ring1) {
@@ -2785,32 +2721,8 @@ TEST_F(gt_ring, ring3) {
my_map.Delete();
}
-
-class gt_conf : public testing::Test {
-
-protected:
- virtual void SetUp() {
- }
-
- virtual void TearDown() {
- }
-public:
-};
-
-
-
-class ipg_calc : public testing::Test {
- protected:
- virtual void SetUp() {
- }
- virtual void TearDown() {
- }
-public:
-};
-
-
-
-
+class gt_conf : public trexTest {};
+class ipg_calc : public trexTest {};
TEST_F(ipg_calc, test1) {
@@ -2846,4 +2758,3 @@ TEST_F(ipg_calc, test3) {
EXPECT_EQ(ticks,UINT32_MAX);
}
}
-
diff --git a/src/bp_gtest.h b/src/bp_gtest.h
index 0bc66eac..955b781e 100644
--- a/src/bp_gtest.h
+++ b/src/bp_gtest.h
@@ -19,6 +19,16 @@ limitations under the License.
#define EXPECT_EQ_UINT32(a,b) EXPECT_EQ((uint32_t)(a),(uint32_t)(b))
+class trexTest : public testing::Test {
+ protected:
+ virtual void SetUp() {
+ CGlobalInfo::m_options.reset();
+ }
+ virtual void TearDown() {
+ }
+public:
+};
+
class CTestBasic {
public: