diff options
author | 2016-05-09 16:44:10 +0300 | |
---|---|---|
committer | 2016-05-09 16:48:17 +0300 | |
commit | 3ef23bf8bf6b9f9bb59de4289658f3f81da63435 (patch) | |
tree | 5d729805f53f5541d0e99380f6967efd633fbd68 /src | |
parent | c4e6748cedf1f9f3a3c1916c96c4f044561b075b (diff) |
PCAP remote gtests
Diffstat (limited to 'src')
-rwxr-xr-x | src/bp_sim.cpp | 67 | ||||
-rwxr-xr-x | src/bp_sim.h | 3 | ||||
-rw-r--r-- | src/gtest/trex_stateless_gtest.cpp | 64 | ||||
-rw-r--r-- | src/stateless/dp/trex_stateless_dp_core.cpp | 6 | ||||
-rw-r--r-- | src/stateless/dp/trex_stream_node.h | 1 |
5 files changed, 122 insertions, 19 deletions
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, |