mirror of
https://github.com/ARMmbed/mbedtls.git
synced 2025-05-10 08:59:05 +08:00
Improve readability of the script
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
This commit is contained in:
parent
31a9b7891a
commit
dd1d6a7cca
@ -64,7 +64,7 @@ def analyze_coverage(results, outcomes, allow_list, full_coverage):
|
|||||||
available = check_test_cases.collect_available_test_cases()
|
available = check_test_cases.collect_available_test_cases()
|
||||||
for suite_case in available:
|
for suite_case in available:
|
||||||
hits = 0
|
hits = 0
|
||||||
for _comp, comp_outcomes in outcomes.items():
|
for comp_outcomes in outcomes.values():
|
||||||
if suite_case in comp_outcomes["successes"] or \
|
if suite_case in comp_outcomes["successes"] or \
|
||||||
suite_case in comp_outcomes["failures"]:
|
suite_case in comp_outcomes["failures"]:
|
||||||
hits += 1
|
hits += 1
|
||||||
@ -96,8 +96,8 @@ def name_matches_pattern(name, str_or_re):
|
|||||||
def analyze_driver_vs_reference(results: Results, outcomes,
|
def analyze_driver_vs_reference(results: Results, outcomes,
|
||||||
component_ref, component_driver,
|
component_ref, component_driver,
|
||||||
ignored_suites, ignored_tests=None):
|
ignored_suites, ignored_tests=None):
|
||||||
"""Check that all tests passed in the reference component are also
|
"""Check that all tests passing in the reference component are also
|
||||||
passed in the corresponding driver component.
|
passing in the corresponding driver component.
|
||||||
Skip:
|
Skip:
|
||||||
- full test suites provided in ignored_suites list
|
- full test suites provided in ignored_suites list
|
||||||
- only some specific test inside a test suite, for which the corresponding
|
- only some specific test inside a test suite, for which the corresponding
|
||||||
@ -144,7 +144,7 @@ def read_outcome_file(outcome_file):
|
|||||||
An outcome collection is a dictionary presentation of the outcome file:
|
An outcome collection is a dictionary presentation of the outcome file:
|
||||||
```
|
```
|
||||||
outcomes = {
|
outcomes = {
|
||||||
"<config>": {
|
"<component>": {
|
||||||
"successes": frozenset(["<suite_case>", ... ]),
|
"successes": frozenset(["<suite_case>", ... ]),
|
||||||
"failures": frozenset(["<suite_case>", ...])
|
"failures": frozenset(["<suite_case>", ...])
|
||||||
}
|
}
|
||||||
@ -156,19 +156,19 @@ suite_case = "<suite>;<case>"
|
|||||||
outcomes = {}
|
outcomes = {}
|
||||||
with open(outcome_file, 'r', encoding='utf-8') as input_file:
|
with open(outcome_file, 'r', encoding='utf-8') as input_file:
|
||||||
for line in input_file:
|
for line in input_file:
|
||||||
(_platform, config, suite, case, result, _cause) = line.split(';')
|
(_platform, component, suite, case, result, _cause) = line.split(';')
|
||||||
suite_case = ';'.join([suite, case])
|
suite_case = ';'.join([suite, case])
|
||||||
if config not in outcomes:
|
if component not in outcomes:
|
||||||
outcomes[config] = {"successes":[], "failures":[]}
|
outcomes[component] = {"successes":[], "failures":[]}
|
||||||
if result == 'PASS':
|
if result == 'PASS':
|
||||||
outcomes[config]['successes'].append(suite_case)
|
outcomes[component]['successes'].append(suite_case)
|
||||||
elif result == 'FAIL':
|
elif result == 'FAIL':
|
||||||
outcomes[config]['failures'].append(suite_case)
|
outcomes[component]['failures'].append(suite_case)
|
||||||
|
|
||||||
# Convert `list` to `frozenset` to improve search performance
|
# Convert `list` to `frozenset` to improve search performance
|
||||||
for config in outcomes:
|
for component in outcomes:
|
||||||
outcomes[config]['successes'] = frozenset(outcomes[config]['successes'])
|
outcomes[component]['successes'] = frozenset(outcomes[component]['successes'])
|
||||||
outcomes[config]['failures'] = frozenset(outcomes[config]['failures'])
|
outcomes[component]['failures'] = frozenset(outcomes[component]['failures'])
|
||||||
|
|
||||||
return outcomes
|
return outcomes
|
||||||
|
|
||||||
@ -489,9 +489,9 @@ def main():
|
|||||||
|
|
||||||
KNOWN_TASKS['analyze_coverage']['args']['full_coverage'] = options.full_coverage
|
KNOWN_TASKS['analyze_coverage']['args']['full_coverage'] = options.full_coverage
|
||||||
|
|
||||||
# If the outcome file already exists, we assume that the user wants to
|
# If the outcome file exists, parse it once and share the result
|
||||||
# perform the comparison.
|
# among tasks to improve performance.
|
||||||
# Share the contents among tasks to improve performance.
|
# Otherwise, it will be generated by do_analyze_driver_vs_reference.
|
||||||
if os.path.exists(options.outcomes):
|
if os.path.exists(options.outcomes):
|
||||||
main_results.info("Read outcome file from {}.", options.outcomes)
|
main_results.info("Read outcome file from {}.", options.outcomes)
|
||||||
outcomes_or_file = read_outcome_file(options.outcomes)
|
outcomes_or_file = read_outcome_file(options.outcomes)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user