glsl/tests/optimization-test: correctly set compare_ir
[mesa.git] / src / compiler / glsl / tests / optimization-test.sh
1 #!/bin/sh
2
3 if [ -z "$PYTHON2" ]; then
4 PYTHON2=python2
5 fi
6
7 which $PYTHON2 >/dev/null
8 if [ $? -ne 0 ]; then
9 echo "Could not find python2. Make sure that PYTHON2 variable is correctly set."
10 exit 1
11 fi
12
13 if [ -z "$srcdir" -o -z "$abs_builddir" ]; then
14 echo ""
15 echo "Warning: you're invoking the script manually and things may fail."
16 echo "Attempting to determine/set srcdir and abs_builddir variables."
17 echo ""
18
19 # Variable should point to the Makefile.glsl.am
20 srcdir=./../../
21 cd `dirname "$0"`
22 # Variable should point to the folder two levels above glsl_test
23 abs_builddir=`pwd`/../../
24 fi
25
26 compare_ir=$srcdir/glsl/tests/compare_ir.py
27
28 total=0
29 pass=0
30
31 echo "====== Generating tests ======"
32 for dir in tests/*/; do
33 if [ -e "${dir}create_test_cases.py" ]; then
34 cd $dir; $PYTHON2 create_test_cases.py; cd ..
35 fi
36 echo "$dir"
37 done
38
39 echo "====== Testing optimization passes ======"
40 for test in `find . -iname '*.opt_test'`; do
41 echo -n "Testing $test..."
42 (cd `dirname "$test"`; ./`basename "$test"`) > "$test.out" 2>&1
43 total=$((total+1))
44 if $PYTHON2 $PYTHON_FLAGS $compare_ir "$test.expected" "$test.out" >/dev/null 2>&1; then
45 echo "PASS"
46 pass=$((pass+1))
47 else
48 echo "FAIL"
49 $PYTHON2 $PYTHON_FLAGS $compare_ir "$test.expected" "$test.out"
50 fi
51 done
52
53 echo ""
54 echo "$pass/$total tests returned correct results"
55 echo ""
56
57 if [ $pass = $total ]; then
58 exit 0
59 else
60 exit 1
61 fi