diff options
-rwxr-xr-x | linux/ws_main.py | 25 | ||||
-rw-r--r-- | src/gtest/rpc_test.cpp | 18 | ||||
-rwxr-xr-x | src/main.cpp | 13 | ||||
-rw-r--r-- | src/rpc-server/src/trex_rpc_server_mock.cpp | 14 |
4 files changed, 36 insertions, 34 deletions
diff --git a/linux/ws_main.py b/linux/ws_main.py index 37051ebe..674b0dc2 100755 --- a/linux/ws_main.py +++ b/linux/ws_main.py @@ -111,7 +111,6 @@ main_src = SrcGroup(dir='src', 'msg_manager.cpp', 'gtest/tuple_gen_test.cpp', 'gtest/nat_test.cpp', - 'gtest/rpc_test.cpp', 'pal/linux/pal_utl.cpp', 'pal/linux/mbuf.cpp' @@ -155,7 +154,8 @@ rpc_server_src = SrcGroup(dir='src/rpc-server/src', # RPC mock server (test) rpc_server_mock_src = SrcGroup(dir='src/rpc-server/src', src_list=[ - 'trex_rpc_server_mock.cpp' + 'trex_rpc_server_mock.cpp', + '../../gtest/rpc_test.cpp', ]) # JSON package @@ -164,10 +164,11 @@ json_src = SrcGroup(dir='external_libs/json', 'jsoncpp.cpp' ]) -rpc_server_mock = SrcGroups([rpc_server_src, - rpc_server_mock_src, - json_src - ]) +rpc_server_mock = SrcGroups([cmn_src, + rpc_server_src, + rpc_server_mock_src, + json_src + ]) yaml_src = SrcGroup(dir='yaml-cpp/src/', src_list=[ @@ -203,9 +204,7 @@ bp =SrcGroups([ main_src, cmn_src , net_src , - rpc_server_src, yaml_src, - json_src ]); @@ -241,12 +240,13 @@ PLATFORM_32 = "32" class build_option: - def __init__(self, name, src, platform, debug_mode, is_pie): + def __init__(self, name, src, platform, debug_mode, is_pie, use = []): self.mode = debug_mode; ##debug,release self.platform = platform; #['32','64'] self.is_pie = is_pie self.name = name self.src = src + self.use = use def __str__(self): s=self.mode+","+self.platform; @@ -313,6 +313,9 @@ class build_option: return result; + def get_use_libs (self): + return self.use + def get_target (self): return self.update_executable_name(self.name); @@ -348,7 +351,7 @@ build_types = [ build_option(name = "bp-sim", src = bp, debug_mode= RELEASE_,platform = PLATFORM_32, is_pie = False), build_option(name = "bp-sim", src = bp, debug_mode= RELEASE_,platform = PLATFORM_64, is_pie = False), - build_option(name = "mock-rpc-server", src = rpc_server_mock, debug_mode= DEBUG_,platform = PLATFORM_64, is_pie = False), + build_option(name = "mock-rpc-server", use = ['zmq'], src = rpc_server_mock, debug_mode= DEBUG_,platform = PLATFORM_64, is_pie = False), ] @@ -362,7 +365,7 @@ def build_prog (bld, build_obj): cxxflags =build_obj.get_flags(), linkflags = build_obj.get_link_flags(), source = build_obj.get_src(), - use = ['zmq'], + use = build_obj.get_use_libs(), rpath = bld.env.RPATH, target = build_obj.get_target()) diff --git a/src/gtest/rpc_test.cpp b/src/gtest/rpc_test.cpp index c616b7a6..068457f3 100644 --- a/src/gtest/rpc_test.cpp +++ b/src/gtest/rpc_test.cpp @@ -127,7 +127,7 @@ TEST_F(RpcTest, test_add_command) { string resp_str; /* simple add - missing paramters */ - req_str = "{\"jsonrpc\": \"2.0\", \"method\": \"test_rpc_add\", \"id\": 488}"; + req_str = "{\"jsonrpc\": \"2.0\", \"method\": \"rpc_test_add\", \"id\": 488}"; resp_str = send_msg(req_str); EXPECT_TRUE(reader.parse(resp_str, response, false)); @@ -136,7 +136,7 @@ TEST_F(RpcTest, test_add_command) { EXPECT_EQ(response["error"]["code"], -32602); /* simple add that works */ - req_str = "{\"jsonrpc\": \"2.0\", \"method\": \"test_rpc_add\", \"params\": {\"x\": 17, \"y\": -13} , \"id\": \"itay\"}"; + req_str = "{\"jsonrpc\": \"2.0\", \"method\": \"rpc_test_add\", \"params\": {\"x\": 17, \"y\": -13} , \"id\": \"itay\"}"; resp_str = send_msg(req_str); EXPECT_TRUE(reader.parse(resp_str, response, false)); @@ -145,7 +145,7 @@ TEST_F(RpcTest, test_add_command) { EXPECT_EQ(response["result"], 4); /* add with bad paratemers types */ - req_str = "{\"jsonrpc\": \"2.0\", \"method\": \"test_rpc_add\", \"params\": {\"x\": \"blah\", \"y\": -13} , \"id\": 17}"; + req_str = "{\"jsonrpc\": \"2.0\", \"method\": \"rpc_test_add\", \"params\": {\"x\": \"blah\", \"y\": -13} , \"id\": 17}"; resp_str = send_msg(req_str); EXPECT_TRUE(reader.parse(resp_str, response, false)); @@ -154,7 +154,7 @@ TEST_F(RpcTest, test_add_command) { EXPECT_EQ(response["error"]["code"], -32602); /* add with invalid count of parameters */ - req_str = "{\"jsonrpc\": \"2.0\", \"method\": \"test_rpc_add\", \"params\": {\"y\": -13} , \"id\": 17}"; + req_str = "{\"jsonrpc\": \"2.0\", \"method\": \"rpc_test_add\", \"params\": {\"y\": -13} , \"id\": 17}"; resp_str = send_msg(req_str); EXPECT_TRUE(reader.parse(resp_str, response, false)); @@ -164,7 +164,7 @@ TEST_F(RpcTest, test_add_command) { /* big numbers */ - req_str = "{\"jsonrpc\": \"2.0\", \"method\": \"test_rpc_add\", \"params\": {\"x\": 4827371, \"y\": -39181273} , \"id\": \"itay\"}"; + req_str = "{\"jsonrpc\": \"2.0\", \"method\": \"rpc_test_add\", \"params\": {\"x\": 4827371, \"y\": -39181273} , \"id\": \"itay\"}"; resp_str = send_msg(req_str); EXPECT_TRUE(reader.parse(resp_str, response, false)); @@ -183,12 +183,12 @@ TEST_F(RpcTest, batch_rpc_test) { string resp_str; req_str = "[ \ - {\"jsonrpc\": \"2.0\", \"method\": \"test_rpc_add\", \"params\": {\"x\": 22, \"y\": 17}, \"id\": \"1\"}, \ - {\"jsonrpc\": \"2.0\", \"method\": \"test_rpc_sub\", \"params\": {\"x\": 22, \"y\": 17}, \"id\": \"2\"}, \ - {\"jsonrpc\": \"2.0\", \"method\": \"test_rpc_add\", \"params\": {\"x\": 22, \"y\": \"itay\"}, \"id\": \"2\"}, \ + {\"jsonrpc\": \"2.0\", \"method\": \"rpc_test_add\", \"params\": {\"x\": 22, \"y\": 17}, \"id\": \"1\"}, \ + {\"jsonrpc\": \"2.0\", \"method\": \"rpc_test_sub\", \"params\": {\"x\": 22, \"y\": 17}, \"id\": \"2\"}, \ + {\"jsonrpc\": \"2.0\", \"method\": \"rpc_test_add\", \"params\": {\"x\": 22, \"y\": \"itay\"}, \"id\": \"2\"}, \ {\"foo\": \"boo\"}, \ {\"jsonrpc\": \"2.0\", \"method\": \"test_rpc_sheker\", \"params\": {\"name\": \"myself\"}, \"id\": 5}, \ - {\"jsonrpc\": \"2.0\", \"method\": \"test_rpc_add\", \"params\": {\"x\": 22, \"y\": 17} } \ + {\"jsonrpc\": \"2.0\", \"method\": \"rpc_test_add\", \"params\": {\"x\": 22, \"y\": 17} } \ ]"; resp_str = send_msg(req_str); diff --git a/src/main.cpp b/src/main.cpp index ddcf81e2..96789cdd 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,19 +27,6 @@ limitations under the License. #include <common/arg/SimpleGlob.h> #include <common/arg/SimpleOpt.h> -/** - * on simulation this is not rebuild every version - * (improved stub) - * - */ -extern "C" const char * get_build_date(void){ - return (__DATE__); -} - -extern "C" const char * get_build_time(void){ - return (__TIME__ ); -} - // An enum for all the option types enum { OPT_HELP, OPT_CFG, OPT_NODE_DUMP, OP_STATS, OPT_FILE_OUT, OPT_UT, OPT_PCAP, OPT_IPV6, OPT_MAC_FILE}; diff --git a/src/rpc-server/src/trex_rpc_server_mock.cpp b/src/rpc-server/src/trex_rpc_server_mock.cpp index 3c63f74a..b01fff90 100644 --- a/src/rpc-server/src/trex_rpc_server_mock.cpp +++ b/src/rpc-server/src/trex_rpc_server_mock.cpp @@ -38,7 +38,19 @@ extern "C" const char * get_build_time(void){ return (__TIME__ ); } -int main() { +int gtest_main(int argc, char **argv); + +int main(int argc, char *argv[]) { + + // gtest ? + if (argc > 1) { + if ( (string(argv[1]) != "--ut") || (argc != 2) ) { + cout << "\n[Usage] " << argv[0] << ": " << " [--ut]\n\n"; + exit(-1); + } + return gtest_main(argc, argv); + } + cout << "\n-= Starting RPC Server Mock =-\n\n"; cout << "Listening on tcp://localhost:5050 [ZMQ]\n\n"; |