Remove now-useless level of method call indirection

No intended behavior change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2024-09-16 20:32:59 +02:00
parent 95b2b0c160
commit 0a7d96d266

View File

@ -156,9 +156,7 @@ class CoverageTask(Task):
def section_name() -> str: def section_name() -> str:
return "Analyze coverage" return "Analyze coverage"
@staticmethod def run(self, results: Results, outcomes: Outcomes) -> None:
def analyze_coverage(results: Results, outcomes: Outcomes,
allow_list: typing.List[str], full_coverage: bool) -> None:
"""Check that all available test cases are executed at least once.""" """Check that all available test cases are executed at least once."""
# Make sure that the generated data files are present (and up-to-date). # Make sure that the generated data files are present (and up-to-date).
# This allows analyze_outcomes.py to run correctly on a fresh Git # This allows analyze_outcomes.py to run correctly on a fresh Git
@ -177,23 +175,18 @@ class CoverageTask(Task):
suite_case in comp_outcomes.failures suite_case in comp_outcomes.failures
for comp_outcomes in outcomes.values()) for comp_outcomes in outcomes.values())
if not hit and suite_case not in allow_list: if not hit and suite_case not in self.ALLOW_LIST:
if full_coverage: if self.full_coverage:
results.error('Test case not executed: {}', suite_case) results.error('Test case not executed: {}', suite_case)
else: else:
results.warning('Test case not executed: {}', suite_case) results.warning('Test case not executed: {}', suite_case)
elif hit and suite_case in allow_list: elif hit and suite_case in self.ALLOW_LIST:
# Test Case should be removed from the allow list. # Test Case should be removed from the allow list.
if full_coverage: if self.full_coverage:
results.error('Allow listed test case was executed: {}', suite_case) results.error('Allow listed test case was executed: {}', suite_case)
else: else:
results.warning('Allow listed test case was executed: {}', suite_case) results.warning('Allow listed test case was executed: {}', suite_case)
def run(self, results: Results, outcomes: Outcomes):
"""Check that all test cases are executed at least once."""
self.analyze_coverage(results, outcomes,
self.ALLOW_LIST, self.full_coverage)
class DriverVSReference(Task): class DriverVSReference(Task):
"""Compare outcomes from testing with and without a driver. """Compare outcomes from testing with and without a driver.
@ -218,13 +211,15 @@ class DriverVSReference(Task):
# see the `name_matches_pattern` function. # see the `name_matches_pattern` function.
IGNORED_TESTS = {} #type: typing.Dict[str, typing.List[IgnoreEntry]] IGNORED_TESTS = {} #type: typing.Dict[str, typing.List[IgnoreEntry]]
def __init__(self, options) -> None:
super().__init__(options)
self.ignored_suites = frozenset('test_suite_' + x
for x in self.IGNORED_SUITES)
def section_name(self) -> str: def section_name(self) -> str:
return f"Analyze driver {self.DRIVER} vs reference {self.REFERENCE}" return f"Analyze driver {self.DRIVER} vs reference {self.REFERENCE}"
@staticmethod def run(self, results: Results, outcomes: Outcomes) -> None:
def analyze_driver_vs_reference(results: Results, outcomes: Outcomes,
component_ref: str, component_driver: str,
ignored_suites: typing.List[str], ignored_tests=None) -> None:
"""Check that all tests passing in the driver component are also """Check that all tests passing in the driver component are also
passing in the corresponding reference component. passing in the corresponding reference component.
Skip: Skip:
@ -232,8 +227,8 @@ class DriverVSReference(Task):
- only some specific test inside a test suite, for which the corresponding - only some specific test inside a test suite, for which the corresponding
output string is provided output string is provided
""" """
ref_outcomes = outcomes.get("component_" + component_ref) ref_outcomes = outcomes.get("component_" + self.REFERENCE)
driver_outcomes = outcomes.get("component_" + component_driver) driver_outcomes = outcomes.get("component_" + self.DRIVER)
if ref_outcomes is None or driver_outcomes is None: if ref_outcomes is None or driver_outcomes is None:
results.error("required components are missing: bad outcome file?") results.error("required components are missing: bad outcome file?")
@ -249,15 +244,16 @@ class DriverVSReference(Task):
test_suite = full_test_suite.split('.')[0] # retrieve main part of test suite name test_suite = full_test_suite.split('.')[0] # retrieve main part of test suite name
# Immediately skip fully-ignored test suites # Immediately skip fully-ignored test suites
if test_suite in ignored_suites or full_test_suite in ignored_suites: if test_suite in self.ignored_suites or \
full_test_suite in self.ignored_suites:
continue continue
# For ignored test cases inside test suites, just remember and: # For ignored test cases inside test suites, just remember and:
# don't issue an error if they're skipped with drivers, # don't issue an error if they're skipped with drivers,
# but issue an error if they're not (means we have a bad entry). # but issue an error if they're not (means we have a bad entry).
ignored = False ignored = False
for str_or_re in (ignored_tests.get(full_test_suite, []) + for str_or_re in (self.IGNORED_TESTS.get(full_test_suite, []) +
ignored_tests.get(test_suite, [])): self.IGNORED_TESTS.get(test_suite, [])):
if name_matches_pattern(test_string, str_or_re): if name_matches_pattern(test_string, str_or_re):
ignored = True ignored = True
@ -266,13 +262,6 @@ class DriverVSReference(Task):
if ignored and suite_case in driver_outcomes.successes: if ignored and suite_case in driver_outcomes.successes:
results.error("uselessly ignored: {}", suite_case) results.error("uselessly ignored: {}", suite_case)
def run(self, results: Results, outcomes: Outcomes) -> None:
"""Compare driver test outcomes with reference outcomes."""
ignored_suites = ['test_suite_' + x for x in self.IGNORED_SUITES]
self.analyze_driver_vs_reference(results, outcomes,
self.REFERENCE, self.DRIVER,
ignored_suites, self.IGNORED_TESTS)
# The names that we give to classes derived from DriverVSReference do not # The names that we give to classes derived from DriverVSReference do not
# follow the usual naming convention, because it's more readable to use # follow the usual naming convention, because it's more readable to use