diff options
author | 2015-12-15 15:57:03 +0200 | |
---|---|---|
committer | 2015-12-15 15:57:03 +0200 | |
commit | 96314dfde866a6b866464c9a91331a266ea137bc (patch) | |
tree | f8ac78df410a10a73ce09548b22d833491cf6701 | |
parent | fb74954c33722dc25236137f76c8fa7a3aeafa2e (diff) |
refactor the vm_tests
-rw-r--r-- | scripts/exp/stl_vm_enable1-0-ex.erf | bin | 6160 -> 6160 bytes | |||
-rw-r--r-- | scripts/exp/stl_vm_enable2-0-ex.erf | bin | 6160 -> 4488 bytes | |||
-rw-r--r-- | src/gtest/trex_stateless_gtest.cpp | 131 |
3 files changed, 33 insertions, 98 deletions
diff --git a/scripts/exp/stl_vm_enable1-0-ex.erf b/scripts/exp/stl_vm_enable1-0-ex.erf Binary files differindex 41dec175..d40539e9 100644 --- a/scripts/exp/stl_vm_enable1-0-ex.erf +++ b/scripts/exp/stl_vm_enable1-0-ex.erf diff --git a/scripts/exp/stl_vm_enable2-0-ex.erf b/scripts/exp/stl_vm_enable2-0-ex.erf Binary files differindex 41dec175..d099c14c 100644 --- a/scripts/exp/stl_vm_enable2-0-ex.erf +++ b/scripts/exp/stl_vm_enable2-0-ex.erf diff --git a/src/gtest/trex_stateless_gtest.cpp b/src/gtest/trex_stateless_gtest.cpp index 88c68095..90dea72e 100644 --- a/src/gtest/trex_stateless_gtest.cpp +++ b/src/gtest/trex_stateless_gtest.cpp @@ -2010,14 +2010,21 @@ TEST_F(basic_stl, multi_pkt1) { } +class CEnableVm { +public: + void run(bool full_packet,double duration ); +public: + std::string m_input_packet; //"cap2/udp_64B.pcap" + std::string m_out_file; //"exp/stl_vm_enable0"; +}; -TEST_F(basic_stl, vm_enable0) { +void CEnableVm::run(bool full_packet,double duration=10.0){ CBasicStl t1; CParserOption * po =&CGlobalInfo::m_options; po->preview.setVMode(7); po->preview.setFileWrite(true); - po->out_file ="exp/stl_vm_enable0"; + po->out_file =m_out_file; TrexStreamsCompiler compile; @@ -2034,7 +2041,7 @@ TEST_F(basic_stl, vm_enable0) { stream1->m_port_id= port_id; CPcapLoader pcap; - pcap.load_pcap_file("cap2/udp_64B.pcap",0); + pcap.load_pcap_file(m_input_packet,0); pcap.update_ip_src(0x10000001); pcap.clone_packet_into_stream(stream1); @@ -2043,71 +2050,23 @@ TEST_F(basic_stl, vm_enable0) { stream1->m_has_vm = true; vm_build_program_seq(stream1->m_vm,pkt_size); stream1->post_vm_compile(); - printf(" vm_prefix_size %d \n",stream1->m_vm_prefix_size); - EXPECT_EQ(stream1->m_vm_prefix_size,pkt_size); - - - streams.push_back(stream1); - - // stream - clean - std::vector<TrexStreamsCompiledObj *> objs; - - assert(compile.compile(port_id,streams, objs) ); - - TrexStatelessDpStart * lpstart = new TrexStatelessDpStart(port_id, 0, objs[0], 10.0 /*sec */ ); - - - t1.m_msg = lpstart; - - bool res=t1.init(); - - delete stream1 ; - - EXPECT_EQ_UINT32(1, res?1:0)<< "pass"; -} - -#if 0 -TEST_F(basic_stl, vm_enable1) { - - CBasicStl t1; - CParserOption * po =&CGlobalInfo::m_options; - po->preview.setVMode(7); - po->preview.setFileWrite(true); - po->out_file ="exp/stl_vm_enable1"; - - TrexStreamsCompiler compile; - - uint8_t port_id=0; - - std::vector<TrexStream *> streams; - - TrexStream * stream1 = new TrexStream(TrexStream::stCONTINUOUS,0,0); - stream1->m_has_vm = true; - stream1->m_vm_prefix_size =64; - stream1->set_pps(1.0); - - - stream1->m_enabled = true; - stream1->m_self_start = true; - stream1->m_port_id= port_id; + if ( full_packet ){ + EXPECT_EQ(stream1->m_vm_prefix_size,pkt_size); + }else{ + EXPECT_EQ(stream1->m_vm_prefix_size,35); + } - CPcapLoader pcap; - pcap.load_pcap_file("stl/udp_594B_no_crc.pcap",0); - pcap.update_ip_src(0x10000001); - pcap.clone_packet_into_stream(stream1); streams.push_back(stream1); // stream - clean - - std::vector<TrexStreamsCompiledObj *> objs; assert(compile.compile(port_id,streams, objs) ); - TrexStatelessDpStart * lpstart = new TrexStatelessDpStart(port_id, 0, objs[0], 10.0 /*sec */ ); + TrexStatelessDpStart * lpstart = new TrexStatelessDpStart(port_id, 0, objs[0], duration /*sec */ ); t1.m_msg = lpstart; @@ -2119,58 +2078,34 @@ TEST_F(basic_stl, vm_enable1) { EXPECT_EQ_UINT32(1, res?1:0)<< "pass"; } -TEST_F(basic_stl, vm_enable2) { - - CBasicStl t1; - CParserOption * po =&CGlobalInfo::m_options; - po->preview.setVMode(7); - po->preview.setFileWrite(true); - po->out_file ="exp/stl_vm_enable2"; - - TrexStreamsCompiler compile; - - uint8_t port_id=0; - - std::vector<TrexStream *> streams; - - TrexStream * stream1 = new TrexStream(TrexStream::stCONTINUOUS,0,0); - stream1->m_has_vm = true; - stream1->m_vm_prefix_size = 256; - stream1->set_pps(1.0); - - - stream1->m_enabled = true; - stream1->m_self_start = true; - stream1->m_port_id= port_id; +TEST_F(basic_stl, vm_enable0) { - CPcapLoader pcap; - pcap.load_pcap_file("stl/udp_594B_no_crc.pcap",0); - pcap.update_ip_src(0x10000001); - pcap.clone_packet_into_stream(stream1); - - streams.push_back(stream1); + CEnableVm vm_test; + vm_test.m_out_file = "exp/stl_vm_enable0"; + vm_test.m_input_packet = "cap2/udp_64B.pcap"; + vm_test.run(true); +} - // stream - clean - std::vector<TrexStreamsCompiledObj *> objs; - assert(compile.compile(port_id,streams, objs) ); - - TrexStatelessDpStart * lpstart = new TrexStatelessDpStart(port_id, 0, objs[0], 10.0 /*sec */ ); +TEST_F(basic_stl, vm_enable1) { + CEnableVm vm_test; + vm_test.m_out_file = "exp/stl_vm_enable1"; + vm_test.m_input_packet = "stl/udp_594B_no_crc.pcap"; + vm_test.run(false); +} - t1.m_msg = lpstart; - bool res=t1.init(); - delete stream1 ; +TEST_F(basic_stl, vm_enable2) { - EXPECT_EQ_UINT32(1, res?1:0)<< "pass"; + CEnableVm vm_test; + vm_test.m_out_file = "exp/stl_vm_enable2"; + vm_test.m_input_packet = "cap2/udp_64B.pcap"; + vm_test.run(true,50.0); } -#endif - - |