summaryrefslogtreecommitdiffstats
path: root/scripts/automation/regression/stateless_tests/stl_examples_test.py
blob: 3f7d7b872d9c91f9105d9c57aac137e2b82997ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/router/bin/python
from .stl_general_test import CStlGeneral_Test, CTRexScenario
import os, sys
from misc_methods import run_command

class STLExamples_Test(CStlGeneral_Test):
    """This class defines the IMIX testcase of the T-Rex traffic generator"""

    def setUp(self):
        CStlGeneral_Test.setUp(self)
        # examples connect by their own
        if self.is_connected():
            CTRexScenario.stl_trex.disconnect()

    @classmethod
    def tearDownClass(cls):
        # connect back at end of tests
        if not cls.is_connected():
            CTRexScenario.stl_trex.connect()

    def test_stl_examples(self):
        examples_dir = '../trex_control_plane/stl/examples'
        examples_to_test = [
                            'stl_imix.py',
                            ]

        for example in examples_to_test:
            return_code, stdout, stderr = run_command("sh -c 'cd %s; %s %s -s %s'" % (examples_dir, sys.executable, example, CTRexScenario.configuration.trex['trex_name']))
            assert return_code == 0, 'example %s failed.\nstdout: %s\nstderr: %s' % (return_code, stdout, stderr)