2017-02-22 19:54:58 +00:00
|
|
|
#!/bin/sh
|
2011-07-05 11:52:06 -07:00
|
|
|
|
2017-02-23 13:15:42 +00:00
|
|
|
if [ -z "$PYTHON2" ]; then
|
|
|
|
|
PYTHON2=python2
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
which $PYTHON2 >/dev/null
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
|
echo "Could not find python2. Make sure that PYTHON2 variable is correctly set."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2017-02-23 14:27:08 +00:00
|
|
|
if [ -z "$srcdir" -o -z "$abs_builddir" ]; then
|
|
|
|
|
echo ""
|
|
|
|
|
echo "Warning: you're invoking the script manually and things may fail."
|
|
|
|
|
echo "Attempting to determine/set srcdir and abs_builddir variables."
|
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
|
|
# Variable should point to the Makefile.glsl.am
|
|
|
|
|
srcdir=./../../
|
|
|
|
|
cd `dirname "$0"`
|
|
|
|
|
# Variable should point to the folder two levels above glsl_test
|
|
|
|
|
abs_builddir=`pwd`/../../
|
|
|
|
|
fi
|
|
|
|
|
|
2017-02-27 18:21:36 +00:00
|
|
|
compare_ir=$srcdir/glsl/tests/compare_ir.py
|
|
|
|
|
|
2011-07-05 11:52:06 -07:00
|
|
|
total=0
|
|
|
|
|
pass=0
|
2017-02-23 14:53:03 +00:00
|
|
|
has_tests=0
|
2011-07-05 11:52:06 -07:00
|
|
|
|
2017-02-26 20:17:00 +00:00
|
|
|
# Store our location before we start diving into subdirectories.
|
|
|
|
|
ORIGDIR=`pwd`
|
2014-05-27 21:23:04 -04:00
|
|
|
echo "====== Generating tests ======"
|
2017-02-26 20:17:00 +00:00
|
|
|
for dir in $srcdir/glsl/tests/*/; do
|
2014-05-27 21:23:04 -04:00
|
|
|
if [ -e "${dir}create_test_cases.py" ]; then
|
2017-02-27 18:58:06 +00:00
|
|
|
echo "$dir"
|
2017-02-26 20:17:00 +00:00
|
|
|
# construct the correct builddir
|
|
|
|
|
completedir="$abs_builddir/glsl/tests/`echo ${dir} | sed 's|.*/glsl/tests/||g'`"
|
|
|
|
|
mkdir -p $completedir
|
2017-02-23 14:53:03 +00:00
|
|
|
cd $dir;
|
2017-02-26 20:28:21 +00:00
|
|
|
$PYTHON2 create_test_cases.py --runner $abs_builddir/glsl/glsl_test --outdir $completedir;
|
2017-02-23 14:53:03 +00:00
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
|
has_tests=1
|
|
|
|
|
fi
|
|
|
|
|
cd ..
|
2014-05-27 21:23:04 -04:00
|
|
|
fi
|
|
|
|
|
done
|
2017-02-26 20:17:00 +00:00
|
|
|
cd "$ORIGDIR"
|
2014-05-27 21:23:04 -04:00
|
|
|
|
2017-02-23 14:53:03 +00:00
|
|
|
if [ $has_tests -eq 0 ]; then
|
|
|
|
|
echo "Could not generate any tests."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2017-02-23 14:17:09 +00:00
|
|
|
if [ ! -f "$compare_ir" ]; then
|
|
|
|
|
echo "Could not find compare_ir. Make sure that srcdir variable is correctly set."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2011-07-05 11:52:06 -07:00
|
|
|
echo "====== Testing optimization passes ======"
|
|
|
|
|
for test in `find . -iname '*.opt_test'`; do
|
2017-02-27 18:56:38 +00:00
|
|
|
echo -n "Testing `echo $test| sed 's|.*/glsl/tests/||g'`..."
|
2017-02-26 20:28:21 +00:00
|
|
|
./$test > "$test.out" 2>&1
|
2011-07-05 11:52:06 -07:00
|
|
|
total=$((total+1))
|
2013-01-15 11:45:40 -08:00
|
|
|
if $PYTHON2 $PYTHON_FLAGS $compare_ir "$test.expected" "$test.out" >/dev/null 2>&1; then
|
2011-07-05 11:52:06 -07:00
|
|
|
echo "PASS"
|
|
|
|
|
pass=$((pass+1))
|
|
|
|
|
else
|
|
|
|
|
echo "FAIL"
|
2013-01-15 11:45:40 -08:00
|
|
|
$PYTHON2 $PYTHON_FLAGS $compare_ir "$test.expected" "$test.out"
|
2011-07-05 11:52:06 -07:00
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
2017-02-26 20:43:05 +00:00
|
|
|
if [ $total -eq 0 ]; then
|
|
|
|
|
echo "Could not find any tests."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2011-07-05 11:52:06 -07:00
|
|
|
echo ""
|
|
|
|
|
echo "$pass/$total tests returned correct results"
|
|
|
|
|
echo ""
|
|
|
|
|
|
2017-02-22 19:54:58 +00:00
|
|
|
if [ $pass = $total ]; then
|
2011-07-05 11:52:06 -07:00
|
|
|
exit 0
|
|
|
|
|
else
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|