From 3b372bbe45931b853f3f906352a0cbdc89952c41 Mon Sep 17 00:00:00 2001 From: imarom Date: Wed, 16 Sep 2015 17:12:30 +0300 Subject: enabled all warnings for the mock RPC server target --- linux/ws_main.py | 3 +- src/common/captureFile.cpp | 2 +- src/gtest/rpc_test.cpp | 61 ++++++++++++++++++++++++ src/rpc-server/commands/trex_rpc_cmd_general.cpp | 2 - src/rpc-server/trex_rpc_cmd_api.h | 3 ++ src/stateless/trex_stateless.cpp | 2 +- 6 files changed, 68 insertions(+), 5 deletions(-) diff --git a/linux/ws_main.py b/linux/ws_main.py index e9f21d11..789895d9 100755 --- a/linux/ws_main.py +++ b/linux/ws_main.py @@ -368,7 +368,8 @@ 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", use = ['zmq'], src = rpc_server_mock, debug_mode= DEBUG_,platform = PLATFORM_64, is_pie = False, flags = ['-DTREX_RPC_MOCK_SERVER'], + build_option(name = "mock-rpc-server", use = ['zmq'], src = rpc_server_mock, debug_mode= DEBUG_,platform = PLATFORM_64, is_pie = False, + flags = ['-DTREX_RPC_MOCK_SERVER', '-Wall', '-Wno-sign-compare', '-Werror'], rpath = ['.']), ] 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 #include #include +#include +#include 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 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 #include -//#include - #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; } } -- cgit 1.2.3-korg