[Mesa-dev] [PATCH v2 14/23] glsl/tests/optimization-test: pass glsl_test as argument

Emil Velikov emil.l.velikov at gmail.com
Fri Mar 17 13:19:40 UTC 2017


From: Emil Velikov <emil.velikov at collabora.com>

Rather than hardcoding the binary location (which ends up wrong in a
number of occasions) in the python script, pass it as argument.

This allows us to remove a couple of dirname/basename workarounds that
aimed to keep this working, and succeeded in the odd occasion.

Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
 src/compiler/glsl/tests/lower_jumps/create_test_cases.py | 7 ++++++-
 src/compiler/glsl/tests/optimization-test.sh             | 4 ++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/compiler/glsl/tests/lower_jumps/create_test_cases.py b/src/compiler/glsl/tests/lower_jumps/create_test_cases.py
index defff2ed34f..f1217b8020f 100644
--- a/src/compiler/glsl/tests/lower_jumps/create_test_cases.py
+++ b/src/compiler/glsl/tests/lower_jumps/create_test_cases.py
@@ -31,6 +31,7 @@ import sys
 sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..')) # For access to sexps.py, which is in parent dir
 from sexps import *
 
+runner = ":"
 outdir = "."
 def make_test_case(f_name, ret_type, body):
     """Create a simple optimization test case consisting of a single
@@ -290,7 +291,7 @@ def create_test_case(doc_string, input_sexp, expected_sexp, test_name,
         'do_lower_jumps({0:d}, {1:d}, {2:d}, {3:d}, {4:d})'.format(
             pull_out_jumps, lower_sub_return, lower_main_return,
             lower_continue, lower_break))
-    args = ['../../glsl_test', 'optpass', '--quiet', '--input-ir', optimization]
+    args = [runner, 'optpass', '--quiet', '--input-ir', optimization]
     test_file = os.path.join(outdir, '{0}.opt_test'.format(test_name))
     with open(test_file, 'w') as f:
         f.write('#!/usr/bin/env bash\n#\n# This file was generated by create_test_cases.py.\n#\n')
@@ -626,10 +627,14 @@ def test_lower_return_non_void_at_end_of_loop():
 
 if __name__ == '__main__':
     parser = argparse.ArgumentParser()
+    parser.add_argument('--runner',
+                        help='The glsl_test runner',
+                        required=True)
     parser.add_argument('--outdir',
                         help='Directory to put the generated files in',
                         required=True)
     args = parser.parse_args()
+    runner = args.runner
     outdir = args.outdir
 
     test_lower_returns_main()
diff --git a/src/compiler/glsl/tests/optimization-test.sh b/src/compiler/glsl/tests/optimization-test.sh
index 86a87b0d954..ddfa7886b5a 100755
--- a/src/compiler/glsl/tests/optimization-test.sh
+++ b/src/compiler/glsl/tests/optimization-test.sh
@@ -38,7 +38,7 @@ for dir in $srcdir/glsl/tests/*/; do
         completedir="$abs_builddir/glsl/tests/`echo ${dir} | sed 's|.*/glsl/tests/||g'`"
         mkdir -p $completedir
         cd $dir;
-        $PYTHON2 create_test_cases.py --outdir $completedir;
+        $PYTHON2 create_test_cases.py --runner $abs_builddir/glsl/glsl_test --outdir $completedir;
         if [ $? -eq 0 ]; then
             has_tests=1
         fi
@@ -61,7 +61,7 @@ fi
 echo "====== Testing optimization passes ======"
 for test in `find . -iname '*.opt_test'`; do
     echo -n "Testing $test..."
-    (cd `dirname "$test"`; ./`basename "$test"`) > "$test.out" 2>&1
+    ./$test > "$test.out" 2>&1
     total=$((total+1))
     if $PYTHON2 $PYTHON_FLAGS $compare_ir "$test.expected" "$test.out" >/dev/null 2>&1; then
         echo "PASS"
-- 
2.11.1



More information about the mesa-dev mailing list