Skip to content

Commit d4f6053

Browse files
matetothpalnvlsianpu
authored andcommitted
travis: Add Script to summarize FIH test output
Change-Id: I5fbbad8cdaf829dc11543a70e419de45f07002a0 Signed-off-by: Mate Toth-Pal <[email protected]>
1 parent b116398 commit d4f6053

File tree

2 files changed

+89
-2
lines changed

2 files changed

+89
-2
lines changed

ci/fih_test_docker/execute_test.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,4 @@ echo " - FIH_LEVEL: $FIH_LEVEL"
6363
echo " - SKIP_SIZE: $SKIP_SIZE"
6464
echo " - DAMAGE_TYPE: $DAMAGE_TYPE"
6565

66-
# TODO: Create human readable output
67-
cat fih_test_output.yaml
66+
python3 $MCUBOOT_PATH/ci/fih_test_docker/generate_test_report.py fih_test_output.yaml
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Copyright (c) 2020 Arm Limited
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import argparse
16+
import yaml
17+
import collections
18+
19+
CATEGORIES = {
20+
'TOTAL': 'Total tests run',
21+
'SUCCESS': 'Tests executed successfully',
22+
'FAILED': 'Tests failed to execute successfully',
23+
# the execution never reached the address
24+
'ADDRES_NOEXEC': 'Address was not executed',
25+
# The address was successfully skipped by the debugger
26+
'SKIPPED': 'Address was skipped',
27+
'NO_BOOT': 'System not booted (desired behaviour)',
28+
'BOOT': 'System booted (undesired behaviour)'
29+
}
30+
31+
32+
def print_results(results):
33+
test_stats = collections.Counter()
34+
failed_boot_last_lines = collections.Counter()
35+
exec_fail_reasons = collections.Counter()
36+
37+
for test in results:
38+
test = test["skip_test"]
39+
40+
test_stats.update([CATEGORIES['TOTAL']])
41+
42+
if test["test_exec_ok"]:
43+
test_stats.update([CATEGORIES['SUCCESS']])
44+
45+
if "skipped" in test.keys() and not test["skipped"]:
46+
# The debugger didn't stop at this address
47+
test_stats.update([CATEGORIES['ADDRES_NOEXEC']])
48+
continue
49+
50+
if test["boot"]:
51+
test_stats.update([CATEGORIES['BOOT']])
52+
continue
53+
54+
failed_boot_last_lines.update([test["last_line"]])
55+
else:
56+
exec_fail_reasons.update([test["test_exec_fail_reason"]])
57+
58+
print("{:s}: {:d}.".format(CATEGORIES['TOTAL'], test_stats[CATEGORIES['TOTAL']]))
59+
print("{:s} ({:d}):".format(CATEGORIES['SUCCESS'], test_stats[CATEGORIES['SUCCESS']]))
60+
print(" {:s}: ({:d}):".format(CATEGORIES['ADDRES_NOEXEC'], test_stats[CATEGORIES['ADDRES_NOEXEC']]))
61+
test_with_skip = test_stats[CATEGORIES['SUCCESS']] - test_stats[CATEGORIES['ADDRES_NOEXEC']]
62+
print(" {:s}: ({:d}):".format(CATEGORIES['SKIPPED'], test_with_skip))
63+
print(" {:s} ({:d}):".format(CATEGORIES['NO_BOOT'], test_with_skip - test_stats[CATEGORIES['BOOT']]))
64+
for last_line in failed_boot_last_lines.keys():
65+
print(" last line: {:s} ({:d})".format(last_line, failed_boot_last_lines[last_line]))
66+
print(" {:s} ({:d})".format(CATEGORIES['BOOT'], test_stats[CATEGORIES['BOOT']]))
67+
print("{:s} ({:d}):".format(CATEGORIES['FAILED'], test_stats[CATEGORIES['TOTAL']] - test_stats[CATEGORIES['SUCCESS']]))
68+
for reason in exec_fail_reasons.keys():
69+
print(" {:s} ({:d})".format(reason, exec_fail_reasons[reason]))
70+
71+
72+
def main():
73+
parser = argparse.ArgumentParser(description='''Process a FIH test output yaml file, and output a human readable report''')
74+
parser.add_argument('filename', help='yaml file to process')
75+
76+
args = parser.parse_args()
77+
78+
with open(args.filename) as output_yaml_file:
79+
results = yaml.safe_load(output_yaml_file)
80+
81+
if results:
82+
print_results(results)
83+
else:
84+
print("Failed to parse output yaml file.")
85+
86+
87+
if __name__ == "__main__":
88+
main()

0 commit comments

Comments
 (0)