Improved the naming of tests which use the 'get_permutations' function. Adds the parameter values to the end of the test class.
This commit is contained in:
committed by
Alex Mykyta
parent
75a2163f6d
commit
6597f889fa
@@ -1,7 +1,20 @@
|
|||||||
from itertools import product
|
from itertools import product
|
||||||
|
|
||||||
|
|
||||||
def get_permutations(spec):
|
def get_permutations(spec):
|
||||||
param_list = []
|
param_list = []
|
||||||
for v in product(*spec.values()):
|
for v in product(*spec.values()):
|
||||||
param_list.append(dict(zip(spec, v)))
|
param_list.append(dict(zip(spec, v)))
|
||||||
return param_list
|
return param_list
|
||||||
|
|
||||||
|
|
||||||
|
def get_permutation_class_name(cls, num: int, params: dict) -> str:
|
||||||
|
class_name = cls.__name__
|
||||||
|
|
||||||
|
for val in params.values():
|
||||||
|
val_str = str(val)
|
||||||
|
if "object at" in val_str:
|
||||||
|
val_str = type(val).__name__
|
||||||
|
class_name += f"_{val_str}"
|
||||||
|
|
||||||
|
return class_name
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
from parameterized import parameterized_class
|
from parameterized import parameterized_class
|
||||||
|
|
||||||
from ..lib.sim_testcase import SimTestCase
|
|
||||||
from ..lib.test_params import get_permutations
|
|
||||||
from ..lib.cpuifs import ALL_CPUIF
|
from ..lib.cpuifs import ALL_CPUIF
|
||||||
|
from ..lib.sim_testcase import SimTestCase
|
||||||
|
from ..lib.test_params import get_permutation_class_name, get_permutations
|
||||||
|
|
||||||
|
|
||||||
@parameterized_class(
|
@parameterized_class(
|
||||||
# To reduce the number of tests, cover all CPUIFs with both error injections enabled, and all
|
# To reduce the number of tests, cover all CPUIFs with both error injections enabled, and all
|
||||||
@@ -15,7 +16,8 @@ from ..lib.cpuifs import ALL_CPUIF
|
|||||||
get_permutations({
|
get_permutations({
|
||||||
"err_if_bad_addr": [True, False],
|
"err_if_bad_addr": [True, False],
|
||||||
"err_if_bad_rw": [True, False],
|
"err_if_bad_rw": [True, False],
|
||||||
})
|
}),
|
||||||
|
class_name_func=get_permutation_class_name
|
||||||
)
|
)
|
||||||
class Test(SimTestCase):
|
class Test(SimTestCase):
|
||||||
extra_tb_files = [
|
extra_tb_files = [
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
from parameterized import parameterized_class
|
from parameterized import parameterized_class
|
||||||
|
|
||||||
from ..lib.sim_testcase import SimTestCase
|
|
||||||
from ..lib.test_params import get_permutations
|
|
||||||
from ..lib.cpuifs.apb4 import APB4
|
from ..lib.cpuifs.apb4 import APB4
|
||||||
from ..lib.cpuifs.axi4lite import AXI4Lite
|
from ..lib.cpuifs.axi4lite import AXI4Lite
|
||||||
from ..lib.cpuifs.passthrough import Passthrough
|
from ..lib.cpuifs.passthrough import Passthrough
|
||||||
|
from ..lib.sim_testcase import SimTestCase
|
||||||
|
from ..lib.test_params import get_permutation_class_name, get_permutations
|
||||||
|
|
||||||
|
|
||||||
@parameterized_class(get_permutations({
|
@parameterized_class(get_permutations({
|
||||||
"cpuif": [
|
"cpuif": [
|
||||||
@@ -15,7 +16,7 @@ from ..lib.cpuifs.passthrough import Passthrough
|
|||||||
"retime_read_fanin": [True, False],
|
"retime_read_fanin": [True, False],
|
||||||
"retime_read_response": [True, False],
|
"retime_read_response": [True, False],
|
||||||
"retime_external": [True, False],
|
"retime_external": [True, False],
|
||||||
}))
|
}), class_name_func=get_permutation_class_name)
|
||||||
class Test(SimTestCase):
|
class Test(SimTestCase):
|
||||||
extra_tb_files = [
|
extra_tb_files = [
|
||||||
"../lib/external_reg.sv",
|
"../lib/external_reg.sv",
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
from parameterized import parameterized_class
|
from parameterized import parameterized_class
|
||||||
|
|
||||||
from ..lib.sim_testcase import SimTestCase
|
|
||||||
from ..lib.test_params import get_permutations
|
|
||||||
from ..lib.cpuifs import ALL_CPUIF
|
from ..lib.cpuifs import ALL_CPUIF
|
||||||
|
from ..lib.sim_testcase import SimTestCase
|
||||||
|
from ..lib.test_params import get_permutation_class_name, get_permutations
|
||||||
|
|
||||||
|
|
||||||
@parameterized_class(get_permutations({
|
@parameterized_class(get_permutations({
|
||||||
"cpuif": ALL_CPUIF,
|
"cpuif": ALL_CPUIF,
|
||||||
"retime_read_fanin": [True, False],
|
"retime_read_fanin": [True, False],
|
||||||
"retime_read_response": [True, False],
|
"retime_read_response": [True, False],
|
||||||
}))
|
}), class_name_func=get_permutation_class_name)
|
||||||
class Test(SimTestCase):
|
class Test(SimTestCase):
|
||||||
def test_dut(self):
|
def test_dut(self):
|
||||||
self.run_test()
|
self.run_test()
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
from parameterized import parameterized_class
|
from parameterized import parameterized_class
|
||||||
|
|
||||||
from ..lib.sim_testcase import SimTestCase
|
from ..lib.sim_testcase import SimTestCase
|
||||||
from ..lib.test_params import get_permutations
|
from ..lib.test_params import get_permutation_class_name, get_permutations
|
||||||
|
|
||||||
PARAMS = get_permutations({
|
PARAMS = get_permutations({
|
||||||
"n_regs" : [1, 2],
|
"n_regs" : [1, 2],
|
||||||
"regwidth" : [8, 16],
|
"regwidth" : [8, 16],
|
||||||
"name" : ["hello", "world"],
|
"name" : ["hello", "world"],
|
||||||
})
|
})
|
||||||
@parameterized_class(PARAMS)
|
@parameterized_class(PARAMS, class_name_func=get_permutation_class_name)
|
||||||
class TestRetimedFanin(SimTestCase):
|
class TestRetimedFanin(SimTestCase):
|
||||||
n_regs = 20
|
n_regs = 20
|
||||||
regwidth = 32
|
regwidth = 32
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
from parameterized import parameterized_class
|
from parameterized import parameterized_class
|
||||||
|
|
||||||
from ..lib.sim_testcase import SimTestCase
|
from ..lib.sim_testcase import SimTestCase
|
||||||
from ..lib.test_params import get_permutations
|
from ..lib.test_params import get_permutation_class_name, get_permutations
|
||||||
|
|
||||||
|
|
||||||
PARAMS = get_permutations({
|
PARAMS = get_permutations({
|
||||||
"regwidth" : [8, 16, 32, 64],
|
"regwidth" : [8, 16, 32, 64],
|
||||||
})
|
})
|
||||||
@parameterized_class(PARAMS)
|
@parameterized_class(PARAMS, class_name_func=get_permutation_class_name)
|
||||||
class TestFanin(SimTestCase):
|
class TestFanin(SimTestCase):
|
||||||
retime_read_fanin = False
|
retime_read_fanin = False
|
||||||
n_regs = 20
|
n_regs = 20
|
||||||
@@ -29,7 +28,7 @@ PARAMS = get_permutations({
|
|||||||
"n_regs" : [1, 4, 7, 9, 11],
|
"n_regs" : [1, 4, 7, 9, 11],
|
||||||
"regwidth" : [8, 16, 32, 64],
|
"regwidth" : [8, 16, 32, 64],
|
||||||
})
|
})
|
||||||
@parameterized_class(PARAMS)
|
@parameterized_class(PARAMS, class_name_func=get_permutation_class_name)
|
||||||
class TestRetimedFanin(TestFanin):
|
class TestRetimedFanin(TestFanin):
|
||||||
retime_read_fanin = True
|
retime_read_fanin = True
|
||||||
|
|
||||||
|
|||||||
@@ -2,28 +2,25 @@ import os
|
|||||||
|
|
||||||
from parameterized import parameterized_class
|
from parameterized import parameterized_class
|
||||||
|
|
||||||
|
from ..lib.cpuifs import ALL_CPUIF
|
||||||
from ..lib.sim_testcase import SimTestCase
|
from ..lib.sim_testcase import SimTestCase
|
||||||
from ..lib.synth_testcase import SynthTestCase
|
from ..lib.synth_testcase import SynthTestCase
|
||||||
from ..lib.test_params import get_permutations
|
from ..lib.test_params import get_permutation_class_name, get_permutations
|
||||||
from ..lib.cpuifs import ALL_CPUIF
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@parameterized_class(get_permutations({
|
@parameterized_class(get_permutations({
|
||||||
"cpuif": ALL_CPUIF,
|
"cpuif": ALL_CPUIF,
|
||||||
"retime_read_fanin": [True, False],
|
"retime_read_fanin": [True, False],
|
||||||
"retime_read_response": [True, False],
|
"retime_read_response": [True, False],
|
||||||
}))
|
}), class_name_func=get_permutation_class_name)
|
||||||
class TestCPUIFS(SimTestCase):
|
class TestCPUIFS(SimTestCase):
|
||||||
def test_dut(self):
|
def test_dut(self):
|
||||||
self.run_test()
|
self.run_test()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@parameterized_class(get_permutations({
|
@parameterized_class(get_permutations({
|
||||||
"reuse_hwif_typedefs": [True, False],
|
"reuse_hwif_typedefs": [True, False],
|
||||||
}))
|
}), class_name_func=get_permutation_class_name)
|
||||||
class TestTypedefs(SimTestCase):
|
class TestTypedefs(SimTestCase):
|
||||||
def test_dut(self):
|
def test_dut(self):
|
||||||
self.run_test()
|
self.run_test()
|
||||||
@@ -33,7 +30,7 @@ class TestTypedefs(SimTestCase):
|
|||||||
@parameterized_class(get_permutations({
|
@parameterized_class(get_permutations({
|
||||||
"default_reset_activelow": [True, False],
|
"default_reset_activelow": [True, False],
|
||||||
"default_reset_async": [True, False],
|
"default_reset_async": [True, False],
|
||||||
}))
|
}), class_name_func=get_permutation_class_name)
|
||||||
class TestDefaultResets(SimTestCase):
|
class TestDefaultResets(SimTestCase):
|
||||||
def test_dut(self):
|
def test_dut(self):
|
||||||
self.run_test()
|
self.run_test()
|
||||||
@@ -45,7 +42,7 @@ class TestDefaultResets(SimTestCase):
|
|||||||
"retime_read_fanin": [True, False],
|
"retime_read_fanin": [True, False],
|
||||||
"retime_read_response": [True, False],
|
"retime_read_response": [True, False],
|
||||||
"reuse_hwif_typedefs": [True, False],
|
"reuse_hwif_typedefs": [True, False],
|
||||||
}))
|
}), class_name_func=get_permutation_class_name)
|
||||||
class TestSynth(SynthTestCase):
|
class TestSynth(SynthTestCase):
|
||||||
def test_dut(self):
|
def test_dut(self):
|
||||||
self.run_synth()
|
self.run_synth()
|
||||||
|
|||||||
Reference in New Issue
Block a user