Roland Mikhel | 9f4ef83 | 2023-02-16 19:21:07 +0100 | [diff] [blame] | 1 | # Copyright (c) 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 | |
| 15 | import collections |
| 16 | import yaml |
| 17 | |
| 18 | CATEGORIES = { |
| 19 | 'TOTAL': 'Total tests run', |
| 20 | 'SUCCESS': 'Tests executed successfully', |
| 21 | 'FAILED': 'Tests failed to execute successfully', |
| 22 | # the execution never reached the address |
| 23 | 'ADDRES_NOEXEC': 'Address was not executed', |
| 24 | # The address was successfully skipped by the debugger |
| 25 | 'SKIPPED': 'Address was skipped', |
| 26 | 'NO_BOOT': 'System not booted (desired behaviour)', |
| 27 | 'BOOT': 'System booted (undesired behaviour)' |
| 28 | } |
| 29 | |
| 30 | |
| 31 | def parse_yaml_file(filepath): |
| 32 | with open(filepath) as f: |
| 33 | results = yaml.safe_load(f) |
| 34 | |
| 35 | if not results: |
| 36 | raise ValueError("Failed to parse output yaml file.") |
| 37 | |
| 38 | test_stats = collections.Counter() |
| 39 | failed_boot_last_lines = collections.Counter() |
| 40 | exec_fail_reasons = collections.Counter() |
| 41 | |
| 42 | for test in results: |
| 43 | test = test["skip_test"] |
| 44 | |
| 45 | test_stats.update([CATEGORIES['TOTAL']]) |
| 46 | |
| 47 | if test["test_exec_ok"]: |
| 48 | test_stats.update([CATEGORIES['SUCCESS']]) |
| 49 | |
| 50 | if "skipped" in test.keys() and not test["skipped"]: |
| 51 | # The debugger didn't stop at this address |
| 52 | test_stats.update([CATEGORIES['ADDRES_NOEXEC']]) |
| 53 | continue |
| 54 | |
| 55 | if test["boot"]: |
| 56 | test_stats.update([CATEGORIES['BOOT']]) |
| 57 | continue |
| 58 | |
| 59 | failed_boot_last_lines.update([test["last_line"]]) |
| 60 | else: |
| 61 | exec_fail_reasons.update([test["test_exec_fail_reason"]]) |
| 62 | |
| 63 | return test_stats, failed_boot_last_lines, exec_fail_reasons |