From: Jacob Lifshay Date: Thu, 25 Aug 2022 05:33:51 +0000 (-0700) Subject: convert all test_caller*.py to work with pytest/unittest test discovery X-Git-Tag: sv_maxu_works-initial~110 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1a17adab1cd5613fbec6bef417413df1682e61ab;p=openpower-isa.git convert all test_caller*.py to work with pytest/unittest test discovery all the removed code had no benefit because each file only tested one *TestCase* class, the removed code was only useful for selecting between multiple *TestCase* classes --- diff --git a/src/openpower/decoder/isa/test_caller_alu.py b/src/openpower/decoder/isa/test_caller_alu.py index 9011ef62..9aef6f2a 100644 --- a/src/openpower/decoder/isa/test_caller_alu.py +++ b/src/openpower/decoder/isa/test_caller_alu.py @@ -6,33 +6,21 @@ related bugs: """ import unittest -import sys - -# These tests utilize the run_hdl=False parameter to compare -# simulator with expected states from openpower.test.runner import TestRunnerBase from openpower.test.alu.alu_cases import ALUTestCase +# writing the test_caller invocation this way makes it work with pytest -if __name__ == "__main__": - - # allow list of testing to be selected by command-line - testing = sys.argv[1:] - sys.argv = sys.argv[:1] - if not testing: - testing = ['alu'] +class TestALU(TestRunnerBase): + def __init__(self, test): + assert test == 'test' + super().__init__(ALUTestCase().test_data) - unittest.main(exit=False) - suite = unittest.TestSuite() + def test(self): + # dummy function to make unittest try to test this class + pass - # dictionary of data for tests - tests = {'alu': ALUTestCase().test_data} - # walk through all tests, those requested get added - for tname, data in tests.items(): - if tname in testing: - suite.addTest(TestRunnerBase(data)) - - runner = unittest.TextTestRunner() - runner.run(suite) +if __name__ == "__main__": + unittest.main() diff --git a/src/openpower/decoder/isa/test_caller_bitmanip.py b/src/openpower/decoder/isa/test_caller_bitmanip.py index 6ba5f661..15e2c0a4 100644 --- a/src/openpower/decoder/isa/test_caller_bitmanip.py +++ b/src/openpower/decoder/isa/test_caller_bitmanip.py @@ -6,33 +6,21 @@ related bugs: """ import unittest -import sys - -# These tests utilize the run_hdl=False parameter to compare -# simulator with expected states from openpower.test.runner import TestRunnerBase from openpower.test.bitmanip.bitmanip_cases import BitManipTestCase +# writing the test_caller invocation this way makes it work with pytest -if __name__ == "__main__": - - # allow list of testing to be selected by command-line - testing = sys.argv[1:] - sys.argv = sys.argv[:1] - if not testing: - testing = ['bitmanip'] +class TestBitManip(TestRunnerBase): + def __init__(self, test): + assert test == 'test' + super().__init__(BitManipTestCase().test_data) - unittest.main(exit=False) - suite = unittest.TestSuite() + def test(self): + # dummy function to make unittest try to test this class + pass - # dictionary of data for tests - tests = {'bitmanip': BitManipTestCase().test_data} - # walk through all tests, those requested get added - for tname, data in tests.items(): - if tname in testing: - suite.addTest(TestRunnerBase(data)) - - runner = unittest.TextTestRunner() - runner.run(suite) +if __name__ == "__main__": + unittest.main() diff --git a/src/openpower/decoder/isa/test_caller_bitmanip_av.py b/src/openpower/decoder/isa/test_caller_bitmanip_av.py index 4e5cf97a..803d7168 100644 --- a/src/openpower/decoder/isa/test_caller_bitmanip_av.py +++ b/src/openpower/decoder/isa/test_caller_bitmanip_av.py @@ -6,33 +6,21 @@ related bugs: """ import unittest -import sys - -# These tests utilize the run_hdl=False parameter to compare -# simulator with expected states from openpower.test.runner import TestRunnerBase from openpower.test.bitmanip.av_cases import AVTestCase +# writing the test_caller invocation this way makes it work with pytest -if __name__ == "__main__": - - # allow list of testing to be selected by command-line - testing = sys.argv[1:] - sys.argv = sys.argv[:1] - if not testing: - testing = ['bitmanipav'] +class TestAV(TestRunnerBase): + def __init__(self, test): + assert test == 'test' + super().__init__(AVTestCase().test_data) - unittest.main(exit=False) - suite = unittest.TestSuite() + def test(self): + # dummy function to make unittest try to test this class + pass - # dictionary of data for tests - tests = {'bitmanipav': AVTestCase().test_data} - # walk through all tests, those requested get added - for tname, data in tests.items(): - if tname in testing: - suite.addTest(TestRunnerBase(data)) - - runner = unittest.TextTestRunner() - runner.run(suite) +if __name__ == "__main__": + unittest.main() diff --git a/src/openpower/decoder/isa/test_caller_fmvis.py b/src/openpower/decoder/isa/test_caller_fmvis.py index 1c7638a4..6a71522b 100644 --- a/src/openpower/decoder/isa/test_caller_fmvis.py +++ b/src/openpower/decoder/isa/test_caller_fmvis.py @@ -6,33 +6,21 @@ related bugs: """ import unittest -import sys - -# These tests utilize the run_hdl=False parameter to compare -# simulator with expected states from openpower.test.runner import TestRunnerBase from openpower.test.alu.fmvis_cases import FMVISTestCase +# writing the test_caller invocation this way makes it work with pytest -if __name__ == "__main__": - - # allow list of testing to be selected by command-line - testing = sys.argv[1:] - sys.argv = sys.argv[:1] - if not testing: - testing = ['fmvis', 'fishmv'] +class TestFMVIS(TestRunnerBase): + def __init__(self, test): + assert test == 'test' + super().__init__(FMVISTestCase().test_data) - unittest.main(exit=False) - suite = unittest.TestSuite() + def test(self): + # dummy function to make unittest try to test this class + pass - # dictionary of data for tests - tests = {'fmvis': FMVISTestCase().test_data} - # walk through all tests, those requested get added - for tname, data in tests.items(): - if tname in testing: - suite.addTest(TestRunnerBase(data)) - - runner = unittest.TextTestRunner() - runner.run(suite) +if __name__ == "__main__": + unittest.main() diff --git a/src/openpower/decoder/isa/test_caller_logical.py b/src/openpower/decoder/isa/test_caller_logical.py index 9546319f..9293cd03 100644 --- a/src/openpower/decoder/isa/test_caller_logical.py +++ b/src/openpower/decoder/isa/test_caller_logical.py @@ -6,33 +6,21 @@ related bugs: """ import unittest -import sys - -# These tests utilize the run_hdl=False parameter to compare -# simulator with expected states from openpower.test.runner import TestRunnerBase from openpower.test.logical.logical_cases import LogicalTestCase +# writing the test_caller invocation this way makes it work with pytest -if __name__ == "__main__": - - # allow list of testing to be selected by command-line - testing = sys.argv[1:] - sys.argv = sys.argv[:1] - if not testing: - testing = ['logical'] +class TestLogical(TestRunnerBase): + def __init__(self, test): + assert test == 'test' + super().__init__(LogicalTestCase().test_data) - unittest.main(exit=False) - suite = unittest.TestSuite() + def test(self): + # dummy function to make unittest try to test this class + pass - # dictionary of data for tests - tests = {'logical': LogicalTestCase().test_data} - # walk through all tests, those requested get added - for tname, data in tests.items(): - if tname in testing: - suite.addTest(TestRunnerBase(data)) - - runner = unittest.TextTestRunner() - runner.run(suite) +if __name__ == "__main__": + unittest.main() diff --git a/src/openpower/decoder/isa/test_caller_mul.py b/src/openpower/decoder/isa/test_caller_mul.py index 824d3a93..24b2f00d 100644 --- a/src/openpower/decoder/isa/test_caller_mul.py +++ b/src/openpower/decoder/isa/test_caller_mul.py @@ -6,33 +6,21 @@ related bugs: """ import unittest -import sys - -# These tests utilize the run_hdl=False parameter to compare -# simulator with expected states from openpower.test.runner import TestRunnerBase from openpower.test.mul.mul_cases import MulTestCases2Arg +# writing the test_caller invocation this way makes it work with pytest -if __name__ == "__main__": - - # allow list of testing to be selected by command-line - testing = sys.argv[1:] - sys.argv = sys.argv[:1] - if not testing: - testing = ['mul2'] +class TestMul2Arg(TestRunnerBase): + def __init__(self, test): + assert test == 'test' + super().__init__(MulTestCases2Arg().test_data) - unittest.main(exit=False) - suite = unittest.TestSuite() + def test(self): + # dummy function to make unittest try to test this class + pass - # dictionary of data for tests - tests = {'mul2': MulTestCases2Arg().test_data} - # walk through all tests, those requested get added - for tname, data in tests.items(): - if tname in testing: - suite.addTest(TestRunnerBase(data)) - - runner = unittest.TextTestRunner() - runner.run(suite) +if __name__ == "__main__": + unittest.main() diff --git a/src/openpower/decoder/isa/test_caller_shift_rot.py b/src/openpower/decoder/isa/test_caller_shift_rot.py index 6d0a949f..90bd328b 100644 --- a/src/openpower/decoder/isa/test_caller_shift_rot.py +++ b/src/openpower/decoder/isa/test_caller_shift_rot.py @@ -6,33 +6,21 @@ related bugs: """ import unittest -import sys - -# These tests utilize the run_hdl=False parameter to compare -# simulator with expected states from openpower.test.runner import TestRunnerBase from openpower.test.shift_rot.shift_rot_cases2 import ShiftRotTestCase2 +# writing the test_caller invocation this way makes it work with pytest -if __name__ == "__main__": - - # allow list of testing to be selected by command-line - testing = sys.argv[1:] - sys.argv = sys.argv[:1] - if not testing: - testing = ['shiftrot2'] +class TestShiftRot2(TestRunnerBase): + def __init__(self, test): + assert test == 'test' + super().__init__(ShiftRotTestCase2().test_data) - unittest.main(exit=False) - suite = unittest.TestSuite() + def test(self): + # dummy function to make unittest try to test this class + pass - # dictionary of data for tests - tests = {'shiftrot2': ShiftRotTestCase2().test_data} - # walk through all tests, those requested get added - for tname, data in tests.items(): - if tname in testing: - suite.addTest(TestRunnerBase(data)) - - runner = unittest.TextTestRunner() - runner.run(suite) +if __name__ == "__main__": + unittest.main() diff --git a/src/openpower/decoder/isa/test_caller_svp64_alu.py b/src/openpower/decoder/isa/test_caller_svp64_alu.py index 1a294d5d..5b10bead 100644 --- a/src/openpower/decoder/isa/test_caller_svp64_alu.py +++ b/src/openpower/decoder/isa/test_caller_svp64_alu.py @@ -6,33 +6,21 @@ related bugs: """ import unittest -import sys - -# These tests utilize the run_hdl=False parameter to compare -# simulator with expected states from openpower.test.runner import TestRunnerBase from openpower.test.alu.svp64_cases import SVP64ALUTestCase +# writing the test_caller invocation this way makes it work with pytest -if __name__ == "__main__": - - # allow list of testing to be selected by command-line - testing = sys.argv[1:] - sys.argv = sys.argv[:1] - if not testing: - testing = ['svp64_alu'] +class TestSVP64ALU(TestRunnerBase): + def __init__(self, test): + assert test == 'test' + super().__init__(SVP64ALUTestCase().test_data) - unittest.main(exit=False) - suite = unittest.TestSuite() + def test(self): + # dummy function to make unittest try to test this class + pass - # dictionary of data for tests - tests = {'svp64_alu': SVP64ALUTestCase().test_data} - # walk through all tests, those requested get added - for tname, data in tests.items(): - if tname in testing: - suite.addTest(TestRunnerBase(data)) - - runner = unittest.TextTestRunner() - runner.run(suite) +if __name__ == "__main__": + unittest.main() diff --git a/src/openpower/decoder/isa/test_caller_svp64_logical.py b/src/openpower/decoder/isa/test_caller_svp64_logical.py index bc600cf7..b98ebeb3 100644 --- a/src/openpower/decoder/isa/test_caller_svp64_logical.py +++ b/src/openpower/decoder/isa/test_caller_svp64_logical.py @@ -6,33 +6,21 @@ related bugs: """ import unittest -import sys - -# These tests utilize the run_hdl=False parameter to compare -# simulator with expected states from openpower.test.runner import TestRunnerBase from openpower.test.logical.svp64_cases import SVP64LogicalTestCase +# writing the test_caller invocation this way makes it work with pytest -if __name__ == "__main__": - - # allow list of testing to be selected by command-line - testing = sys.argv[1:] - sys.argv = sys.argv[:1] - if not testing: - testing = ['svp64_logical'] +class TestSVP64Logical(TestRunnerBase): + def __init__(self, test): + assert test == 'test' + super().__init__(SVP64LogicalTestCase().test_data) - unittest.main(exit=False) - suite = unittest.TestSuite() + def test(self): + # dummy function to make unittest try to test this class + pass - # dictionary of data for tests - tests = {'svp64_logical': SVP64LogicalTestCase().test_data} - # walk through all tests, those requested get added - for tname, data in tests.items(): - if tname in testing: - suite.addTest(TestRunnerBase(data)) - - runner = unittest.TextTestRunner() - runner.run(suite) +if __name__ == "__main__": + unittest.main() diff --git a/src/openpower/decoder/isa/test_caller_svp64_utf_8_validation.py b/src/openpower/decoder/isa/test_caller_svp64_utf_8_validation.py index e14b12c5..de86dfb0 100644 --- a/src/openpower/decoder/isa/test_caller_svp64_utf_8_validation.py +++ b/src/openpower/decoder/isa/test_caller_svp64_utf_8_validation.py @@ -8,6 +8,7 @@ from openpower.test.runner import TestRunnerBase # writing the test_caller invocation this way makes it work with pytest + class TestSVP64UTF8Validation(TestRunnerBase): def __init__(self, test): assert test == 'test'