diff options
Diffstat (limited to 'src/compiler')
-rwxr-xr-x | src/compiler/glsl/tests/warnings-test.sh | 57 | ||||
-rwxr-xr-x | src/compiler/glsl/tests/warnings_test.py | 74 |
2 files changed, 75 insertions, 56 deletions
diff --git a/src/compiler/glsl/tests/warnings-test.sh b/src/compiler/glsl/tests/warnings-test.sh index d5dc3b5974f..09b6bb2fc98 100755 --- a/src/compiler/glsl/tests/warnings-test.sh +++ b/src/compiler/glsl/tests/warnings-test.sh @@ -1,58 +1,3 @@ #!/bin/sh -if [ -z "$srcdir" -o -z "$abs_builddir" ]; then - echo "" - echo "Warning: you're invoking the script manually and things may fail." - echo "Attempting to determine/set srcdir and abs_builddir variables." - echo "" - - # Variable should point to the Makefile.glsl.am - srcdir=./../../ - cd `dirname "$0"` - # Variable should point to glsl_compiler - abs_builddir=`pwd`/../../ -fi - -# Execute several shaders, and check that the InfoLog outcome is the expected. - -compiler=$abs_builddir/glsl_compiler -total=0 -pass=0 - -if [ ! -x "$compiler" ]; then - echo "Could not find glsl_compiler. Ensure that it is build via make check" - exit 1 -fi - -tests_relative_dir="glsl/tests/warnings" - -echo "====== Testing compilation output ======" -for test in $srcdir/$tests_relative_dir/*.vert; do - test_output="$abs_builddir/$tests_relative_dir/`basename $test`" - mkdir -p $abs_builddir/$tests_relative_dir/ - echo -n "Testing `basename $test`..." - $compiler --just-log --version 150 "$test" > "$test_output.out" 2>&1 - total=$((total+1)) - if diff "$test.expected" "$test_output.out" >/dev/null 2>&1; then - echo "PASS" - pass=$((pass+1)) - else - echo "FAIL" - diff "$test.expected" "$test_output.out" - fi -done - -if [ $total -eq 0 ]; then - echo "Could not find any tests." - exit 1 -fi - -echo "" -echo "$pass/$total tests returned correct results" -echo "" - -if [ $pass = $total ]; then - exit 0 -else - exit 1 -fi +$PYTHON2 $srcdir/glsl/tests/warnings_test.py --glsl-compiler $abs_builddir/glsl_compiler --test-directory $srcdir/glsl/tests/warnings/ diff --git a/src/compiler/glsl/tests/warnings_test.py b/src/compiler/glsl/tests/warnings_test.py new file mode 100755 index 00000000000..2e0f23180f3 --- /dev/null +++ b/src/compiler/glsl/tests/warnings_test.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python +# encoding=utf-8 +# Copyright © 2017 Intel Corporation + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +from __future__ import print_function +import argparse +import os +import subprocess + + +def arg_parser(): + parser = argparse.ArgumentParser() + parser.add_argument( + '--glsl-compiler', + required=True, + help='Path to the standalone glsl compiler') + parser.add_argument( + '--test-directory', + required=True, + help='Directory containing tests to run.') + return parser.parse_args() + + +def main(): + args = arg_parser() + files = [f for f in os.listdir(args.test_directory) if f.endswith('.vert')] + passed = 0 + + if not files: + print('Could not find any tests') + exit(1) + + print('====== Testing compilation output ======') + for file in files: + print('Testing {} ...'.format(file), end='') + file = os.path.join(args.test_directory, file) + + with open('{}.expected'.format(file), 'rb') as f: + expected = f.read().strip() + + actual = subprocess.check_output( + [args.glsl_compiler, '--just-log', '--version', '150', file] + ).strip() + + if actual == expected: + print('PASS') + passed += 1 + else: + print('FAIL') + + print('{}/{} tests returned correct results'.format(passed, len(files))) + exit(0 if passed == len(files) else 1) + + +if __name__ == '__main__': + main() |