summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/automation/regression/unit_tests/functional_tests/stl_basic_tests.py51
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_sim.py20
2 files changed, 46 insertions, 25 deletions
diff --git a/scripts/automation/regression/unit_tests/functional_tests/stl_basic_tests.py b/scripts/automation/regression/unit_tests/functional_tests/stl_basic_tests.py
index 47d584f5..cd653895 100644
--- a/scripts/automation/regression/unit_tests/functional_tests/stl_basic_tests.py
+++ b/scripts/automation/regression/unit_tests/functional_tests/stl_basic_tests.py
@@ -12,6 +12,8 @@ from trex_stl_lib import trex_stl_sim
import sys
import os
import subprocess
+import shlex
+from threading import Thread
@attr('run_on_trex')
class CStlBasic_Test(functional_general_test.CGeneralFunctional_Test):
@@ -36,7 +38,9 @@ class CStlBasic_Test(functional_general_test.CGeneralFunctional_Test):
for k, v in self.profiles.iteritems():
self.verify_exists(v)
- self.valgrind_profiles = [ self.profiles['imix_3pkt_vm'], self.profiles['random_size_9k'], self.profiles['imix_tuple_gen']]
+ self.valgrind_profiles = [ self.profiles['imix_3pkt_vm'],
+ self.profiles['random_size_9k'],
+ self.profiles['imix_tuple_gen'] ]
self.golden_path = os.path.join(self.test_path,"stl/golden/")
@@ -81,31 +85,21 @@ class CStlBasic_Test(functional_general_test.CGeneralFunctional_Test):
- def run_sim (self, yaml, output, options = "", silent = False):
+ def run_sim (self, yaml, output, options = "", silent = False, obj = None):
if output:
user_cmd = "-f {0} -o {1} {2}".format(yaml, output, options)
else:
user_cmd = "-f {0} {1}".format(yaml, options)
- rc = trex_stl_sim.main(args = user_cmd.split())
+ if silent:
+ user_cmd += " --silent"
- return (rc == 0)
-
-
- def golden_run (self, testname, profile, options, silent = False):
-
- output_cap = os.path.join("/tmp/", "{0}_test.cap".format(testname))
- golden_cap = os.path.join(self.test_path, "stl/golden/{0}_golden.cap".format(testname))
- if os.path.exists(output_cap):
- os.unlink(output_cap)
- try:
- rc = self.run_sim(self.profiles[profile], output_cap, options, silent)
- assert_equal(rc, True)
+ rc = trex_stl_sim.main(args = shlex.split(user_cmd))
+ if obj:
+ obj['rc'] = (rc == 0)
- self.compare_caps(output_cap, golden_cap)
+ return (rc == 0)
- finally:
- os.unlink(output_cap)
def run_py_profile_path (self, profile, options,silent = False, do_no_remove=False,compare =True, test_generated=True):
@@ -239,13 +233,26 @@ class CStlBasic_Test(functional_general_test.CGeneralFunctional_Test):
for obj in p:
self.run_py_profile_path (obj[0], obj[1], compare =obj[2], do_no_remove=True)
- # valgrind tests
+ # valgrind tests - this runs in multi thread as it safe (no output)
def test_valgrind_various_profiles (self):
print "\n"
+ threads = []
for profile in self.valgrind_profiles:
- print "\n*** testing profile '{0}' ***\n".format(profile)
- rc = self.run_sim(profile, output = None, options = "--cores 8 --limit 20 --valgrind", silent = False)
- assert_equal(rc, True)
+ print "\n*** VALGRIND: testing profile '{0}' ***\n".format(profile)
+ obj = {'t': None, 'rc': None}
+ t = Thread(target = self.run_sim,
+ kwargs = {'obj': obj, 'yaml': profile, 'output':None, 'options': "--cores 8 --limit 20 --valgrind", 'silent': True})
+ obj['t'] = t
+
+ threads.append(obj)
+ t.start()
+
+ for obj in threads:
+ obj['t'].join()
+
+ for obj in threads:
+ assert_equal(obj['rc'], True)
+
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_sim.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_sim.py
index 395c5864..614d8b77 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_sim.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_sim.py
@@ -121,7 +121,8 @@ class STLSim(object):
pkt_limit = 5000,
mult = "1",
duration = -1,
- mode = 'none'):
+ mode = 'none',
+ silent = False):
if not mode in ['none', 'gdb', 'valgrind', 'json', 'yaml','pkt','native']:
raise STLArgumentError('mode', mode)
@@ -225,6 +226,7 @@ class STLSim(object):
self.mult = mult
self.duration = duration,
self.mode = mode
+ self.silent = silent
self.__run(cmds_json)
@@ -285,7 +287,13 @@ class STLSim(object):
cmd = ['/usr/bin/gdb', '--args'] + cmd
print "executing command: '{0}'".format(" ".join(cmd))
- rc = subprocess.call(cmd)
+
+ if self.silent:
+ FNULL = open(os.devnull, 'w')
+ rc = subprocess.call(cmd, stdout=FNULL)
+ else:
+ rc = subprocess.call(cmd)
+
if rc != 0:
raise STLError('simulation has failed with error code {0}'.format(rc))
@@ -358,6 +366,11 @@ def setParserOptions():
default = False)
+ parser.add_argument("-s", "--silent",
+ help = "runs on silent mode (no stdout) [default is False]",
+ action = "store_true",
+ default = False)
+
parser.add_argument("-l", "--limit",
help = "limit test total packet count [default is 5000]",
default = 5000,
@@ -462,7 +475,8 @@ def main (args = None):
pkt_limit = options.limit,
mult = options.mult,
duration = options.duration,
- mode = mode)
+ mode = mode,
+ silent = options.silent)
except KeyboardInterrupt as e:
print "\n\n*** Caught Ctrl + C... Exiting...\n\n"