summaryrefslogtreecommitdiffstats
path: root/scripts/automation/regression/unit_tests/functional_tests/stl_basic_tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/automation/regression/unit_tests/functional_tests/stl_basic_tests.py')
-rw-r--r--scripts/automation/regression/unit_tests/functional_tests/stl_basic_tests.py65
1 files changed, 32 insertions, 33 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 88a6983f..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
@@ -8,10 +8,12 @@ from nose.tools import nottest
from nose.plugins.attrib import attr
from unit_tests.trex_general_test import CTRexScenario
from dpkt import pcap
-
+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,39 +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)
- cmd = "{0} {1}".format(self.stl_sim,
- user_cmd)
-
if silent:
- devnull = open('/dev/null', 'w')
- rc = subprocess.call(cmd, shell = True, stdout = devnull)
- else:
- print cmd
- rc = subprocess.call(cmd, shell = True)
-
- return (rc == 0)
+ user_cmd += " --silent"
+ rc = trex_stl_sim.main(args = shlex.split(user_cmd))
+ if obj:
+ obj['rc'] = (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)
+ return (rc == 0)
- self.compare_caps(output_cap, golden_cap)
-
- finally:
- os.unlink(output_cap)
def run_py_profile_path (self, profile, options,silent = False, do_no_remove=False,compare =True, test_generated=True):
@@ -170,8 +156,8 @@ class CStlBasic_Test(functional_general_test.CGeneralFunctional_Test):
["udp_inc_len_9k.py","-m 1 -l 100",True],
["udp_1pkt_range_clients.py","-m 1 -l 100",True],
["multi_burst_2st_1000pkt.py","-m 1 -l 100",True],
- #["pcap.py", "-m 1", True],
- #["pcap_with_vm.py", "-m 1", True],
+ ["pcap.py", "-m 1", True],
+ ["pcap_with_vm.py", "-m 1", True],
# YAML test
["yaml/burst_1000_pkt.yaml","-m 1 -l 100",True],
@@ -202,7 +188,7 @@ class CStlBasic_Test(functional_general_test.CGeneralFunctional_Test):
["udp_1pkt_simple_test2.py","-m 1 -l 10 ",True], # test split of packet with ip option
["udp_1pkt_simple_test.py","-m 1 -l 10 ",True],
["udp_1pkt_mac_mask5.py","-m 1 -l 30 ",True],
- #["udp_1pkt_range_clients_split_garp.py","-m 1 -l 50",True]
+ ["udp_1pkt_range_clients_split_garp.py","-m 1 -l 50",True]
];
@@ -247,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)
+