From cf47d6147cd48506fae3a1652dadf1384379f959 Mon Sep 17 00:00:00 2001 From: Antonio Maiorano Date: Tue, 4 Oct 2022 19:48:41 +0000 Subject: [PATCH] tint: add parse_hlsl_errors.py to help triage hlsl errors Change-Id: If160a8c72c407874060024c365faca83722b541f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103760 Kokoro: Kokoro Reviewed-by: Ben Clayton Commit-Queue: Antonio Maiorano --- test/tint/parse_hlsl_errors.py | 74 ++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 test/tint/parse_hlsl_errors.py diff --git a/test/tint/parse_hlsl_errors.py b/test/tint/parse_hlsl_errors.py new file mode 100644 index 0000000000..45dd85c8d8 --- /dev/null +++ b/test/tint/parse_hlsl_errors.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python3 + +# Copyright 2021 The Tint Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Parses expected.*.hlsl files for errors and outputs a report. +# +# Usage: +# parse_hlsl_erors + +import glob +import re +import argparse + +parser = argparse.ArgumentParser() +parser.add_argument('--list-files', dest='list_files', action='store_true') +parser.add_argument('--no-list-files', dest='list_files', action='store_false') +parser.set_defaults(list_files=True) +args = parser.parse_args() + +def add_error(error_to_file, error, file): + if not error in error_to_file: + error_to_file[error] = [file] + else: + error_to_file[error].append(file) + +def find_and_print_errors(glob_pathname): + files = glob.glob(glob_pathname, recursive=True) + error_to_file = {} + + for f in files: + found_error = False + with open(f, "r") as fs: + first_line = fs.readline() + if not first_line.startswith("SKIP:"): + continue + for line in fs: + m = re.search('error( X[0-9]+)*?:(.*)', line) + if m: + add_error(error_to_file, m.group(), f) + found_error = True + else: + if "exit status" in line: + add_error(error_to_file, line, f) + found_error = True + if found_error: + break # Stop on first error string found + + if not found_error: + # If no error message was found, add the SKIP line as it may contain the reason for skipping + add_error(error_to_file, first_line.strip(), f) + + for error,files in sorted(error_to_file.items()): + print('{} (count: {})'.format(error, len(files))) + if args.list_files: + for f in files: + print('\t{}'.format(f)) + +print("=== FXC ===") +find_and_print_errors('./**/*.fxc.hlsl') + +print("=== DXC ===") +find_and_print_errors('./**/*.dxc.hlsl')