From: Dylan Baker Date: Mon, 7 Oct 2019 20:03:58 +0000 (-0700) Subject: glsl/tests: Handle no-exec errors X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=638868bbff5fca0263df3d8fa400f980fb738e10;p=mesa.git glsl/tests: Handle no-exec errors Currently meson doesn't correctly handle passing compiled binaries to scripts in tests. This patch looks to the future (0.53) when meson will have this functionality, but also immediately it fixes these tests in cross compiles by causing them to return 77, which meson interprets as skip. Acked-by: Kristian H. Kristensen --- diff --git a/src/compiler/glsl/tests/optimization_test.py b/src/compiler/glsl/tests/optimization_test.py index 15ca3216f40..a02dcd31a05 100644 --- a/src/compiler/glsl/tests/optimization_test.py +++ b/src/compiler/glsl/tests/optimization_test.py @@ -24,6 +24,8 @@ from __future__ import print_function import argparse import difflib +import errno +import os import subprocess import sys @@ -54,6 +56,14 @@ def compare(actual, expected): return difflib.unified_diff(expected.splitlines(), actual.splitlines()) +def get_test_runner(runner): + """Wrap the test runner in the exe wrapper if necessary.""" + wrapper = os.environ.get('MESON_EXE_WRAPPER', None) + if wrapper is None: + return [runner] + return [wrapper, runner] + + def main(): """Generate each test and report pass or fail.""" args = arg_parser() @@ -61,12 +71,14 @@ def main(): total = 0 passes = 0 + runner = get_test_runner(args.test_runner) + for gen in lower_jump_cases.CASES: for name, opt, source, expected in gen(): total += 1 print('{}: '.format(name), end='') proc = subprocess.Popen( - [args.test_runner, 'optpass', '--quiet', '--input-ir', opt], + runner + ['optpass', '--quiet', '--input-ir', opt], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) @@ -93,4 +105,11 @@ def main(): if __name__ == '__main__': - main() + try: + main() + except OSError as e: + if e.errno == errno.ENOEXEC: + print('Skipping due to lack of exe_wrapper.', file=sys.stderr) + sys.exit(77) + else: + raise diff --git a/src/compiler/glsl/tests/warnings_test.py b/src/compiler/glsl/tests/warnings_test.py index 2c4fa5a0d5a..ed0774880d3 100644 --- a/src/compiler/glsl/tests/warnings_test.py +++ b/src/compiler/glsl/tests/warnings_test.py @@ -21,8 +21,10 @@ from __future__ import print_function import argparse +import errno import os import subprocess +import sys def arg_parser(): @@ -38,6 +40,14 @@ def arg_parser(): return parser.parse_args() +def get_test_runner(runner): + """Wrap the test runner in the exe wrapper if necessary.""" + wrapper = os.environ.get('MESON_EXE_WRAPPER', None) + if wrapper is None: + return [runner] + return [wrapper, runner] + + def main(): args = arg_parser() files = [f for f in os.listdir(args.test_directory) if f.endswith('.vert')] @@ -47,6 +57,8 @@ def main(): print('Could not find any tests') exit(1) + runner = get_test_runner(args.glsl_compiler) + print('====== Testing compilation output ======') for file in files: print('Testing {} ...'.format(file), end='') @@ -56,7 +68,7 @@ def main(): expected = f.read().strip() actual = subprocess.check_output( - [args.glsl_compiler, '--just-log', '--version', '150', file] + runner + ['--just-log', '--version', '150', file] ).strip() if actual == expected: @@ -70,4 +82,11 @@ def main(): if __name__ == '__main__': - main() + try: + main() + except OSError as e: + if e.errno == errno.ENOEXEC: + print('Skipping due to lack of exe_wrapper.', file=sys.stderr) + sys.exit(77) + else: + raise