mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 11:20:11 +01:00
Old script created files in the source directory, which is generally considered bad form. The rewrite to python instead of duct-taping around in the shell script goes towards the goal of only having cross-platform python scripts, which is also harder to make mistakes in than shell scripts. Signed-off-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Sagar Ghuge <sagar.ghuge@intel.com> Reviewed-by: Dylan Baker <dylan@pnwbakers.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5155>
49 lines
1.5 KiB
Python
Executable file
49 lines
1.5 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
import argparse
|
|
import difflib
|
|
import pathlib
|
|
import subprocess
|
|
import tempfile
|
|
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument('--i965_asm',
|
|
help='path to i965_asm binary')
|
|
parser.add_argument('--gen_name',
|
|
help='name of the hardware generation (as understood by i965_asm)')
|
|
parser.add_argument('--gen_folder',
|
|
type=pathlib.Path,
|
|
help='name of the folder for the generation')
|
|
args = parser.parse_args()
|
|
|
|
success = True
|
|
|
|
for asm_file in args.gen_folder.glob('*.asm'):
|
|
expected_file = asm_file.stem + '.expected'
|
|
expected_path = args.gen_folder / expected_file
|
|
out_path = tempfile.NamedTemporaryFile()
|
|
|
|
subprocess.run([args.i965_asm,
|
|
'--type', 'hex',
|
|
'--gen', args.gen_name,
|
|
'--output', out_path.name,
|
|
asm_file],
|
|
stdout=subprocess.DEVNULL,
|
|
stderr=subprocess.STDOUT)
|
|
|
|
with expected_path.open() as f:
|
|
lines_before = f.readlines()
|
|
lines_after = [line.decode('ascii') for line in out_path]
|
|
|
|
diff = ''.join(difflib.unified_diff(lines_before, lines_after,
|
|
expected_file, asm_file.stem + '.out'))
|
|
|
|
if diff:
|
|
print('Output comparison for {}:'.format(asm_file.name))
|
|
print(diff)
|
|
success = False
|
|
else:
|
|
print('{} : PASS'.format(asm_file.name))
|
|
|
|
if not success:
|
|
exit(1)
|