add factory-function for StateRunner
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 25 Sep 2021 18:03:05 +0000 (19:03 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 25 Sep 2021 18:03:05 +0000 (19:03 +0100)
src/openpower/test/state.py

index 6274ba47496c2d24a77c0e04a588f6934904e47b..3cba30eedb09e1319e30e33370667cabcba8e0c0 100644 (file)
@@ -25,13 +25,24 @@ methods, the use of yield from/yield is required.
 from openpower.decoder.power_enums import XER_bits
 from openpower.util import log
 
+global staterunner_factory
+staterunner_factory = {}
+
+
+def staterunner_add(name, kls):
+    log("staterunner_add", name, kls)
+    staterunner_factory[name] = kls
+
+
 
 # TBD an Abstract Base Class
 class StateRunner:
     """StateRunner: an Abstract Base Class for preparing and running "State".
     near-identical in concept to python unittest.TestCase
     """
-    def __init__(self, dut, **kwargs): pass
+    def __init__(self, name, kls):
+        staterunner_add(name, kls)
+
     def setup_for_test(self):
         if False: yield
     def setup_during_test(self):
@@ -48,6 +59,7 @@ class StateRunner:
 
 class SimRunner(StateRunner):
     def __init__(self, dut, **kwargs):
+        super().__init__("sim", SimRunner)
         self.pspec = kwargs['pspec']
         self.m = kwargs['m']