summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-05-09 16:44:10 +0300
committerimarom <imarom@cisco.com>2016-05-09 16:48:17 +0300
commit3ef23bf8bf6b9f9bb59de4289658f3f81da63435 (patch)
tree5d729805f53f5541d0e99380f6967efd633fbd68
parentc4e6748cedf1f9f3a3c1916c96c4f044561b075b (diff)
PCAP remote gtests
-rw-r--r--.gitignore3
-rw-r--r--scripts/exp/pcap_remote_basic-0-ex.erfbin0 -> 125664 bytes
-rw-r--r--scripts/exp/pcap_remote_duration-0-ex.erfbin0 -> 528 bytes
-rw-r--r--scripts/exp/pcap_remote_loop-0-ex.erfbin0 -> 376992 bytes
-rw-r--r--scripts/exp/remote_test.capbin0 -> 108552 bytes
-rwxr-xr-xsrc/bp_sim.cpp67
-rwxr-xr-xsrc/bp_sim.h3
-rw-r--r--src/gtest/trex_stateless_gtest.cpp64
-rw-r--r--src/stateless/dp/trex_stateless_dp_core.cpp6
-rw-r--r--src/stateless/dp/trex_stream_node.h1
10 files changed, 125 insertions, 19 deletions
diff --git a/.gitignore b/.gitignore
index 80456922..aae8781e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,6 +37,9 @@ scripts/stl/exportedFile.pcap
scripts/exp/stl_multi_burst1-0.erf
scripts/exp/stl_multi_pkt1-0.erf
scripts/exp/stl_multi_pkt2-0.erf
+scripts/pcap_remote_basic-0.erf
+scripts/exp/pcap_remote_duration-0.erf
+scripts/exp/pcap_remote_loop-0.erf
scripts/exp/stl_single_pkt_burst1-0.erf
scripts/exp/stl_single_sctp_pkt-0.erf
scripts/exp/stl_single_stream-0.erf
diff --git a/scripts/exp/pcap_remote_basic-0-ex.erf b/scripts/exp/pcap_remote_basic-0-ex.erf
new file mode 100644
index 00000000..3c626419
--- /dev/null
+++ b/scripts/exp/pcap_remote_basic-0-ex.erf
Binary files differ
diff --git a/scripts/exp/pcap_remote_duration-0-ex.erf b/scripts/exp/pcap_remote_duration-0-ex.erf
new file mode 100644
index 00000000..3731f735
--- /dev/null
+++ b/scripts/exp/pcap_remote_duration-0-ex.erf
Binary files differ
diff --git a/scripts/exp/pcap_remote_loop-0-ex.erf b/scripts/exp/pcap_remote_loop-0-ex.erf
new file mode 100644
index 00000000..c5f3d8be
--- /dev/null
+++ b/scripts/exp/pcap_remote_loop-0-ex.erf
Binary files differ
diff --git a/scripts/exp/remote_test.cap b/scripts/exp/remote_test.cap
new file mode 100644
index 00000000..05462b28
--- /dev/null
+++ b/scripts/exp/remote_test.cap
Binary files differ
diff --git a/src/bp_sim.cpp b/src/bp_sim.cpp
index c658248e..0e3aa2ae 100755
--- a/src/bp_sim.cpp
+++ b/src/bp_sim.cpp
@@ -4848,31 +4848,62 @@ int CErfIFStl::update_mac_addr_from_global_cfg(pkt_dir_t dir, uint8_t * p){
}
-int CErfIFStl::send_node(CGenNode * _no_to_use){
+int CErfIFStl::send_sl_node(CGenNodeStateless *node_sl) {
+ pkt_dir_t dir=(pkt_dir_t)node_sl->get_mbuf_cache_dir();
+
+ /* check that we have mbuf */
+ rte_mbuf_t * m=node_sl->get_cache_mbuf();
+ if (m) {
+ /* cache packet */
+ fill_raw_packet(m, (CGenNode*)node_sl, dir);
+ /* can't free the m, it is cached*/
+ }else{
- if ( m_preview_mode->getFileWrite() ){
+ m=node_sl->alloc_node_with_vm();
+ assert(m);
+ fill_raw_packet(m, (CGenNode*)node_sl, dir);
+ rte_pktmbuf_free(m);
- CGenNodeStateless * node_sl=(CGenNodeStateless *) _no_to_use;
+ }
+
+ int rc = write_pkt(m_raw);
+ BP_ASSERT(rc == 0);
- pkt_dir_t dir=(pkt_dir_t)node_sl->get_mbuf_cache_dir();
+ return (rc);
+}
- /* check that we have mbuf */
- rte_mbuf_t * m=node_sl->get_cache_mbuf();
- if (m) {
- /* cache packet */
- fill_raw_packet(m,_no_to_use,dir);
- /* can't free the m, it is cached*/
- }else{
- m=node_sl->alloc_node_with_vm();
- assert(m);
- fill_raw_packet(m,_no_to_use,dir);
- rte_pktmbuf_free(m);
+int CErfIFStl::send_pcap_node(CGenNodePCAP *pcap_node) {
+ rte_mbuf_t *m = pcap_node->get_pkt();
+ if (!m) {
+ return (-1);
+ }
- }
+ pkt_dir_t dir = (pkt_dir_t)pcap_node->get_mbuf_dir();
+ fill_raw_packet(m, (CGenNode*)pcap_node, dir);
+ rte_pktmbuf_free(m);
- int rc = write_pkt(m_raw);
- BP_ASSERT(rc == 0);
+ int rc = write_pkt(m_raw);
+ BP_ASSERT(rc == 0);
+
+ return (rc);
+}
+
+int CErfIFStl::send_node(CGenNode * _no_to_use){
+
+ if ( m_preview_mode->getFileWrite() ) {
+
+ switch (_no_to_use->m_type) {
+ case CGenNode::STATELESS_PKT:
+ return send_sl_node((CGenNodeStateless *) _no_to_use);
+
+ case CGenNode::PCAP_PKT:
+ return send_pcap_node((CGenNodePCAP *) _no_to_use);
+
+ default:
+ assert(0);
+ }
+
}
return (0);
diff --git a/src/bp_sim.h b/src/bp_sim.h
index 8f003eee..037cc8fb 100755
--- a/src/bp_sim.h
+++ b/src/bp_sim.h
@@ -1887,6 +1887,9 @@ public:
virtual pkt_dir_t port_id_to_dir(uint8_t port_id);
+private:
+ int send_sl_node(CGenNodeStateless * node_sl);
+ int send_pcap_node(CGenNodePCAP * pcap_node);
};
diff --git a/src/gtest/trex_stateless_gtest.cpp b/src/gtest/trex_stateless_gtest.cpp
index a5cf3307..ef7b658d 100644
--- a/src/gtest/trex_stateless_gtest.cpp
+++ b/src/gtest/trex_stateless_gtest.cpp
@@ -3569,6 +3569,70 @@ TEST_F(basic_stl, vm_split_client_var) {
}
+TEST_F(basic_stl, pcap_remote_basic) {
+
+ CBasicStl t1;
+ CParserOption * po =&CGlobalInfo::m_options;
+ po->preview.setVMode(7);
+ po->preview.setFileWrite(true);
+ po->out_file ="exp/pcap_remote_basic";
+
+ TrexStatelessCpToDpMsgBase *push_msg = new TrexStatelessDpPushPCAP(0,
+ 0,
+ "exp/remote_test.cap",
+ 10,
+ 1,
+ 1,
+ -1);
+ t1.m_msg = push_msg;
+
+ bool res = t1.init();
+ EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
+}
+
+TEST_F(basic_stl, pcap_remote_loop) {
+
+ CBasicStl t1;
+ CParserOption * po =&CGlobalInfo::m_options;
+ po->preview.setVMode(7);
+ po->preview.setFileWrite(true);
+ po->out_file ="exp/pcap_remote_loop";
+
+ TrexStatelessCpToDpMsgBase *push_msg = new TrexStatelessDpPushPCAP(0,
+ 0,
+ "exp/remote_test.cap",
+ 1,
+ 1,
+ 3,
+ -1);
+ t1.m_msg = push_msg;
+
+ bool res = t1.init();
+ EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
+}
+
+TEST_F(basic_stl, pcap_remote_duration) {
+
+ CBasicStl t1;
+ CParserOption * po =&CGlobalInfo::m_options;
+ po->preview.setVMode(7);
+ po->preview.setFileWrite(true);
+ po->out_file ="exp/pcap_remote_duration";
+
+ TrexStatelessCpToDpMsgBase *push_msg = new TrexStatelessDpPushPCAP(0,
+ 0,
+ "exp/remote_test.cap",
+ 100000,
+ 1,
+ 0,
+ 0.5);
+ t1.m_msg = push_msg;
+
+ bool res = t1.init();
+ EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
+}
+
+
/********************************************* Itay Tests End *************************************/
class rx_stat_pkt_parse : public testing::Test {
protected:
diff --git a/src/stateless/dp/trex_stateless_dp_core.cpp b/src/stateless/dp/trex_stateless_dp_core.cpp
index 1a730e66..6648e2f3 100644
--- a/src/stateless/dp/trex_stateless_dp_core.cpp
+++ b/src/stateless/dp/trex_stateless_dp_core.cpp
@@ -276,13 +276,15 @@ bool TrexStatelessDpPerPort::push_pcap(uint8_t port_id,
return (false);
}
- pkt_dir_t dir = m_core->m_node_gen.m_v_if->port_id_to_dir(port_id);
+ pkt_dir_t dir = m_core->m_node_gen.m_v_if->port_id_to_dir(port_id);
+ socket_id_t socket_id = m_core->m_node_gen.m_socket_id;
uint8_t mac_addr[12];
m_core->m_node_gen.m_v_if->update_mac_addr_from_global_cfg(dir, mac_addr);
bool rc = pcap_node->create(port_id,
dir,
+ socket_id,
mac_addr,
pcap_filename,
ipg_usec,
@@ -984,6 +986,7 @@ TrexStatelessDpCore::barrier(uint8_t port_id, int event_id) {
*/
bool CGenNodePCAP::create(uint8_t port_id,
pkt_dir_t dir,
+ socket_id_t socket_id,
const uint8_t *mac_addr,
const std::string &pcap_filename,
double ipg_usec,
@@ -1015,6 +1018,7 @@ bool CGenNodePCAP::create(uint8_t port_id,
/* set the dir */
set_mbuf_dir(dir);
+ set_socket_id(socket_id);
/* create the PCAP reader */
m_reader = CCapReaderFactory::CreateReader((char *)pcap_filename.c_str(), 0, ss);
diff --git a/src/stateless/dp/trex_stream_node.h b/src/stateless/dp/trex_stream_node.h
index de4c21de..70054bbc 100644
--- a/src/stateless/dp/trex_stream_node.h
+++ b/src/stateless/dp/trex_stream_node.h
@@ -400,6 +400,7 @@ public:
*/
bool create(uint8_t port_id,
pkt_dir_t dir,
+ socket_id_t socket_id,
const uint8_t *mac_addr,
const std::string &pcap_filename,
double ipg_usec,