summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-07-03 10:55:49 +0300
committerimarom <imarom@cisco.com>2016-07-03 13:40:23 +0300
commitc6c4a4307a8a0ae17d3e26c9dc98b874dd5ee60b (patch)
treec32a0f0c6465b63e9857d19313ed13651cfd934a
parented196079a710ddc30552ecbc0329db7a75a4ca60 (diff)
client config - cosmetics and gtest back on
-rwxr-xr-xlinux/ws_main.py2
-rwxr-xr-xsrc/bp_sim.cpp7
-rwxr-xr-xsrc/gtest/tuple_gen_test.cpp75
-rw-r--r--src/main_dpdk.cpp8
-rw-r--r--src/sim/trex_sim_stateful.cpp14
-rw-r--r--src/trex_client_config.cpp9
-rw-r--r--src/trex_client_config.h1
-rwxr-xr-xsrc/tuple_gen.cpp2
-rwxr-xr-xsrc/utl_yaml.cpp4
9 files changed, 56 insertions, 66 deletions
diff --git a/linux/ws_main.py b/linux/ws_main.py
index 0ee2fd3b..2219522a 100755
--- a/linux/ws_main.py
+++ b/linux/ws_main.py
@@ -97,7 +97,7 @@ bp_sim_main = SrcGroup(dir='src',
bp_sim_gtest = SrcGroup(dir='src',
src_list=[
'bp_gtest.cpp',
- #'gtest/tuple_gen_test.cpp',
+ 'gtest/tuple_gen_test.cpp',
'gtest/nat_test.cpp',
'gtest/trex_stateless_gtest.cpp'
])
diff --git a/src/bp_sim.cpp b/src/bp_sim.cpp
index ba8caf32..758778d9 100755
--- a/src/bp_sim.cpp
+++ b/src/bp_sim.cpp
@@ -4399,12 +4399,7 @@ void CFlowGenList::clean_p_thread_info(void){
}
int CFlowGenList::load_client_config_file(std::string file_name) {
- try {
- m_client_config_info.load_yaml_file(file_name);
- } catch (const std::exception& e) {
- std::cout << e.what() << "\n";
- exit(-1);
- }
+ m_client_config_info.load_yaml_file(file_name);
return (0);
}
diff --git a/src/gtest/tuple_gen_test.cpp b/src/gtest/tuple_gen_test.cpp
index f3b9fa1e..fa760c6d 100755
--- a/src/gtest/tuple_gen_test.cpp
+++ b/src/gtest/tuple_gen_test.cpp
@@ -25,6 +25,22 @@ limitations under the License.
/* TEST case for CClientInfo*/
+class CClientInfo : public CSimpleClientInfo<CIpInfo> {
+public:
+ CClientInfo() : CSimpleClientInfo<CIpInfo>(0) {
+
+ }
+};
+
+class CClientInfoL : public CSimpleClientInfo<CIpInfoL> {
+public:
+ CClientInfoL() : CSimpleClientInfo<CIpInfoL>(0) {
+
+ }
+};
+
+static ClientCfgDB g_dummy;
+
class CClientInfoUT {
public:
CClientInfoUT(CClientInfo *a) {
@@ -157,7 +173,7 @@ TEST(CClientInfoLTest, get_new_free_port) {
TEST(tuple_gen,clientPoolL) {
CClientPool gen;
gen.Create(cdSEQ_DIST,
- 0x10000001, 0x10000f01, 64000,1,NULL,false,
+ 0x10000001, 0x10000f01, 64000,1, g_dummy,
0,0);
CTupleBase result;
uint32_t result_src;
@@ -181,7 +197,7 @@ TEST(tuple_gen,clientPoolL) {
TEST(tuple_gen,clientPool) {
CClientPool gen;
gen.Create(cdSEQ_DIST,
- 0x10000001, 0x10000021, 64000,1000,NULL,false,
+ 0x10000001, 0x10000021, 64000,1000, g_dummy,
0,0);
CTupleBase result;
uint32_t result_src;
@@ -273,7 +289,7 @@ TEST(tuple_gen,GenerateTuple2) {
CClientPool c_gen;
CClientPool c_gen_2;
c_gen.Create(cdSEQ_DIST,
- 0x10000001, 0x1000000f, 64000,4,NULL,false,
+ 0x10000001, 0x1000000f, 64000,4, g_dummy,
0,0);
CServerPool s_gen;
CServerPool s_gen_2;
@@ -302,7 +318,7 @@ TEST(tuple_gen,GenerateTuple2) {
c_gen.Delete();
// EXPECT_EQ((size_t)0, gen.m_clients.size());
c_gen.Create(cdSEQ_DIST,
- 0x10000001, 0x1000000f, 64000,400,NULL,false,
+ 0x10000001, 0x1000000f, 64000,400, g_dummy,
0,0);
s_gen.Create(cdSEQ_DIST,
0x30000001, 0x30000001, 64000,10);
@@ -325,39 +341,6 @@ TEST(tuple_gen,GenerateTuple2) {
}
-TEST(tuple_gen,GenerateTupleMac) {
- CFlowGenList fl;
- fl.Create();
- fl.load_from_mac_file("avl/mac_uit.yaml");
-
- CClientPool gen;
- gen.Create(cdSEQ_DIST,
- 0x10000001, 0x1000000f, 64000,2, &fl.m_mac_info,true,0,0);
-
- CTupleBase result;
- uint32_t result_src;
- uint16_t result_port;
- mac_addr_align_t* result_mac;
- for(int i=0;i<10;i++) {
- gen.GenerateTuple(result);
- printf(" C:%x P:%d \n",result.getClient(),result.getClientPort());
-
- result_src = result.getClient();
- result_port = result.getClientPort();
- result_mac = result.getClientMac();
- EXPECT_EQ(result_src, (uint32_t)(0x10000001+i%2));
- EXPECT_EQ(result_port, 1024+i/2);
- printf("i:%d,mac:%d\n",i,result_mac->mac[3]);
- if (i%2==0)
- EXPECT_EQ(result_mac->mac[3], 5);
- else
- EXPECT_EQ(result_mac->mac[3], 1);
- }
-
- gen.Delete();
-// EXPECT_EQ((size_t)0, gen.m_clients.size());
-}
-
TEST(tuple_gen,split1) {
CIpPortion portion;
@@ -421,7 +404,7 @@ TEST(tuple_gen,split2) {
TEST(tuple_gen,template1) {
CTupleGeneratorSmart gen;
gen.Create(1, 1);
- gen.add_client_pool(cdSEQ_DIST,0x10000001,0x1000000f,64000,4,NULL,0,0);
+ gen.add_client_pool(cdSEQ_DIST,0x10000001,0x1000000f,64000,4, g_dummy, 0, 0);
gen.add_server_pool(cdSEQ_DIST,0x30000001,0x40000001,64000,4,false);
CTupleTemplateGeneratorSmart template_1;
template_1.Create(&gen,0,0);
@@ -446,7 +429,7 @@ TEST(tuple_gen,template1) {
TEST(tuple_gen,template2) {
CTupleGeneratorSmart gen;
gen.Create(1, 1);
- gen.add_client_pool(cdSEQ_DIST,0x10000001,0x1000000f,64000,4,NULL,0,0);
+ gen.add_client_pool(cdSEQ_DIST,0x10000001,0x1000000f,64000,4,g_dummy,0,0);
gen.add_server_pool(cdSEQ_DIST,0x30000001,0x40000001,64000,4,false);
CTupleTemplateGeneratorSmart template_1;
template_1.Create(&gen,0,0);
@@ -475,7 +458,7 @@ TEST(tuple_gen,template2) {
TEST(tuple_gen,no_free) {
CTupleGeneratorSmart gen;
gen.Create(1, 1);
- gen.add_client_pool(cdSEQ_DIST,0x10000001,0x10000001,64000,4,NULL,0,0);
+ gen.add_client_pool(cdSEQ_DIST,0x10000001,0x10000001,64000,4,g_dummy,0,0);
gen.add_server_pool(cdSEQ_DIST,0x30000001,0x400000ff,64000,4,false);
CTupleTemplateGeneratorSmart template_1;
template_1.Create(&gen,0,0);
@@ -497,7 +480,7 @@ TEST(tuple_gen,no_free) {
TEST(tuple_gen,try_to_free) {
CTupleGeneratorSmart gen;
gen.Create(1, 1);
- gen.add_client_pool(cdSEQ_DIST,0x10000001,0x10000001,64000,4,NULL,0,0);
+ gen.add_client_pool(cdSEQ_DIST,0x10000001,0x10000001,64000,4,g_dummy,0,0);
gen.add_server_pool(cdSEQ_DIST,0x30000001,0x400000ff,64000,4,false);
CTupleTemplateGeneratorSmart template_1;
template_1.Create(&gen,0,0);
@@ -524,7 +507,7 @@ TEST(tuple_gen,try_to_free) {
TEST(tuple_gen_2,GenerateTuple) {
CTupleGeneratorSmart gen;
gen.Create(1, 1);
- gen.add_client_pool(cdSEQ_DIST,0x10000001,0x10000f01,64000,4,NULL,0,0);
+ gen.add_client_pool(cdSEQ_DIST,0x10000001,0x10000f01,64000,4,g_dummy,0,0);
gen.add_server_pool(cdSEQ_DIST,0x30000001,0x40000001,64000,4,false);
CTupleTemplateGeneratorSmart template_1;
template_1.Create(&gen,0,0);
@@ -552,7 +535,7 @@ TEST(tuple_gen_2,GenerateTuple) {
TEST(tuple_gen_2,GenerateTuple2) {
CTupleGeneratorSmart gen;
gen.Create(1, 1);
- gen.add_client_pool(cdSEQ_DIST,0x10000001,0x1000000f,64000,4,NULL,0,0);
+ gen.add_client_pool(cdSEQ_DIST,0x10000001,0x1000000f,64000,4,g_dummy,0,0);
gen.add_server_pool(cdSEQ_DIST,0x30000001,0x40000001,64000,4,false);
CTupleTemplateGeneratorSmart template_1;
template_1.Create(&gen,0,0);
@@ -576,7 +559,7 @@ TEST(tuple_gen_2,GenerateTuple2) {
gen.Delete();
// EXPECT_EQ((size_t)0, gen.m_clients.size());
gen.Create(1, 1);
- gen.add_client_pool(cdSEQ_DIST,0x10000001,0x1000000f,64000,4,NULL,0,0);
+ gen.add_client_pool(cdSEQ_DIST,0x10000001,0x1000000f,64000,4,g_dummy,0,0);
gen.add_server_pool(cdSEQ_DIST,0x30000001,0x40000001,64000,4,false);
template_1.Create(&gen,0,0);
for(int i=0;i<200;i++) {
@@ -599,7 +582,7 @@ TEST(tuple_gen_2,GenerateTuple2) {
TEST(tuple_gen_2,template1) {
CTupleGeneratorSmart gen;
gen.Create(1, 1);
- gen.add_client_pool(cdSEQ_DIST,0x10000001,0x1000000f,64000,4,NULL,0,0);
+ gen.add_client_pool(cdSEQ_DIST,0x10000001,0x1000000f,64000,4,g_dummy,0,0);
gen.add_server_pool(cdSEQ_DIST,0x30000001,0x40000001,64000,4,false);
CTupleTemplateGeneratorSmart template_1;
template_1.Create(&gen,0,0);
@@ -626,7 +609,7 @@ TEST(tuple_gen_2,template1) {
TEST(tuple_gen_2,template2) {
CTupleGeneratorSmart gen;
gen.Create(1, 1);
- gen.add_client_pool(cdSEQ_DIST,0x10000001,0x1000000f,64000,4,NULL,0,0);
+ gen.add_client_pool(cdSEQ_DIST,0x10000001,0x1000000f,64000,4,g_dummy,0,0);
gen.add_server_pool(cdSEQ_DIST,0x30000001,0x40000001,64000,4,false);
CTupleTemplateGeneratorSmart template_1;
template_1.Create(&gen,0,0);
diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp
index 3827579b..4b086597 100644
--- a/src/main_dpdk.cpp
+++ b/src/main_dpdk.cpp
@@ -4188,8 +4188,14 @@ int CGlobalTRex::start_master_statefull() {
m_fl.Create();
m_fl.load_from_yaml(CGlobalInfo::m_options.cfg_file,get_cores_tx());
+ /* client config */
if (CGlobalInfo::m_options.client_cfg_file != "") {
- m_fl.load_client_config_file(CGlobalInfo::m_options.client_cfg_file);
+ try {
+ m_fl.load_client_config_file(CGlobalInfo::m_options.client_cfg_file);
+ } catch (const std::runtime_error &e) {
+ std::cout << "\n*** " << e.what() << "\n\n";
+ exit(-1);
+ }
CGlobalInfo::m_options.preview.set_client_cfg_enable(true);
}
diff --git a/src/sim/trex_sim_stateful.cpp b/src/sim/trex_sim_stateful.cpp
index 03538e58..7546644d 100644
--- a/src/sim/trex_sim_stateful.cpp
+++ b/src/sim/trex_sim_stateful.cpp
@@ -167,7 +167,12 @@ int load_list_of_cap_files(CParserOption * op){
fl.load_from_yaml(op->cfg_file,1);
if (op->client_cfg_file != "") {
- fl.load_client_config_file(op->client_cfg_file);
+ try {
+ fl.load_client_config_file(op->client_cfg_file);
+ } catch (const std::runtime_error &e) {
+ std::cout << "\n*** " << e.what() << "\n\n";
+ exit(-1);
+ }
CGlobalInfo::m_options.preview.set_client_cfg_enable(true);
}
@@ -609,5 +614,10 @@ int merge_2_cap_files_sip() {
int
SimStateful::run() {
assert( CMsgIns::Ins()->Create(4) );
- return load_list_of_cap_files(&CGlobalInfo::m_options);
+ try {
+ return load_list_of_cap_files(&CGlobalInfo::m_options);
+ } catch (const std::runtime_error &e) {
+ std::cout << "\n*** " << e.what() << "\n\n";
+ exit(-1);
+ }
}
diff --git a/src/trex_client_config.cpp b/src/trex_client_config.cpp
index bb2b7772..8569cbf0 100644
--- a/src/trex_client_config.cpp
+++ b/src/trex_client_config.cpp
@@ -70,10 +70,8 @@ ClientCfgDB::load_yaml_file(const std::string &filename) {
m_groups.clear();
m_cache_group = NULL;
- m_filename = filename;
-
if (!utl_is_file_exists(filename)){
- ss << "*** file '" << filename << "' does not exists";
+ ss << "file '" << filename << "' does not exists";
throw std::runtime_error(ss.str());
}
@@ -85,12 +83,11 @@ ClientCfgDB::load_yaml_file(const std::string &filename) {
try {
base_parser.GetNextDocument(root);
} catch (const std::runtime_error &ex) {
- throw std::runtime_error("*** failed to parse client config file '" + filename + "'\n " + std::string(ex.what()));
-
+ throw std::runtime_error("failed to parse client config file '" + filename + "'\n " + std::string(ex.what()));
}
/* wrapper parser */
- YAMLParserWrapper parser(m_filename);
+ YAMLParserWrapper parser(filename);
/* parse globals */
m_under_vlan = parser.parse_bool(root, "vlan");
diff --git a/src/trex_client_config.h b/src/trex_client_config.h
index bb378450..a5bb83b3 100644
--- a/src/trex_client_config.h
+++ b/src/trex_client_config.h
@@ -258,7 +258,6 @@ private:
bool m_under_vlan;
ClientCfgEntry *m_cache_group;
- std::string m_filename;
bool m_is_empty;
};
diff --git a/src/tuple_gen.cpp b/src/tuple_gen.cpp
index b8a54118..6861b73f 100755
--- a/src/tuple_gen.cpp
+++ b/src/tuple_gen.cpp
@@ -130,7 +130,7 @@ void CClientPool::allocate_configured_clients(uint32_t min_ip,
ClientCfgEntry *group = client_info.lookup(ip);
if (!group) {
std::stringstream ss;
- ss << "*** client configuration error: could not map IP '" << ip_to_str(ip) << "' to a group\n";
+ ss << "client configuration error: could not map IP '" << ip_to_str(ip) << "' to a group\n";
throw std::runtime_error(ss.str());
}
diff --git a/src/utl_yaml.cpp b/src/utl_yaml.cpp
index 444031c6..66c83ac8 100755
--- a/src/utl_yaml.cpp
+++ b/src/utl_yaml.cpp
@@ -322,7 +322,7 @@ void
YAMLParserWrapper::parse_err(const std::string &err, const YAML::Node &node) const {
std::stringstream ss;
- ss << "\n*** '" << m_header << "' - YAML parsing error at line " << node.GetMark().line << ": ";
+ ss << "'" << m_header << "' - YAML parsing error at line " << node.GetMark().line << ": ";
ss << err;
throw std::runtime_error(ss.str());
@@ -332,7 +332,7 @@ void
YAMLParserWrapper::parse_err(const std::string &err) const {
std::stringstream ss;
- ss << "\n*** '" << m_header << "' - YAML parsing error: " << err;
+ ss << "'" << m_header << "' - YAML parsing error: " << err;
throw std::runtime_error(ss.str());
}