From 857bdcf05a920b99e1cf180c700176b04801da00 Mon Sep 17 00:00:00 2001
From: imarom <imarom@cisco.com>
Date: Mon, 4 Jan 2016 09:49:37 -0500
Subject: some additions to the stateless simulation mode

---
 .../client/trex_stateless_sim.py                   | 32 ++++++++++++++++++++--
 1 file changed, 29 insertions(+), 3 deletions(-)

(limited to 'scripts/automation/trex_control_plane')

diff --git a/scripts/automation/trex_control_plane/client/trex_stateless_sim.py b/scripts/automation/trex_control_plane/client/trex_stateless_sim.py
index 7829af60..7655b27c 100644
--- a/scripts/automation/trex_control_plane/client/trex_stateless_sim.py
+++ b/scripts/automation/trex_control_plane/client/trex_stateless_sim.py
@@ -38,13 +38,15 @@ import os
 
 
 class SimRun(object):
-    def __init__ (self, yaml_file, dp_core_count, core_index, packet_limit, output_filename):
+    def __init__ (self, yaml_file, dp_core_count, core_index, packet_limit, output_filename, is_valgrind, is_gdb):
 
         self.yaml_file = yaml_file
         self.output_filename = output_filename
         self.dp_core_count = dp_core_count
         self.core_index = core_index
         self.packet_limit = packet_limit
+        self.is_valgrind = is_valgrind
+        self.is_gdb = is_gdb
 
         # dummies
         self.handler = 0
@@ -97,7 +99,14 @@ class SimRun(object):
         f.close()
 
         try:
-            subprocess.call(['bp-sim-64-debug', '--sl', '-f', f.name, '-o', self.output_filename])
+            cmd = ['bp-sim-64-debug', '--sl', '--cores', str(self.dp_core_count), '--core_index', str(self.core_index), '-f', f.name, '-o', self.output_filename]
+            if self.is_valgrind:
+                cmd = ['valgrind', '--leak-check=full'] + cmd
+            elif self.is_gdb:
+                cmd = ['gdb', '--args'] + cmd
+
+            subprocess.call(cmd)
+
         finally:
             os.unlink(f.name)
 
@@ -149,6 +158,17 @@ def setParserOptions():
                         type = unsigned_int)
 
 
+    group = parser.add_mutually_exclusive_group()
+
+    group.add_argument("-x", "--valgrind",
+                       help = "run under valgrind [default is False]",
+                       action = "store_true",
+                       default = False)
+
+    group.add_argument("-g", "--gdb",
+                       help = "run under GDB [default is False]",
+                       action = "store_true",
+                       default = False)
 
     return parser
 
@@ -165,7 +185,13 @@ def main ():
 
     validate_args(parser, options)
 
-    r = SimRun(options.input_file, options.cores, options.core_index, options.limit, options.output_file)
+    r = SimRun(options.input_file,
+               options.cores,
+               options.core_index,
+               options.limit,
+               options.output_file,
+               options.valgrind,
+               options.gdb)
 
     r.run()
 
-- 
cgit