Skip to content

Commit a74e0b4

Browse files
committed
Improved the naming of tests which use the 'get_permutations' function. Adds the parameter values to the end of the test class.
1 parent 610351d commit a74e0b4

File tree

7 files changed

+37
-24
lines changed

7 files changed

+37
-24
lines changed

tests/lib/test_params.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
from itertools import product
22

3+
34
def get_permutations(spec):
45
param_list = []
56
for v in product(*spec.values()):
67
param_list.append(dict(zip(spec, v)))
78
return param_list
9+
10+
11+
def get_permutation_class_name(cls, num: int, params: dict) -> str:
12+
class_name = cls.__name__
13+
14+
for val in params.values():
15+
val_str = str(val)
16+
if "object at" in val_str:
17+
val_str = type(val).__name__
18+
class_name += f"_{val_str}"
19+
20+
return class_name

tests/test_cpuif_err_rsp/testcase.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from parameterized import parameterized_class
22

3-
from ..lib.sim_testcase import SimTestCase
4-
from ..lib.test_params import get_permutations
53
from ..lib.cpuifs import ALL_CPUIF
4+
from ..lib.sim_testcase import SimTestCase
5+
from ..lib.test_params import get_permutation_class_name, get_permutations
6+
67

78
@parameterized_class(
89
# To reduce the number of tests, cover all CPUIFs with both error injections enabled, and all
@@ -15,7 +16,8 @@
1516
get_permutations({
1617
"err_if_bad_addr": [True, False],
1718
"err_if_bad_rw": [True, False],
18-
})
19+
}),
20+
class_name_func=get_permutation_class_name
1921
)
2022
class Test(SimTestCase):
2123
extra_tb_files = [

tests/test_external/testcase.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from parameterized import parameterized_class
22

3-
from ..lib.sim_testcase import SimTestCase
4-
from ..lib.test_params import get_permutations
53
from ..lib.cpuifs.apb4 import APB4
64
from ..lib.cpuifs.axi4lite import AXI4Lite
75
from ..lib.cpuifs.passthrough import Passthrough
6+
from ..lib.sim_testcase import SimTestCase
7+
from ..lib.test_params import get_permutation_class_name, get_permutations
8+
89

910
@parameterized_class(get_permutations({
1011
"cpuif": [
@@ -15,7 +16,7 @@
1516
"retime_read_fanin": [True, False],
1617
"retime_read_response": [True, False],
1718
"retime_external": [True, False],
18-
}))
19+
}), class_name_func=get_permutation_class_name)
1920
class Test(SimTestCase):
2021
extra_tb_files = [
2122
"../lib/external_reg.sv",
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
from parameterized import parameterized_class
22

3-
from ..lib.sim_testcase import SimTestCase
4-
from ..lib.test_params import get_permutations
53
from ..lib.cpuifs import ALL_CPUIF
4+
from ..lib.sim_testcase import SimTestCase
5+
from ..lib.test_params import get_permutation_class_name, get_permutations
6+
67

78
@parameterized_class(get_permutations({
89
"cpuif": ALL_CPUIF,
910
"retime_read_fanin": [True, False],
1011
"retime_read_response": [True, False],
11-
}))
12+
}), class_name_func=get_permutation_class_name)
1213
class Test(SimTestCase):
1314
def test_dut(self):
1415
self.run_test()

tests/test_pkg_params/testcase.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
from parameterized import parameterized_class
22

33
from ..lib.sim_testcase import SimTestCase
4-
from ..lib.test_params import get_permutations
4+
from ..lib.test_params import get_permutation_class_name, get_permutations
55

66
PARAMS = get_permutations({
77
"n_regs" : [1, 2],
88
"regwidth" : [8, 16],
99
"name" : ["hello", "world"],
1010
})
11-
@parameterized_class(PARAMS)
11+
@parameterized_class(PARAMS, class_name_func=get_permutation_class_name)
1212
class TestRetimedFanin(SimTestCase):
1313
n_regs = 20
1414
regwidth = 32

tests/test_read_fanin/testcase.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
from parameterized import parameterized_class
22

33
from ..lib.sim_testcase import SimTestCase
4-
from ..lib.test_params import get_permutations
5-
4+
from ..lib.test_params import get_permutation_class_name, get_permutations
65

76
PARAMS = get_permutations({
87
"regwidth" : [8, 16, 32, 64],
98
})
10-
@parameterized_class(PARAMS)
9+
@parameterized_class(PARAMS, class_name_func=get_permutation_class_name)
1110
class TestFanin(SimTestCase):
1211
retime_read_fanin = False
1312
n_regs = 20
@@ -29,7 +28,7 @@ def test_dut(self):
2928
"n_regs" : [1, 4, 7, 9, 11],
3029
"regwidth" : [8, 16, 32, 64],
3130
})
32-
@parameterized_class(PARAMS)
31+
@parameterized_class(PARAMS, class_name_func=get_permutation_class_name)
3332
class TestRetimedFanin(TestFanin):
3433
retime_read_fanin = True
3534

tests/test_structural_sw_rw/testcase.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,25 @@
22

33
from parameterized import parameterized_class
44

5+
from ..lib.cpuifs import ALL_CPUIF
56
from ..lib.sim_testcase import SimTestCase
67
from ..lib.synth_testcase import SynthTestCase
7-
from ..lib.test_params import get_permutations
8-
from ..lib.cpuifs import ALL_CPUIF
9-
10-
8+
from ..lib.test_params import get_permutation_class_name, get_permutations
119

1210

1311
@parameterized_class(get_permutations({
1412
"cpuif": ALL_CPUIF,
1513
"retime_read_fanin": [True, False],
1614
"retime_read_response": [True, False],
17-
}))
15+
}), class_name_func=get_permutation_class_name)
1816
class TestCPUIFS(SimTestCase):
1917
def test_dut(self):
2018
self.run_test()
2119

2220

23-
2421
@parameterized_class(get_permutations({
2522
"reuse_hwif_typedefs": [True, False],
26-
}))
23+
}), class_name_func=get_permutation_class_name)
2724
class TestTypedefs(SimTestCase):
2825
def test_dut(self):
2926
self.run_test()
@@ -33,7 +30,7 @@ def test_dut(self):
3330
@parameterized_class(get_permutations({
3431
"default_reset_activelow": [True, False],
3532
"default_reset_async": [True, False],
36-
}))
33+
}), class_name_func=get_permutation_class_name)
3734
class TestDefaultResets(SimTestCase):
3835
def test_dut(self):
3936
self.run_test()
@@ -45,7 +42,7 @@ def test_dut(self):
4542
"retime_read_fanin": [True, False],
4643
"retime_read_response": [True, False],
4744
"reuse_hwif_typedefs": [True, False],
48-
}))
45+
}), class_name_func=get_permutation_class_name)
4946
class TestSynth(SynthTestCase):
5047
def test_dut(self):
5148
self.run_synth()

0 commit comments

Comments
 (0)