[Mesa-dev] [PATCH 4/4] glsl/tests/optimization-test: correctly manage srcdir/pwd and co

Emil Velikov emil.l.velikov at gmail.com
Thu Feb 23 16:43:10 UTC 2017


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

At the moment things are completely bonkers (as can be seen from last
commit). Regardless if we run the test as part of "make check" or
standalone the most of the paths are wrong.

Untangle things by issuing "cd `dirname "$0`" and working from there.
Otherwise it's nearly impossible to consider all the permutations one
can use while running outside of "make check"

Clearly document the variables and the intended behaviour.

Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
We really want to cut down all the crazy design here. Dylan ?

sh script which executes a python one, with the latter creating a bunch
of sh ones and hardcoding binary location. Then call the generated sh
scripts, to create the tested OP files. Now compare the expected vs the
tested via another python script which decodes [in to a temporary file]
and calls "diff" to compare them.
---
 src/compiler/glsl/tests/optimization-test | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/compiler/glsl/tests/optimization-test b/src/compiler/glsl/tests/optimization-test
index d84b83cfaa..e851e13bfb 100755
--- a/src/compiler/glsl/tests/optimization-test
+++ b/src/compiler/glsl/tests/optimization-test
@@ -1,10 +1,18 @@
 #!/usr/bin/env bash
 
-if [ ! -z "$srcdir" ]; then
-   compare_ir=`pwd`/tests/compare_ir
-else
-   compare_ir=./compare_ir
+# The srcdir variable must point to the location where the Makefile.am or
+# Makefile.glsl.am in particular is. Even if we execute this test manually.
+
+if [ -z "$srcdir" ]; then
+   srcdir=./../../
+
+    # In the manual invokation case, we must CD otherwise we cannot manage all
+    # the permutations of our scripts which calls a script to create a script
+    # then execute the script design.
+    cd `dirname "$0"`
+    
 fi
+compare_ir=$srcdir/glsl/tests/compare_ir
 
 if [ -z "$PYTHON2" ]; then
     PYTHON2=python2
@@ -20,10 +28,13 @@ total=0
 pass=0
 has_tests=0
 
+# Store our location before we start diving into subdirectories.
+ORIGDIR=`pwd`
 echo "======       Generating tests      ======"
-for dir in tests/*/; do
+for dir in $srcdir/glsl/tests/*/; do
     if [ -e "${dir}create_test_cases.py" ]; then
         cd $dir;
+        echo found
         $PYTHON2 create_test_cases.py
         if [ "x$?" = x0 ]; then
             has_tests=1
@@ -32,6 +43,7 @@ for dir in tests/*/; do
     fi
     echo "$dir"
 done
+cd "$ORIGDIR"
 
 if [ "x$has_tests" = x0 ]; then
     echo "Could not generate any tests."
-- 
2.11.0



More information about the mesa-dev mailing list