From 70cf2cd6e3dcff41d02296063282ae7e080383bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thi=C3=A9baud=20Weksteen?= Date: Tue, 14 May 2024 13:36:34 +1000 Subject: [PATCH] Collect test names in sepolicy_tests.py Some entries in Tests were not matching their actual function (e.g., TestSystemTypeViolators instead of TestSystemTypeViolations). Automatically generate the list of tests, based on the 'Test' prefix in their name. Test: sepolicy_tests -h Change-Id: I1865e24c6cc1bfe15f633263897ea7530140c41d --- tests/sepolicy_tests.py | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/tests/sepolicy_tests.py b/tests/sepolicy_tests.py index 1df823183..af4793826 100644 --- a/tests/sepolicy_tests.py +++ b/tests/sepolicy_tests.py @@ -299,24 +299,7 @@ class MultipleOption(Option): else: Option.take_action(self, action, dest, opt, value, values, parser) -Tests = [ - "TestBpffsTypeViolations", - "TestDataTypeViolators", - "TestProcTypeViolations", - "TestSysfsTypeViolations", - "TestSystemTypeViolators", - "TestDebugfsTypeViolations", - "TestTracefsTypeViolations", - "TestVendorTypeViolations", - "TestCoreDataTypeViolations", - "TestPropertyTypeViolations", - "TestAppDataTypeViolations", - "TestDmaHeapDevTypeViolations", - "TestCoredomainViolations", - "TestViolatorAttributes", - "TestIsolatedAttributeConsistency", - "TestDevTypeViolations", -] +TEST_NAMES = [ name for name in dir() if name.startswith('Test') ] def do_main(libpath): """ @@ -330,7 +313,7 @@ def do_main(libpath): metavar="FILE", action="extend", type="string") parser.add_option("-p", "--policy", dest="policy", metavar="FILE") parser.add_option("-t", "--test", dest="test", action="extend", - help="Test options include "+str(Tests)) + help="Test options include "+str(TEST_NAMES)) (options, args) = parser.parse_args()