glsl/tests/optimisation-test: make sure that $PYTHON2 is set/available
[mesa.git] / src / compiler / glsl / tests / optimization-test.sh
1 #!/bin/sh
2
3 if [ ! -z "$srcdir" ]; then
4 compare_ir=`pwd`/tests/compare_ir.py
5 else
6 compare_ir=./compare_ir.py
7 fi
8
9 if [ -z "$PYTHON2" ]; then
10 PYTHON2=python2
11 fi
12
13 which $PYTHON2 >/dev/null
14 if [ $? -ne 0 ]; then
15 echo "Could not find python2. Make sure that PYTHON2 variable is correctly set."
16 exit 1
17 fi
18
19 total=0
20 pass=0
21
22 echo "====== Generating tests ======"
23 for dir in tests/*/; do
24 if [ -e "${dir}create_test_cases.py" ]; then
25 cd $dir; $PYTHON2 create_test_cases.py; cd ..
26 fi
27 echo "$dir"
28 done
29
30 echo "====== Testing optimization passes ======"
31 for test in `find . -iname '*.opt_test'`; do
32 echo -n "Testing $test..."
33 (cd `dirname "$test"`; ./`basename "$test"`) > "$test.out" 2>&1
34 total=$((total+1))
35 if $PYTHON2 $PYTHON_FLAGS $compare_ir "$test.expected" "$test.out" >/dev/null 2>&1; then
36 echo "PASS"
37 pass=$((pass+1))
38 else
39 echo "FAIL"
40 $PYTHON2 $PYTHON_FLAGS $compare_ir "$test.expected" "$test.out"
41 fi
42 done
43
44 echo ""
45 echo "$pass/$total tests returned correct results"
46 echo ""
47
48 if [ $pass = $total ]; then
49 exit 0
50 else
51 exit 1
52 fi