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
This commit is contained in:
Thiébaud Weksteen 2024-05-14 13:36:34 +10:00
parent fff886e374
commit 70cf2cd6e3

View file

@ -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()