summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2015-08-19 15:31:58 +0300
committerimarom <imarom@cisco.com>2015-08-19 15:31:58 +0300
commit2a4d1ac17610d15c65d6337306ffeda04ab29bef (patch)
tree2645d90e98aa5e5bffb210e551339ca9f1e4a586 /src
parent2acb002ded9dd522af059f3d80f3f26a4e70c1d4 (diff)
mock server
Diffstat (limited to 'src')
-rw-r--r--src/gtest/rpc_test.cpp18
-rwxr-xr-xsrc/main.cpp13
-rw-r--r--src/rpc-server/src/trex_rpc_server_mock.cpp14
3 files changed, 22 insertions, 23 deletions
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";