From 2e72d446ad714f44d240487c1e85644f28e20f97 Mon Sep 17 00:00:00 2001 From: imarom Date: Tue, 11 Aug 2015 15:28:32 +0300 Subject: added support for c++ 2011 this requires some compiler support (checking version, adding RPATH) --- linux/b | 2 +- linux/ws_main.py | 47 +++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 40 insertions(+), 9 deletions(-) (limited to 'linux') diff --git a/linux/b b/linux/b index a308cf60..b33a4400 100755 --- a/linux/b +++ b/linux/b @@ -1,5 +1,5 @@ #! /bin/bash -/router/bin/python-2.7.1 waf-1.6.8 $@ +python2.7 waf-1.6.8 $@ sts=$? exit $sts diff --git a/linux/ws_main.py b/linux/ws_main.py index 93ed02b8..b6e4fcc2 100755 --- a/linux/ws_main.py +++ b/linux/ws_main.py @@ -7,15 +7,18 @@ VERSION='0.0.1' APPNAME='cxx_test' + import os; import commands; import shutil; import copy; +from distutils.version import StrictVersion top = '../' out = 'build' b_path ="./build/linux/" +REQUIRED_CC_VERSION = "4.7.0" class SrcGroup: ' group of source by directory ' @@ -68,8 +71,25 @@ class SrcGroups: def options(opt): opt.load('compiler_cxx') + +def verify_cc_version (env): + ver = '.'.join(env['CC_VERSION']) + + if StrictVersion(ver) < REQUIRED_CC_VERSION: + print "\nMachine GCC version too low '{0}' - required at least '{1}'".format(ver, REQUIRED_CC_VERSION) + print "\n*** please set a compiler using CXX / AR enviorment variables ***\n" + exit(-1) + + def configure(conf): + # start from clean + if 'RPATH' in os.environ: + conf.env.RPATH = os.environ['RPATH'].split(':') + else: + conf.env.RPATH = [] + conf.load('g++') + verify_cc_version(conf.env) main_src = SrcGroup(dir='src', @@ -118,6 +138,12 @@ net_src = SrcGroup(dir='src/common/Network/Packet', 'MacAddress.cpp', 'VLANHeader.cpp']); +# JSON package +json_src = SrcGroup(dir='external_libs/json', + src_list=[ + 'jsoncpp.cpp' + ]) + yaml_src = SrcGroup(dir='yaml-cpp/src/', src_list=[ 'aliasmanager.cpp', @@ -152,15 +178,18 @@ bp =SrcGroups([ main_src, cmn_src , net_src , - yaml_src + yaml_src, + json_src ]); cxxflags_base =['-DWIN_UCODE_SIM', - '-D_BYTE_ORDER', - '-D_LITTLE_ENDIAN', - '-DLINUX', - '-g', + '-D_BYTE_ORDER', + '-D_LITTLE_ENDIAN', + '-DLINUX', + '-g', + '-Wno-deprecated-declarations', + '-std=c++0x', ]; @@ -268,9 +297,11 @@ class build_option: #platform depended flags if self.is64Platform(): - base_flags += ['-m64']; + base_flags += ['-m64'] else: - base_flags += ['-lrt']; + base_flags += ['-m32'] + base_flags += ['-lrt'] + if self.isPIE(): base_flags += ['-pie', '-DPATCH_FOR_PIE'] @@ -293,9 +324,9 @@ def build_prog (bld, build_obj): bld.program(features='cxx cxxprogram', includes =includes_path, cxxflags =build_obj.get_flags(), - stlib = 'stdc++', linkflags = build_obj.get_link_flags(), source = bp.file_list(top), + rpath = bld.env.RPATH, target = build_obj.get_target()) -- cgit 1.2.3-korg From 2acb002ded9dd522af059f3d80f3f26a4e70c1d4 Mon Sep 17 00:00:00 2001 From: imarom Date: Wed, 19 Aug 2015 13:12:10 +0300 Subject: draft --- .gitignore | 1 + linux/ws_main.py | 67 ++++++++-- src/console/trex_console.py | 36 +++--- src/console/trex_rpc_client.py | 4 +- src/console/trex_status.py | 183 ++++++++-------------------- src/main.cpp | 4 +- src/rpc-server/src/trex_rpc_server_mock.cpp | 60 +++++++++ 7 files changed, 192 insertions(+), 163 deletions(-) create mode 100644 src/rpc-server/src/trex_rpc_server_mock.cpp (limited to 'linux') diff --git a/.gitignore b/.gitignore index 26668730..71cce64e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ linux_dpdk* linux* scripts/_t-rex-* scripts/bp-sim-* +scripts/mock-* *.pyc diff --git a/linux/ws_main.py b/linux/ws_main.py index b6e4fcc2..37051ebe 100755 --- a/linux/ws_main.py +++ b/linux/ws_main.py @@ -111,6 +111,7 @@ 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' @@ -138,11 +139,35 @@ net_src = SrcGroup(dir='src/common/Network/Packet', 'MacAddress.cpp', 'VLANHeader.cpp']); +# RPC code +rpc_server_src = SrcGroup(dir='src/rpc-server/src', + src_list=[ + 'trex_rpc_server.cpp', + 'trex_rpc_req_resp_server.cpp', + 'trex_rpc_jsonrpc_v2_parser.cpp', + 'trex_rpc_cmds_table.cpp', + + 'commands/trex_rpc_cmd_test.cpp', + 'commands/trex_rpc_cmd_general.cpp', + + ]) + +# RPC mock server (test) +rpc_server_mock_src = SrcGroup(dir='src/rpc-server/src', + src_list=[ + 'trex_rpc_server_mock.cpp' + ]) + # JSON package json_src = SrcGroup(dir='external_libs/json', - src_list=[ - 'jsoncpp.cpp' - ]) + src_list=[ + 'jsoncpp.cpp' + ]) + +rpc_server_mock = SrcGroups([rpc_server_src, + rpc_server_mock_src, + json_src + ]) yaml_src = SrcGroup(dir='yaml-cpp/src/', src_list=[ @@ -178,6 +203,7 @@ bp =SrcGroups([ main_src, cmn_src , net_src , + rpc_server_src, yaml_src, json_src ]); @@ -196,7 +222,10 @@ cxxflags_base =['-DWIN_UCODE_SIM', includes_path =''' ../src/pal/linux/ + ../src/zmq/include/ ../src/ + ../src/rpc-server/include + ../external_libs/json/ ../yaml-cpp/include/ '''; @@ -212,10 +241,12 @@ PLATFORM_32 = "32" class build_option: - def __init__(self,platform,debug_mode,is_pie): + def __init__(self, name, src, platform, debug_mode, is_pie): self.mode = debug_mode; ##debug,release self.platform = platform; #['32','64'] self.is_pie = is_pie + self.name = name + self.src = src def __str__(self): s=self.mode+","+self.platform; @@ -283,11 +314,14 @@ class build_option: return result; def get_target (self): - return self.update_executable_name("bp-sim"); + return self.update_executable_name(self.name); def get_flags (self): return self.cxxcomp_flags(cxxflags_base); + def get_src (self): + return self.src.file_list(top) + def get_link_flags(self): # add here basic flags base_flags = ['-lpthread']; @@ -307,25 +341,28 @@ class build_option: return base_flags; - def get_exe (self,full_path = True): - return self.toExe(self.get_target(),full_path); - build_types = [ - build_option(debug_mode= DEBUG_, platform = PLATFORM_32, is_pie = False), - build_option(debug_mode= DEBUG_, platform = PLATFORM_64, is_pie = False), - build_option(debug_mode= RELEASE_,platform = PLATFORM_32, is_pie = False), - build_option(debug_mode= RELEASE_,platform = PLATFORM_64, is_pie = False), + build_option(name = "bp-sim", src = bp, debug_mode= DEBUG_, platform = PLATFORM_32, is_pie = False), + build_option(name = "bp-sim", src = bp, debug_mode= DEBUG_, platform = PLATFORM_64, is_pie = False), + 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), ] def build_prog (bld, build_obj): + zmq_lib_path='src/zmq/' + bld.read_shlib( name='zmq' , paths=[top + zmq_lib_path] ) + bld.program(features='cxx cxxprogram', includes =includes_path, cxxflags =build_obj.get_flags(), linkflags = build_obj.get_link_flags(), - source = bp.file_list(top), + source = build_obj.get_src(), + use = ['zmq'], rpath = bld.env.RPATH, target = build_obj.get_target()) @@ -336,15 +373,19 @@ def build_type(bld,build_obj): def post_build(bld): print "copy objects" + exec_p ="../scripts/" + for obj in build_types: install_single_system(bld, exec_p, obj); def build(bld): + bld.add_post_fun(post_build); for obj in build_types: build_type(bld,obj); + def build_info(bld): pass; diff --git a/src/console/trex_console.py b/src/console/trex_console.py index 15022e06..584089ae 100755 --- a/src/console/trex_console.py +++ b/src/console/trex_console.py @@ -12,10 +12,14 @@ class TrexConsole(cmd.Cmd): def __init__(self, rpc_client): cmd.Cmd.__init__(self) self.prompt = "TRex > " - self.intro = "\n-=TRex Console V1.0=-\n" + + self.intro = "\n-=TRex Console V1.0=-\n" + self.intro += "\nType 'help' or '?' for supported actions\n" + self.rpc_client = rpc_client self.verbose = False + # before starting query the RPC server and add the methods rc, msg = self.rpc_client.query_rpc_server() if rc: @@ -29,20 +33,22 @@ class TrexConsole(cmd.Cmd): # set verbose on / off def do_verbose (self, line): - '''shows or set verbose mode\nusage: verbose [on/off]\n''' + '''\nshows or set verbose mode\nusage: verbose [on/off]\n''' if line == "": - print "verbose is " + ("on" if self.verbose else "off") + print "\nverbose is " + ("on\n" if self.verbose else "off\n") + elif line == "on": self.verbose = True self.rpc_client.set_verbose(True) - print "verbose set to on\n" + print "\nverbose set to on\n" elif line == "off": self.verbose = False self.rpc_client.set_verbose(False) - print "verbose set to off\n" + print "\nverbose set to off\n" + else: - print "please specify 'on' or 'off'\n" + print "\nplease specify 'on' or 'off'\n" # query the server for registered commands def do_query_server(self, line): @@ -51,11 +57,11 @@ class TrexConsole(cmd.Cmd): if not rc: print "\n*** Failed to query RPC server: " + str(msg) - print "RPC server supports the following commands: \n\n" + msg + print "\nRPC server supports the following commands: \n\n" + msg def do_ping (self, line): - '''pings the RPC server\n''' - print "Pinging RPC server" + '''\npings the RPC server\n''' + print "\n-> Pinging RPC server" rc, msg = self.rpc_client.ping_rpc_server() if rc: @@ -64,9 +70,9 @@ class TrexConsole(cmd.Cmd): print "[FAILED]\n" def do_rpc (self, line): - '''Launches a RPC on the server\n''' + '''\nLaunches a RPC on the server\n''' if line == "": - print "Please provide method name\n" + print "\nUsage: [method name] [param 1] ...\n" return rc, msg = self.rpc_client.invoke_rpc_method(line) @@ -81,7 +87,9 @@ class TrexConsole(cmd.Cmd): return [x for x in self.supported_rpc if x.startswith(text)] def do_status (self, line): - '''Shows a graphical console\n''' + '''\nShows a graphical console\n''' + + self.do_verbose('off') trex_status.show_trex_status(self.rpc_client) def do_quit(self, line): @@ -89,10 +97,10 @@ class TrexConsole(cmd.Cmd): return True def default(self, line): - print "'{0}' is an unrecognized command\n".format(line) + print "'{0}' is an unrecognized command. type 'help' or '?' for a list\n".format(line) # aliasing - do_EOF = do_q = do_quit + do_exit = do_EOF = do_q = do_quit def main (): # RPC client diff --git a/src/console/trex_rpc_client.py b/src/console/trex_rpc_client.py index 4562cf23..fe8f69a2 100644 --- a/src/console/trex_rpc_client.py +++ b/src/console/trex_rpc_client.py @@ -39,7 +39,7 @@ class RpcClient(): msg = self.create_jsonrpc_v2(method_name, params, id = 1) if self.verbose: - print "\nSending Request To Server: " + str(msg) + "\n" + print "\n[verbose] Sending Request To Server: " + str(msg) + "\n" if block: self.socket.send(msg) @@ -67,7 +67,7 @@ class RpcClient(): return False, "Failed To Get Server Response" if self.verbose: - print "Server Response: " + str(response) + "\n" + print "[verbose] Server Response: " + str(response) # decode response_json = json.loads(response) diff --git a/src/console/trex_status.py b/src/console/trex_status.py index 20d70534..8ee669b5 100755 --- a/src/console/trex_status.py +++ b/src/console/trex_status.py @@ -85,6 +85,7 @@ class TrexStatus(): return win, panel1 + # static info panel def update_info (self): if self.server_status == None: return @@ -99,106 +100,12 @@ class TrexStatus(): self.server_status["general"]["build_date"] + " @ " + self.server_status["general"]["build_time"] + " by " + self.server_status["general"]["version_user"])) self.info_panel.getwin().addstr(6, 2, "{:<30} {:30}".format("Server Uptime:", self.server_status["general"]["uptime"])) - #self.ft_panel.clear() - - #ft_section_y = 3 - #self.ft_panel.getwin().addstr(ft_section_y, 2,"General Info:", curses.A_UNDERLINE) - - #self.ft_panel.getwin().addstr(ft_section_y, 2, "{:<30} {:<30,}".format("Total Flows Opened:", ft_stats["total-opened-flows"])) - #ft_section_y = ft_section_y + 1 - #self.ft_panel.getwin().addstr(ft_section_y, 2, "{:<30} {:<30,}".format("Total Flows Closed:", ft_stats["total-closed-flows"])) - #ft_section_y = ft_section_y + 1 - #self.ft_panel.getwin().addstr(ft_section_y, 2, "{:<30} {:<30,}".format("Current Active Flows:", ft_stats["active-flows"])) - #ft_section_y = ft_section_y + 1 - #self.ft_panel.getwin().addstr(ft_section_y, 2, "{:<30} {:<30,}".format("Flow Allocation Errors:", ft_stats["allocation_err"])) + # general stats def update_general (self, gen_stats): + pass - if not gen_stats: - return - - transport_info_section_y = 3 - general_info_section_y = int(self.cls_panel.h * 0.5) - - self.general_panel.clear() - - # transport layer info - self.general_panel.getwin().addstr(transport_info_section_y, 2, "{:<30} {:^10} {:^5} {:^10}".format("Total Tx Rate:", - float_to_human_readable(gen_stats["total-rx-bps"]), - "/", - float_to_human_readable(gen_stats["total-rx-pps"], suffix = "pps"))) - transport_info_section_y += 2 - - - self.general_panel.getwin().addstr(transport_info_section_y, 2, "{:<30} {:^6.2f} %".format("DP Core Util.:", gen_stats["cpu-util"])); - - transport_info_section_y += 2 - - for i in range(1, 3): - self.general_panel.getwin().addstr(transport_info_section_y, 2, "{:<30} {:^10} {:^5} {:^10}".format("Port {0} Rx:".format(i), - float_to_human_readable(gen_stats["port " + str(i)]["total-rx-bps"]), - "/", - float_to_human_readable(gen_stats["port " + str(i)]["total-rx-pps"], suffix = "pps"))) - transport_info_section_y += 1 - - - self.general_panel.getwin().addstr(general_info_section_y, 2,"General Info:", curses.A_UNDERLINE) - general_info_section_y = general_info_section_y + 2 - - self.general_panel.getwin().addstr(general_info_section_y, 2, "{:<30} {:<30}".format("VNBAR Main Process PID:", os.getppid())) - general_info_section_y = general_info_section_y + 1 - self.general_panel.getwin().addstr(general_info_section_y, 2, "{:<30} {:<30}".format("ZMQ client online at:", vnbar_ipc.VnbarIpc.get_zmq_transport_name())) - - - # v2 - def update_cls (self, pd_stats): - if not pd_stats: - return - - self.cls_panel.clear() - - section_start = 3 - section_size = (self.cls_panel.h / 2) - 5 - - for port_name, pd in sorted(pd_stats.iteritems()): - if pd == None: - continue - - # sort by bandwidth - pd = collections.OrderedDict(sorted(pd.items(), key=operator.itemgetter(1), reverse = True)) - - # restart the line index - line_index = 0 - - # headline - self.cls_panel.getwin().addstr(section_start + line_index, 2, "{0}:".format(port_name), curses.A_BOLD | curses.A_UNDERLINE) - line_index += 1 - - cls_str = "{:^45} {:^20} {:^20} {:^20}".format("Protocol Name", "Byte Count", "Packet Count", "B/W Perc.") - self.cls_panel.getwin().addstr(section_start + line_index, 2, cls_str) - line_index += 2 - - # protocols - proto_index = 0 - proto_count = len(pd) - - total_bandwidth = sum([i['bytes'] for i in pd.values()]) - - for proto_name, cnts in pd.iteritems(): - proto_str = "{:<45} {:^20,} {:^20,} {:^20}".format(proto_name, cnts['bytes'], cnts['pkts'], percentage(cnts['bytes'], total_bandwidth) ) - proto_index = proto_index + 1 - - if line_index > section_size: - self.cls_panel.getwin().addstr(section_start + line_index, 2, "<...{0} More...>".format(proto_count - proto_index), (curses.A_DIM if ((line_index % 2) == 0) else curses.A_BOLD)) - break - - self.cls_panel.getwin().addstr(section_start + line_index, 2, proto_str, (curses.A_DIM if ((line_index % 2) == 0) else curses.A_BOLD)) - - line_index += 1 - - section_start = section_start + section_size + 3 - - + # control panel def update_control (self): self.control_panel.clear() @@ -214,17 +121,7 @@ class TrexStatus(): self.control_panel.getwin().addstr(index, 2, l) index += 1 - def run (self): - try: - curses.curs_set(0) - except: - pass - - curses.use_default_colors() - self.stdscr.nodelay(1) - curses.nonl() - curses.noecho() - + def generate_layout (self): self.max_y = self.stdscr.getmaxyx()[0] self.max_x = self.stdscr.getmaxyx()[1] @@ -239,32 +136,54 @@ class TrexStatus(): panel.update_panels(); self.stdscr.refresh() + def wait_for_key_input (self): + ch = self.stdscr.getch() + + if (ch != curses.ERR): + # stop/start status + if (ch == ord('f')): + self.update_active = not self.update_active + self.add_log_event("Update continued" if self.update_active else "Update stopped") + + elif (ch == ord('p')): + self.add_log_event("Pinging RPC server") + rc, msg = self.rpc_client.ping_rpc_server() + if rc: + self.add_log_event("Server replied: '{0}'".format(msg)) + else: + self.add_log_event("Failed to get reply") + + # c - clear stats + elif (ch == ord('c')): + self.add_log_event("Statistics cleared") + + elif (ch == ord('q')): + return False + else: + self.add_log_event("Unknown key pressed {0}".format("'" + chr(ch) + "'" if chr(ch).isalpha() else "")) + + return True + + # main run entry point + def run (self): + try: + curses.curs_set(0) + except: + pass + + curses.use_default_colors() + self.stdscr.nodelay(1) + curses.nonl() + curses.noecho() + + self.generate_layout() + self.update_active = True while (True): - ch = self.stdscr.getch() - - if (ch != curses.ERR): - # stop/start status - if (ch == ord('f')): - self.update_active = not self.update_active - self.add_log_event("Update continued" if self.update_active else "Update stopped") - - elif (ch == ord('p')): - self.add_log_event("Pinging RPC server") - rc, msg = self.rpc_client.ping_rpc_server() - if rc: - self.add_log_event("Server replied: '{0}'".format(msg)) - else: - self.add_log_event("Failed to get reply") - - # c - clear stats - elif (ch == ord('c')): - self.add_log_event("Statistics cleared") - - elif (ch == ord('q')): - break - else: - self.add_log_event("Unknown key pressed {0}".format("'" + chr(ch) + "'" if chr(ch).isalpha() else "")) + + rc = self.wait_for_key_input() + if not rc: + break self.update_control() self.update_info() diff --git a/src/main.cpp b/src/main.cpp index e3176be3..ddcf81e2 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,11 +32,11 @@ limitations under the License. * (improved stub) * */ -extern "C" char * get_build_date(void){ +extern "C" const char * get_build_date(void){ return (__DATE__); } -extern "C" char * get_build_time(void){ +extern "C" const char * get_build_time(void){ return (__TIME__ ); } diff --git a/src/rpc-server/src/trex_rpc_server_mock.cpp b/src/rpc-server/src/trex_rpc_server_mock.cpp new file mode 100644 index 00000000..3c63f74a --- /dev/null +++ b/src/rpc-server/src/trex_rpc_server_mock.cpp @@ -0,0 +1,60 @@ +/* + Itay Marom + Cisco Systems, Inc. +*/ + +/* +Copyright (c) 2015-2015 Cisco Systems, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#include +#include +#include + +using namespace std; + +/** + * 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__ ); +} + +int main() { + cout << "\n-= Starting RPC Server Mock =-\n\n"; + cout << "Listening on tcp://localhost:5050 [ZMQ]\n\n"; + + TrexRpcServerConfig rpc_cfg(TrexRpcServerConfig::RPC_PROT_TCP, 5050); + TrexRpcServer rpc(rpc_cfg); + + /* init the RPC server */ + rpc.start(); + + cout << "Server Started\n\n"; + + while (true) { + sleep(1); + } + + rpc.stop(); + + +} -- cgit 1.2.3-korg From 2a4d1ac17610d15c65d6337306ffeda04ab29bef Mon Sep 17 00:00:00 2001 From: imarom Date: Wed, 19 Aug 2015 15:31:58 +0300 Subject: mock server --- linux/ws_main.py | 25 ++++++++++++++----------- src/gtest/rpc_test.cpp | 18 +++++++++--------- src/main.cpp | 13 ------------- src/rpc-server/src/trex_rpc_server_mock.cpp | 14 +++++++++++++- 4 files changed, 36 insertions(+), 34 deletions(-) (limited to 'linux') 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 #include -/** - * 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"; -- cgit 1.2.3-korg From 3bfe53394f43a37ce02b09c6420751027c602047 Mon Sep 17 00:00:00 2001 From: Hanoh Haim Date: Sun, 23 Aug 2015 15:43:38 +0300 Subject: remove mock for now --- linux/ws_main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'linux') diff --git a/linux/ws_main.py b/linux/ws_main.py index 674b0dc2..6a8967bf 100755 --- a/linux/ws_main.py +++ b/linux/ws_main.py @@ -349,9 +349,9 @@ build_types = [ build_option(name = "bp-sim", src = bp, debug_mode= DEBUG_, platform = PLATFORM_32, is_pie = False), build_option(name = "bp-sim", src = bp, debug_mode= DEBUG_, platform = PLATFORM_64, is_pie = False), 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 = "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), + #build_option(name = "mock-rpc-server", use = ['zmq'], src = rpc_server_mock, debug_mode= DEBUG_,platform = PLATFORM_64, is_pie = False), ] -- cgit 1.2.3-korg