From 039699083d0ff6c2341682c1b724a03f776846fa Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Thu, 4 Jun 2020 20:58:01 +0100 Subject: [PATCH] no global variables in test suites --- src/soc/fu/branch/test/test_pipe_caller.py | 7 +++---- src/soc/fu/compunits/test/test_branch_compunit.py | 3 +-- src/soc/simple/test/test_core.py | 6 +++--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/soc/fu/branch/test/test_pipe_caller.py b/src/soc/fu/branch/test/test_pipe_caller.py index 8a281411..99913dcb 100644 --- a/src/soc/fu/branch/test/test_pipe_caller.py +++ b/src/soc/fu/branch/test/test_pipe_caller.py @@ -47,8 +47,6 @@ def get_rec_width(rec): # massively. Before, it took around 1 minute on my computer, now it # takes around 3 seconds -test_data = [] - def get_cu_inputs(dec2, sim): """naming (res) must conform to BranchFunctionUnit input regspec @@ -83,6 +81,7 @@ def get_cu_inputs(dec2, sim): class BranchTestCase(FHDLTestCase): + test_data = [] def __init__(self, name): super().__init__(name) self.test_name = name @@ -91,7 +90,7 @@ class BranchTestCase(FHDLTestCase): initial_sprs=None, initial_cr=0): tc = TestCase(prog, self.test_name, initial_regs, initial_sprs, initial_cr) - test_data.append(tc) + self.test_data.append(tc) def test_unconditional(self): choices = ["b", "ba", "bl", "bla"] @@ -261,7 +260,7 @@ class TestRunner(FHDLTestCase): if __name__ == "__main__": unittest.main(exit=False) suite = unittest.TestSuite() - suite.addTest(TestRunner(test_data)) + suite.addTest(TestRunner(BranchTestCase.test_data)) runner = unittest.TextTestRunner() runner.run(suite) diff --git a/src/soc/fu/compunits/test/test_branch_compunit.py b/src/soc/fu/compunits/test/test_branch_compunit.py index 9d4503ce..dbcd0f65 100644 --- a/src/soc/fu/compunits/test/test_branch_compunit.py +++ b/src/soc/fu/compunits/test/test_branch_compunit.py @@ -3,7 +3,6 @@ from soc.decoder.power_enums import (XER_bits, Function, spr_dict, SPR) # XXX bad practice: use of global variables from soc.fu.branch.test.test_pipe_caller import BranchTestCase, get_cu_inputs -from soc.fu.branch.test.test_pipe_caller import test_data from soc.fu.compunits.compunits import BranchFunctionUnit from soc.fu.compunits.test.test_compunit import TestRunner @@ -59,7 +58,7 @@ class BranchTestRunner(TestRunner): if __name__ == "__main__": unittest.main(exit=False) suite = unittest.TestSuite() - suite.addTest(BranchTestRunner(test_data)) + suite.addTest(BranchTestRunner(BranchTestCase.test_data)) runner = unittest.TextTestRunner() runner.run(suite) diff --git a/src/soc/simple/test/test_core.py b/src/soc/simple/test/test_core.py index 564c6f3b..713da17d 100644 --- a/src/soc/simple/test/test_core.py +++ b/src/soc/simple/test/test_core.py @@ -230,9 +230,9 @@ if __name__ == "__main__": unittest.main(exit=False) suite = unittest.TestSuite() suite.addTest(TestRunner(CRTestCase.test_data)) - #suite.addTest(TestRunner(ShiftRotTestCase.test_data)) - #suite.addTest(TestRunner(LogicalTestCase.test_data)) - #suite.addTest(TestRunner(ALUTestCase.test_data)) + suite.addTest(TestRunner(ShiftRotTestCase.test_data)) + suite.addTest(TestRunner(LogicalTestCase.test_data)) + suite.addTest(TestRunner(ALUTestCase.test_data)) runner = unittest.TextTestRunner() runner.run(suite) -- 2.30.2