Mesa (main): aco/tests: improve reporting of failed code checks
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jun 3 04:04:15 UTC 2021
Module: Mesa
Branch: main
Commit: bb52484df54ec9824229e99ed64e03e2f3a4cd72
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bb52484df54ec9824229e99ed64e03e2f3a4cd72
Author: Rhys Perry <pendingchaos02 at gmail.com>
Date: Thu May 20 10:47:47 2021 +0100
aco/tests: improve reporting of failed code checks
Instead of just reporting the failed statements, print where they
originated. This is useful for tests which have a number of similar
checks.
Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10898>
---
src/amd/compiler/tests/check_output.py | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/src/amd/compiler/tests/check_output.py b/src/amd/compiler/tests/check_output.py
index c4a022e7a34..ad007c44952 100644
--- a/src/amd/compiler/tests/check_output.py
+++ b/src/amd/compiler/tests/check_output.py
@@ -40,10 +40,10 @@ initial_code = '''
import re
def insert_code(code):
- insert_queue.append(CodeCheck(code))
+ insert_queue.append(CodeCheck(code, current_position))
def insert_pattern(pattern):
- insert_queue.append(PatternCheck(pattern, False, '(code pattern)'))
+ insert_queue.append(PatternCheck(pattern, False, current_position))
def vector_gpr(prefix, name, size, align):
insert_code(f'{name} = {name}0')
@@ -80,8 +80,9 @@ def search_re(pattern):
'''
class Check:
- def __init__(self, data):
+ def __init__(self, data, position):
self.data = data.rstrip()
+ self.position = position
def run(self, state):
pass
@@ -109,12 +110,12 @@ class CodeCheck(Check):
state.result.log += state.g['log']
state.g['log'] = ''
except BaseException as e:
- state.result.log += 'code check raised exception:\n'
+ state.result.log += 'code check at %s raised exception:\n' % self.position
state.result.log += code + '\n'
state.result.log += str(e)
return False
if not state.g['success']:
- state.result.log += 'code check failed:\n'
+ state.result.log += 'code check at %s failed:\n' % self.position
state.result.log += code + '\n'
return False
return True
@@ -338,9 +339,8 @@ def do_match(g, pattern, output, skip_lines, in_func=False):
class PatternCheck(Check):
def __init__(self, data, search, position):
- Check.__init__(self, data)
+ Check.__init__(self, data, position)
self.search = search
- self.position = position
def run(self, state):
pattern_stream = StringStream(self.data.rstrip(), 'pattern')
@@ -363,12 +363,13 @@ class CheckState:
self.variant = variant
self.checks = checks
- self.checks.insert(0, CodeCheck(initial_code))
+ self.checks.insert(0, CodeCheck(initial_code, None))
self.insert_queue = []
self.g = {'success': True, 'funcs': {}, 'insert_queue': self.insert_queue,
'variant': variant, 'log': '', 'output': StringStream(output, 'output'),
- 'CodeCheck': CodeCheck, 'PatternCheck': PatternCheck}
+ 'CodeCheck': CodeCheck, 'PatternCheck': PatternCheck,
+ 'current_position': ''}
class TestResult:
def __init__(self, expected):
@@ -381,6 +382,7 @@ def check_output(result, variant, checks, output):
while len(state.checks):
check = state.checks.pop(0)
+ state.current_position = check.position
if not check.run(state):
result.result = 'failed'
return
@@ -398,7 +400,7 @@ def parse_check(variant, line, checks, pos):
if len(checks) and isinstance(checks[-1], CodeCheck):
checks[-1].data += '\n' + line
else:
- checks.append(CodeCheck(line))
+ checks.append(CodeCheck(line, pos))
elif line.startswith('!'):
checks.append(PatternCheck(line[1:], False, pos))
elif line.startswith('>>'):
More information about the mesa-commit
mailing list