diff options
author | imarom <imarom@cisco.com> | 2015-09-16 17:12:30 +0300 |
---|---|---|
committer | imarom <imarom@cisco.com> | 2015-09-16 17:12:30 +0300 |
commit | 3b372bbe45931b853f3f906352a0cbdc89952c41 (patch) | |
tree | 994c08f5b916029d7d700e502b0d37e63b3c1397 /src | |
parent | dd99c3890d3bb7b4aab833927e85648cd6e86c85 (diff) |
enabled all warnings for the mock RPC server target
Diffstat (limited to 'src')
-rwxr-xr-x | src/common/captureFile.cpp | 2 | ||||
-rw-r--r-- | src/gtest/rpc_test.cpp | 61 | ||||
-rw-r--r-- | src/rpc-server/commands/trex_rpc_cmd_general.cpp | 2 | ||||
-rw-r--r-- | src/rpc-server/trex_rpc_cmd_api.h | 3 | ||||
-rw-r--r-- | src/stateless/trex_stateless.cpp | 2 |
5 files changed, 66 insertions, 4 deletions
diff --git a/src/common/captureFile.cpp b/src/common/captureFile.cpp index a4fe78be..00625181 100755 --- a/src/common/captureFile.cpp +++ b/src/common/captureFile.cpp @@ -110,7 +110,7 @@ void CCapPktRaw::CloneShalow(CCapPktRaw *obj){ } void CCapPktRaw::Dump(FILE *fd,int verbose){ - fprintf(fd," =>pkt (%p) %llu , len %d, time [%x:%x] \n",raw,pkt_cnt,pkt_len,time_sec,time_nsec); + fprintf(fd," =>pkt (%p) %llu , len %d, time [%x:%x] \n",raw, (unsigned long long)pkt_cnt,pkt_len,time_sec,time_nsec); if (verbose) { utl_DumpBuffer(fd,raw,pkt_len,0); } diff --git a/src/gtest/rpc_test.cpp b/src/gtest/rpc_test.cpp index 02d88eae..58197000 100644 --- a/src/gtest/rpc_test.cpp +++ b/src/gtest/rpc_test.cpp @@ -25,6 +25,8 @@ limitations under the License. #include <zmq.h> #include <json/json.h> #include <sstream> +#include <vector> +#include <algorithm> using namespace std; @@ -518,3 +520,62 @@ TEST_F(RpcTestOwned, add_remove_stream) { } +TEST_F(RpcTestOwned, get_stream_id_list) { + Json::Value request; + Json::Value response; + Json::Reader reader; + + + /* add stream 1 */ + create_request(request, "add_stream"); + request["params"]["port_id"] = 1; + + + Json::Value stream; + create_simple_stream(stream); + + request["params"]["stream"] = stream; + + request["params"]["stream_id"] = 5; + send_request(request, response); + EXPECT_EQ(response["result"], "ACK"); + + request["params"]["stream_id"] = 12; + send_request(request, response); + EXPECT_EQ(response["result"], "ACK"); + + request["params"]["stream_id"] = 19; + send_request(request, response); + EXPECT_EQ(response["result"], "ACK"); + + + create_request(request, "get_stream_list"); + request["params"]["port_id"] = 1; + send_request(request, response); + + EXPECT_TRUE(response["result"].isArray()); + vector<int> vec; + for (auto x : response["result"]) { + vec.push_back(x.asInt()); + } + + sort(vec.begin(), vec.end()); + + EXPECT_EQ(vec[0], 5); + EXPECT_EQ(vec[1], 12); + EXPECT_EQ(vec[2], 19); + + create_request(request, "remove_all_streams"); + request["params"]["port_id"] = 1; + send_request(request, response); + + EXPECT_TRUE(response["result"] == "ACK"); + + /* make sure the lights are off ... */ + create_request(request, "get_stream_list"); + request["params"]["port_id"] = 1; + send_request(request, response); + + EXPECT_TRUE(response["result"].isArray()); + EXPECT_TRUE(response["result"].size() == 0); +} diff --git a/src/rpc-server/commands/trex_rpc_cmd_general.cpp b/src/rpc-server/commands/trex_rpc_cmd_general.cpp index afa15973..fcdb7acf 100644 --- a/src/rpc-server/commands/trex_rpc_cmd_general.cpp +++ b/src/rpc-server/commands/trex_rpc_cmd_general.cpp @@ -28,8 +28,6 @@ limitations under the License. #include <iostream> #include <unistd.h> -//#include <netdb.h> - #ifndef TREX_RPC_MOCK_SERVER #include <../linux_dpdk/version.h> #endif diff --git a/src/rpc-server/trex_rpc_cmd_api.h b/src/rpc-server/trex_rpc_cmd_api.h index c72b3e3b..cab50cfd 100644 --- a/src/rpc-server/trex_rpc_cmd_api.h +++ b/src/rpc-server/trex_rpc_cmd_api.h @@ -177,6 +177,9 @@ protected: s.pop_back(); s += "]"; generate_parse_err(result, s); + + /* dummy return value - does not matter, the above will throw exception */ + return (*choices.begin()); } /** diff --git a/src/stateless/trex_stateless.cpp b/src/stateless/trex_stateless.cpp index b51c4e69..537dfa4a 100644 --- a/src/stateless/trex_stateless.cpp +++ b/src/stateless/trex_stateless.cpp @@ -107,7 +107,7 @@ void TrexStatelessPort::stop_traffic(void) { /* real code goes here */ - if (m_port_state = PORT_STATE_TRANSMITTING) { + if (m_port_state == PORT_STATE_TRANSMITTING) { m_port_state = PORT_STATE_UP_IDLE; } } |