add common test base class for "accumulating" tests to run
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 26 Jul 2020 09:31:49 +0000 (10:31 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 26 Jul 2020 09:31:49 +0000 (10:31 +0100)
src/soc/fu/test/common.py

index ce4f21fe3368eebd3f66e201faddab92a97db653..c7f87dd9597dc2f9764127105ec494ac3866331a 100644 (file)
@@ -7,6 +7,17 @@ from soc.decoder.power_enums import XER_bits, CryIn, spr_dict
 from soc.regfile.util import fast_reg_to_spr  # HACK!
 from soc.regfile.regfiles import FastRegs
 
+class TestAccumulatorBase:
+
+    def __init__(self):
+        self.test_data = []
+        # automatically identifies anything starting with "case_" and
+        # runs it.  very similar to unittest auto-identification except
+        # we need a different system
+        for n, v in self.__class__.__dict__.items():
+            if n.startswith("case_") and callable(v):
+                v(self)
+
 
 class TestCase:
     def __init__(self, program, name, regs=None, sprs=None, cr=0, mem=None,