From b3c544bd3d3e150660774d4588419e75058bdf97 Mon Sep 17 00:00:00 2001 From: Ido Barnea Date: Tue, 10 Jan 2017 16:01:27 +0200 Subject: Add client config unit test + fixes to unit tests infra Signed-off-by: Ido Barnea --- src/bp_gtest.cpp | 119 +------------------------------------------------------ 1 file changed, 1 insertion(+), 118 deletions(-) (limited to 'src/bp_gtest.cpp') diff --git a/src/bp_gtest.cpp b/src/bp_gtest.cpp index 4c04dde9..be601957 100755 --- a/src/bp_gtest.cpp +++ b/src/bp_gtest.cpp @@ -34,6 +34,7 @@ limitations under the License. #include "stateful_rx_core.h" #include "nat_check_flow_table.h" #include "utl_ipg_bucket.h" +#include "bp_gtest.h" int test_policer(){ CPolicer policer; @@ -113,124 +114,6 @@ int test_human_p(){ return (0); } - - - - - -#define EXPECT_EQ_UINT32(a,b) EXPECT_EQ((uint32_t)(a),(uint32_t)(b)) - - -class CTestBasic { - -public: - CTestBasic(){ - m_threads=1; - m_time_diff=0.001; - m_req_ports=0; - m_dump_json=false; - } - - bool init(void){ - - uint16 * ports = NULL; - CTupleBase tuple; - - CErfIF erf_vif; - - - fl.Create(); - m_saved_packet_padd_offset=0; - - fl.load_from_yaml(CGlobalInfo::m_options.cfg_file,m_threads); - fl.generate_p_thread_info(m_threads); - - CFlowGenListPerThread * lpt; - - fl.m_threads_info[0]->set_vif(&erf_vif); - - - CErfCmp cmp; - cmp.dump=1; - - bool res=true; - - - int i; - for (i=0; im_cap_gen[0]->m_flow_info->GetPacket(0); - m_saved_packet_padd_offset =pkt->m_pkt_indication.m_packet_padding; - - char buf[100]; - char buf_ex[100]; - sprintf(buf,"%s-%d.erf",CGlobalInfo::m_options.out_file.c_str(),i); - sprintf(buf_ex,"%s-%d-ex.erf",CGlobalInfo::m_options.out_file.c_str(),i); - - if ( m_req_ports ){ - /* generate from first template m_req_ports ports */ - int i; - CTupleTemplateGeneratorSmart * lpg=&lpt->m_cap_gen[0]->tuple_gen; - ports = new uint16_t[m_req_ports]; - lpg->GenerateTuple(tuple); - for (i=0 ; iGenerateOneSourcePort(); - } - } - CGlobalInfo::m_options.m_run_mode = CParserOption::RUN_MODE_BATCH; - lpt->start_generate_stateful(buf,CGlobalInfo::m_options.preview); - lpt->m_node_gen.DumpHist(stdout); - - cmp.d_sec = m_time_diff; - //compare - if ( cmp.compare(std::string(buf),std::string(buf_ex)) != true ) { - res=false; - } - - } - if ( m_dump_json ){ - printf(" dump json ...........\n"); - std::string s; - fl.m_threads_info[0]->m_node_gen.dump_json(s); - printf(" %s \n",s.c_str()); - } - - if ( m_req_ports ){ - int i; - fl.m_threads_info[0]->m_smart_gen.FreePort(0, tuple.getClientId(),tuple.getClientPort()); - - for (i=0 ; im_smart_gen.FreePort(0,tuple.getClientId(),ports[i]); - } - delete []ports; - } - - printf(" active %d \n", fl.m_threads_info[0]->m_smart_gen.ActiveSockets()); - EXPECT_EQ_UINT32(fl.m_threads_info[0]->m_smart_gen.ActiveSockets(),0); - fl.Delete(); - return (res); - } - - uint16_t get_padd_offset_first_packet(){ - return (m_saved_packet_padd_offset); - - } - - - -public: - int m_req_ports; - int m_threads; - double m_time_diff; - bool m_dump_json; - uint16_t m_saved_packet_padd_offset; - CFlowGenList fl; -}; - - - - class basic : public testing::Test { protected: virtual void SetUp() { -- cgit 1.2.3-korg