|
2 | 2 | import sys
|
3 | 3 |
|
4 | 4 | from utils import get_result_and_return_code
|
5 |
| -from mmuconfig_input.mmuconfig_test_vectors import * |
| 5 | +from mmuconfig_input.mmuconfig_test_vectors import show_mmu_config, show_mmu_config_one, test_data |
6 | 6 | from json import load
|
7 | 7 |
|
8 | 8 | root_path = os.path.dirname(os.path.abspath(__file__))
|
|
11 | 11 | sys.path.insert(0, root_path)
|
12 | 12 | sys.path.insert(0, modules_path)
|
13 | 13 |
|
| 14 | + |
14 | 15 | class TestMmuconfigMultiAsic(object):
|
15 |
| - @classmethod |
16 |
| - def setup_class(cls): |
17 |
| - os.environ["PATH"] += os.pathsep + scripts_path |
18 |
| - os.environ["UTILITIES_UNIT_TESTING_TOPOLOGY"] = "multi_asic" |
19 |
| - os.environ['UTILITIES_UNIT_TESTING'] = "2" |
20 |
| - print("SETUP") |
21 |
| - |
22 |
| - def executor(self, command, expected_result=None): |
23 |
| - return_code, result = get_result_and_return_code(command) |
24 |
| - print("return_code: {}".format(return_code)) |
25 |
| - print("result = {}".format(result)) |
26 |
| - assert return_code == 0 |
27 |
| - if expected_result: |
28 |
| - assert result == expected_result |
29 |
| - |
30 |
| - def test_mmu_show_config_one_masic(self): |
31 |
| - self.executor(['mmuconfig', '-l', '-n', 'asic0'], show_mmu_config_one) |
32 |
| - |
33 |
| - def test_mmu_show_config_all_masic(self): |
34 |
| - self.executor(['mmuconfig', '-l'], show_mmu_config) |
35 |
| - |
36 |
| - def test_mmu_alpha_config_masic(self): |
37 |
| - self.executor(['mmuconfig', '-p', 'alpha_profile', '-a', '2', '-n', 'asic0']) |
38 |
| - fd = open('/tmp/mmuconfig', 'r') |
39 |
| - cmp_data = load(fd) |
40 |
| - assert cmp_data['alpha_profile']['dynamic_th'] == '2' |
41 |
| - |
42 |
| - @classmethod |
43 |
| - def teardown_class(cls): |
44 |
| - os.environ['PATH'] = os.pathsep.join(os.environ['PATH'].split(os.pathsep)[:-1]) |
45 |
| - os.environ['UTILITIES_UNIT_TESTING'] = "0" |
46 |
| - os.environ["UTILITIES_UNIT_TESTING_TOPOLOGY"] = "" |
47 |
| - if os.path.isfile('/tmp/mmuconfig'): |
48 |
| - os.remove('/tmp/mmuconfig') |
49 |
| - print("TEARDOWN") |
| 16 | + @classmethod |
| 17 | + def setup_class(cls): |
| 18 | + os.environ["PATH"] += os.pathsep + scripts_path |
| 19 | + os.environ["UTILITIES_UNIT_TESTING_TOPOLOGY"] = "multi_asic" |
| 20 | + os.environ['UTILITIES_UNIT_TESTING'] = "2" |
| 21 | + print("SETUP") |
| 22 | + |
| 23 | + def executor(self, command, expected_result=None): |
| 24 | + return_code, result = get_result_and_return_code(command) |
| 25 | + print("return_code: {}".format(return_code)) |
| 26 | + print("result = {}".format(result)) |
| 27 | + assert return_code == 0 |
| 28 | + if expected_result: |
| 29 | + assert result == expected_result |
| 30 | + |
| 31 | + def test_mmu_show_config_one_masic(self): |
| 32 | + self.executor(['mmuconfig', '-l', '-n', 'asic0'], show_mmu_config_one) |
| 33 | + |
| 34 | + def test_mmu_show_config_all_masic(self): |
| 35 | + self.executor(['mmuconfig', '-l'], show_mmu_config) |
| 36 | + |
| 37 | + def test_mmu_alpha_config_masic(self): |
| 38 | + self.executor(['mmuconfig', '-p', 'alpha_profile', '-a', '2', '-n', 'asic0']) |
| 39 | + fd = open('/tmp/mmuconfig', 'r') |
| 40 | + cmp_data = load(fd) |
| 41 | + assert cmp_data['alpha_profile']['dynamic_th'] == '2' |
| 42 | + |
| 43 | + @classmethod |
| 44 | + def teardown_class(cls): |
| 45 | + os.environ['PATH'] = os.pathsep.join(os.environ['PATH'].split(os.pathsep)[:-1]) |
| 46 | + os.environ['UTILITIES_UNIT_TESTING'] = "0" |
| 47 | + os.environ["UTILITIES_UNIT_TESTING_TOPOLOGY"] = "" |
| 48 | + if os.path.isfile('/tmp/mmuconfig'): |
| 49 | + os.remove('/tmp/mmuconfig') |
| 50 | + print("TEARDOWN") |
0 commit comments