split out "all" div into separate unit test (takes a really long time)
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 24 Jul 2020 11:50:07 +0000 (12:50 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 24 Jul 2020 11:50:07 +0000 (12:50 +0100)
src/soc/fu/div/test/test_all_pipe_caller.py [new file with mode: 0644]
src/soc/fu/div/test/test_pipe_caller.py

diff --git a/src/soc/fu/div/test/test_all_pipe_caller.py b/src/soc/fu/div/test/test_all_pipe_caller.py
new file mode 100644 (file)
index 0000000..26b9f4a
--- /dev/null
@@ -0,0 +1,65 @@
+import random
+import unittest
+from soc.simulator.program import Program
+from soc.config.endian import bigendian
+
+from soc.fu.test.common import TestCase
+from soc.fu.div.test.test_pipe_caller import TestRunner
+
+
+class DivTestCasesLong:
+    def __init__(self):
+        self.test_data = []
+        for n, v in self.__class__.__dict__.items():
+            if n.startswith("test") and callable(v):
+                self._current_test_name = n
+                v(self)
+
+    def run_test_program(self, prog, initial_regs=None, initial_sprs=None):
+        tc = TestCase(prog, self._current_test_name,
+                      initial_regs, initial_sprs)
+        self.test_data.append(tc)
+
+    def test_all(self):
+        instrs = []
+        for width in ("w", "d"):
+            for sign in ("", "u"):
+                for ov in ("", "o"):
+                    for cnd in ("", "."):
+                        instrs += ["div" + width + sign + ov + cnd,
+                                   "div" + width + "e" + sign + ov + cnd]
+            for sign in ("s", "u"):
+                instrs += ["mod" + sign + width]
+        test_values = [
+            0x0,
+            0x1,
+            0x2,
+            0xFFFF_FFFF_FFFF_FFFF,
+            0xFFFF_FFFF_FFFF_FFFE,
+            0x7FFF_FFFF_FFFF_FFFF,
+            0x8000_0000_0000_0000,
+            0x1234_5678_0000_0000,
+            0x1234_5678_8000_0000,
+            0x1234_5678_FFFF_FFFF,
+            0x1234_5678_7FFF_FFFF,
+        ]
+        for instr in instrs:
+            l = [f"{instr} 3, 1, 2"]
+            for ra in test_values:
+                for rb in test_values:
+                    initial_regs = [0] * 32
+                    initial_regs[1] = ra
+                    initial_regs[2] = rb
+                    # use "with" so as to close the files used
+                    with Program(l, bigendian) as prog:
+                        self.run_test_program(prog, initial_regs)
+
+
+if __name__ == "__main__":
+    unittest.main(exit=False)
+    suite = unittest.TestSuite()
+    suite.addTest(TestRunner(DivTestCasesLong.test_data))
+
+    runner = unittest.TextTestRunner()
+    runner.run(suite)
+
index de9df1895aadc6f7463738c5dc5caeb5bba84d47..e69ebffd7f487e59a54036c780910699bfd4737c 100644 (file)
@@ -178,40 +178,6 @@ class DivTestCases:
         initial_regs[2] = 0x2
         self.run_test_program(Program(lst, bigendian), initial_regs)
 
-    def test_all(self):
-        instrs = []
-        for width in ("w", "d"):
-            for sign in ("", "u"):
-                for ov in ("", "o"):
-                    for cnd in ("", "."):
-                        instrs += ["div" + width + sign + ov + cnd,
-                                   "div" + width + "e" + sign + ov + cnd]
-            for sign in ("s", "u"):
-                instrs += ["mod" + sign + width]
-        test_values = [
-            0x0,
-            0x1,
-            0x2,
-            0xFFFF_FFFF_FFFF_FFFF,
-            0xFFFF_FFFF_FFFF_FFFE,
-            0x7FFF_FFFF_FFFF_FFFF,
-            0x8000_0000_0000_0000,
-            0x1234_5678_0000_0000,
-            0x1234_5678_8000_0000,
-            0x1234_5678_FFFF_FFFF,
-            0x1234_5678_7FFF_FFFF,
-        ]
-        for instr in instrs:
-            l = [f"{instr} 3, 1, 2"]
-            for ra in test_values:
-                for rb in test_values:
-                    initial_regs = [0] * 32
-                    initial_regs[1] = ra
-                    initial_regs[2] = rb
-                    # use "with" so as to close the files used
-                    with Program(l, bigendian) as prog:
-                        self.run_test_program(prog, initial_regs)
-
     def tst_rand_divwu(self):
         insns = ["divwu", "divwu.", "divwuo", "divwuo."]
         for i in range(40):