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 <hoegsberg@google.com>
This commit is contained in:
Dylan Baker
2019-10-07 13:03:58 -07:00
parent 1bf5e5a011
commit 638868bbff
2 changed files with 42 additions and 4 deletions

View File

@@ -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

View File

@@ -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