move run_test_program to base class and rename to "add_case"
[soc.git] / src / soc / fu / test / common.py
index c7f87dd9597dc2f9764127105ec494ac3866331a..b4bceb1b43bd7adcfc66ebd45f92f7ccaa4a8f03 100644 (file)
@@ -3,6 +3,7 @@ Bugreports:
 * https://bugs.libre-soc.org/show_bug.cgi?id=361
 """
 
+import inspect
 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
@@ -18,6 +19,11 @@ class TestAccumulatorBase:
             if n.startswith("case_") and callable(v):
                 v(self)
 
+    def add_case(self, prog, initial_regs=None, initial_sprs=None):
+        test_name = inspect.stack()[1][3] # name of caller of this function
+        tc = TestCase(prog, test_name, initial_regs, initial_sprs)
+        self.test_data.append(tc)
+
 
 class TestCase:
     def __init__(self, program, name, regs=None, sprs=None, cr=0, mem=None,