1#!/bin/sh 2 3if [ -z "$PYTHON2" ]; then 4 PYTHON2=python2 5fi 6 7which $PYTHON2 >/dev/null 8if [ $? -ne 0 ]; then 9 echo "Could not find python2. Make sure that PYTHON2 variable is correctly set." 10 exit 1 11fi 12 13if [ -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`/../../ 24fi 25 26compare_ir=$srcdir/glsl/tests/compare_ir.py 27 28total=0 29pass=0 30has_tests=0 31 32# Store our location before we start diving into subdirectories. 33ORIGDIR=`pwd` 34echo "====== Generating tests ======" 35for dir in $srcdir/glsl/tests/*/; do 36 if [ -e "${dir}create_test_cases.py" ]; then 37 echo "$dir" 38 # construct the correct builddir 39 completedir="$abs_builddir/glsl/tests/`echo ${dir} | sed 's|.*/glsl/tests/||g'`" 40 mkdir -p $completedir 41 cd $dir; 42 $PYTHON2 create_test_cases.py --runner $abs_builddir/glsl/glsl_test --outdir $completedir; 43 if [ $? -eq 0 ]; then 44 has_tests=1 45 fi 46 cd .. 47 fi 48done 49cd "$ORIGDIR" 50 51if [ $has_tests -eq 0 ]; then 52 echo "Could not generate any tests." 53 exit 1 54fi 55 56if [ ! -f "$compare_ir" ]; then 57 echo "Could not find compare_ir. Make sure that srcdir variable is correctly set." 58 exit 1 59fi 60 61echo "====== Testing optimization passes ======" 62for test in `find . -iname '*.opt_test'`; do 63 echo -n "Testing `echo $test| sed 's|.*/glsl/tests/||g'`..." 64 ./$test > "$test.out" 2>&1 65 total=$((total+1)) 66 if $PYTHON2 $PYTHON_FLAGS $compare_ir "$test.expected" "$test.out" >/dev/null 2>&1; then 67 echo "PASS" 68 pass=$((pass+1)) 69 else 70 echo "FAIL" 71 $PYTHON2 $PYTHON_FLAGS $compare_ir "$test.expected" "$test.out" 72 fi 73done 74 75if [ $total -eq 0 ]; then 76 echo "Could not find any tests." 77 exit 1 78fi 79 80echo "" 81echo "$pass/$total tests returned correct results" 82echo "" 83 84if [ $pass = $total ]; then 85 exit 0 86else 87 exit 1 88fi 89