1# Copyright (c) 2020-2023 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 15import argparse 16from utils import CATEGORIES, parse_yaml_file 17 18 19def print_results(results): 20 21 test_stats, failed_boot_last_lines, exec_fail_reasons = results 22 23 print("{:s}: {:d}.".format(CATEGORIES['TOTAL'], test_stats[CATEGORIES['TOTAL']])) 24 print("{:s} ({:d}):".format(CATEGORIES['SUCCESS'], test_stats[CATEGORIES['SUCCESS']])) 25 print(" {:s}: ({:d}):".format(CATEGORIES['ADDRES_NOEXEC'], test_stats[CATEGORIES['ADDRES_NOEXEC']])) 26 test_with_skip = test_stats[CATEGORIES['SUCCESS']] - test_stats[CATEGORIES['ADDRES_NOEXEC']] 27 print(" {:s}: ({:d}):".format(CATEGORIES['SKIPPED'], test_with_skip)) 28 print(" {:s} ({:d}):".format(CATEGORIES['NO_BOOT'], test_with_skip - test_stats[CATEGORIES['BOOT']])) 29 for last_line in failed_boot_last_lines.keys(): 30 print(" last line: {:s} ({:d})".format(last_line, failed_boot_last_lines[last_line])) 31 print(" {:s} ({:d})".format(CATEGORIES['BOOT'], test_stats[CATEGORIES['BOOT']])) 32 print("{:s} ({:d}):".format(CATEGORIES['FAILED'], test_stats[CATEGORIES['TOTAL']] - test_stats[CATEGORIES['SUCCESS']])) 33 for reason in exec_fail_reasons.keys(): 34 print(" {:s} ({:d})".format(reason, exec_fail_reasons[reason])) 35 36 37def main(): 38 parser = argparse.ArgumentParser(description='''Process a FIH test output yaml file, and output a human readable report''') 39 parser.add_argument('filename', help='yaml file to process') 40 41 args = parser.parse_args() 42 results = parse_yaml_file(args.filename) 43 print_results(results) 44 45 46if __name__ == "__main__": 47 main() 48