diff options
Diffstat (limited to 'scripts/automation/regression/functional_tests')
-rwxr-xr-x | scripts/automation/regression/functional_tests/platform_device_cfg_test.py | 6 | ||||
-rw-r--r-- | scripts/automation/regression/functional_tests/stl_basic_tests.py | 59 |
2 files changed, 56 insertions, 9 deletions
diff --git a/scripts/automation/regression/functional_tests/platform_device_cfg_test.py b/scripts/automation/regression/functional_tests/platform_device_cfg_test.py index 3935a4c5..c60635fe 100755 --- a/scripts/automation/regression/functional_tests/platform_device_cfg_test.py +++ b/scripts/automation/regression/functional_tests/platform_device_cfg_test.py @@ -9,12 +9,12 @@ from nose.tools import assert_not_equal class CDeviceCfg_Test(functional_general_test.CGeneralFunctional_Test): def setUp(self): - self.dev_cfg = CDeviceCfg('./functional_tests/config.yaml') + self.dev_cfg = CDeviceCfg('./functional_tests/config.yaml') def test_get_interfaces_cfg(self): assert_equal (self.dev_cfg.get_interfaces_cfg(), - [{'client': {'src_mac_addr': '0000.0001.0000', 'name': 'GigabitEthernet0/0/1', 'dest_mac_addr': '0000.1000.0000'}, 'vrf_name': None, 'server': {'src_mac_addr': '0000.0002.0000', 'name': 'GigabitEthernet0/0/2', 'dest_mac_addr': '0000.2000.0000'}}, {'client': {'src_mac_addr': '0000.0003.0000', 'name': 'GigabitEthernet0/0/3', 'dest_mac_addr': '0000.3000.0000'}, 'vrf_name': 'dup', 'server': {'src_mac_addr': '0000.0004.0000', 'name': 'GigabitEthernet0/0/4', 'dest_mac_addr': '0000.4000.0000'}}] - ) + [{'client': {'src_mac_addr': '0000.0001.0000', 'name': 'GigabitEthernet0/0/1', 'dest_mac_addr': '0000.1000.0000'}, 'vrf_name': None, 'server': {'src_mac_addr': '0000.0002.0000', 'name': 'GigabitEthernet0/0/2', 'dest_mac_addr': '0000.2000.0000'}}, {'client': {'src_mac_addr': '0000.0003.0000', 'name': 'GigabitEthernet0/0/3', 'dest_mac_addr': '0000.3000.0000'}, 'vrf_name': 'dup', 'server': {'src_mac_addr': '0000.0004.0000', 'name': 'GigabitEthernet0/0/4', 'dest_mac_addr': '0000.4000.0000'}}] + ) def tearDown(self): pass diff --git a/scripts/automation/regression/functional_tests/stl_basic_tests.py b/scripts/automation/regression/functional_tests/stl_basic_tests.py index 2bf97307..71228d9a 100644 --- a/scripts/automation/regression/functional_tests/stl_basic_tests.py +++ b/scripts/automation/regression/functional_tests/stl_basic_tests.py @@ -9,8 +9,16 @@ from nose.plugins.attrib import attr from trex import CTRexScenario from trex_stl_lib import trex_stl_sim from trex_stl_lib.trex_stl_streams import STLProfile -from trex_stl_lib.trex_stl_packet_builder_scapy import RawPcapReader, RawPcapWriter +from trex_stl_lib.trex_stl_packet_builder_scapy import RawPcapReader, RawPcapWriter, Ether +from trex_stl_lib.utils.text_opts import * + import sys + +if sys.version_info > (3,0): + from io import StringIO +else: + from cStringIO import StringIO + import os import subprocess import shlex @@ -64,9 +72,18 @@ class CStlBasic_Test(functional_general_test.CGeneralFunctional_Test): raise Exception("cannot find '{0}'".format(name)) - def compare_caps (self, cap1, cap2, max_diff_sec = 0.01): - pkts1 = list(RawPcapReader(cap1)) - pkts2 = list(RawPcapReader(cap2)) + def scapy_pkt_show_to_str (self, scapy_pkt): + capture = StringIO() + save_stdout = sys.stdout + sys.stdout = capture + scapy_pkt.show() + sys.stdout = save_stdout + return capture.getvalue() + + + def compare_caps (self, output, golden, max_diff_sec = 0.01): + pkts1 = list(RawPcapReader(output)) + pkts2 = list(RawPcapReader(golden)) assert_equal(len(pkts1), len(pkts2)) @@ -75,11 +92,29 @@ class CStlBasic_Test(functional_general_test.CGeneralFunctional_Test): ts2 = float(pkt2[1][0]) + (float(pkt2[1][1]) / 1e6) if abs(ts1-ts2) > 0.000005: # 5 nsec - raise AssertionError("TS error: cap files '{0}', '{1}' differ in cap #{2} - '{3}' vs. '{4}'".format(cap1, cap2, i, ts1, ts2)) + raise AssertionError("TS error: cap files '{0}', '{1}' differ in cap #{2} - '{3}' vs. '{4}'".format(output, golden, i, ts1, ts2)) if pkt1[0] != pkt2[0]: - raise AssertionError("RAW error: cap files '{0}', '{1}' differ in cap #{2}".format(cap1, cap2, i)) + errmsg = "RAW error: output file '{0}', differs from golden '{1}' in cap #{2}".format(output, golden, i) + print(errmsg) + + print(format_text("\ndifferent fields for packet #{0}:".format(i), 'underline')) + scapy_pkt1_info = self.scapy_pkt_show_to_str(Ether(pkt1[0])).split('\n') + scapy_pkt2_info = self.scapy_pkt_show_to_str(Ether(pkt2[0])).split('\n') + + print(format_text("\nGot:\n", 'bold', 'underline')) + for line, ref in zip(scapy_pkt1_info, scapy_pkt2_info): + if line != ref: + print(format_text(line, 'bold')) + + print(format_text("\nExpected:\n", 'bold', 'underline')) + for line, ref in zip(scapy_pkt2_info, scapy_pkt1_info): + if line != ref: + print(format_text(line, 'bold')) + + print("\n") + raise AssertionError(errmsg) def run_sim (self, yaml, output, options = "", silent = False, obj = None): @@ -100,6 +135,7 @@ class CStlBasic_Test(functional_general_test.CGeneralFunctional_Test): def run_py_profile_path (self, profile, options,silent = False, do_no_remove=False,compare =True, test_generated=True, do_no_remove_generated = False): + print('Testing profile: %s' % profile) output_cap = "a.pcap" input_file = os.path.join('stl/', profile) golden_file = os.path.join('exp',os.path.basename(profile).split('.')[0]+'.pcap'); @@ -262,3 +298,14 @@ class CStlBasic_Test(functional_general_test.CGeneralFunctional_Test): + def test_multicore_scheduling (self): + mc_tests = ['stl/tests/single_cont.py', + 'stl/tests/single_burst.py', + 'stl/tests/multi_burst.py', + 'stl/tests/many_streams.py', + ] + + for mc_test in mc_tests: + rc = self.run_sim(mc_test, output = None, options = '--test_multi_core --limit=3840 -m 27kpps', silent = True) + assert_equal(rc, True) + |