summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/exp/stl_vm_enable1-0-ex.erfbin6160 -> 6160 bytes
-rw-r--r--scripts/exp/stl_vm_enable2-0-ex.erfbin6160 -> 4488 bytes
-rw-r--r--src/gtest/trex_stateless_gtest.cpp131
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
index 41dec175..d40539e9 100644
--- a/scripts/exp/stl_vm_enable1-0-ex.erf
+++ b/scripts/exp/stl_vm_enable1-0-ex.erf
Binary files differ
diff --git a/scripts/exp/stl_vm_enable2-0-ex.erf b/scripts/exp/stl_vm_enable2-0-ex.erf
index 41dec175..d099c14c 100644
--- a/scripts/exp/stl_vm_enable2-0-ex.erf
+++ b/scripts/exp/stl_vm_enable2-0-ex.erf
Binary files differ
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
-
-