2010-05-10 16:21:10 -07:00
|
|
|
#!/bin/sh
|
2010-05-25 13:09:03 -07:00
|
|
|
|
2012-11-07 13:58:14 -08:00
|
|
|
if [ ! -z "$srcdir" ]; then
|
|
|
|
|
testdir=$srcdir/tests
|
|
|
|
|
glcpp=`pwd`/glcpp
|
|
|
|
|
else
|
|
|
|
|
testdir=.
|
|
|
|
|
glcpp=../glcpp
|
|
|
|
|
fi
|
|
|
|
|
|
2010-08-11 12:46:16 -07:00
|
|
|
trap 'rm $test.valgrind-errors; exit 1' INT QUIT
|
|
|
|
|
|
2011-04-14 14:55:52 -07:00
|
|
|
usage ()
|
|
|
|
|
{
|
|
|
|
|
cat <<EOF
|
|
|
|
|
Usage: glcpp [options...]
|
|
|
|
|
|
|
|
|
|
Run the test suite for mesa's GLSL pre-processor.
|
|
|
|
|
|
|
|
|
|
Valid options include:
|
|
|
|
|
|
|
|
|
|
--valgrind Run the test suite a second time under valgrind
|
|
|
|
|
EOF
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Parse command-line options
|
|
|
|
|
for option; do
|
|
|
|
|
if [ "${option}" = '--help' ] ; then
|
|
|
|
|
usage
|
|
|
|
|
exit 0
|
|
|
|
|
elif [ "${option}" = '--valgrind' ] ; then
|
|
|
|
|
do_valgrind=yes
|
|
|
|
|
else
|
|
|
|
|
echo "Unrecognized option: $option" >&2
|
|
|
|
|
echo >&2
|
|
|
|
|
usage
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
2010-07-19 17:48:17 -07:00
|
|
|
total=0
|
|
|
|
|
pass=0
|
2010-07-19 17:49:23 -07:00
|
|
|
clean=0
|
2010-07-19 17:48:17 -07:00
|
|
|
|
2010-07-19 17:49:23 -07:00
|
|
|
echo "====== Testing for correctness ======"
|
2012-11-07 13:58:14 -08:00
|
|
|
for test in $testdir/*.c; do
|
2010-07-19 17:48:17 -07:00
|
|
|
echo -n "Testing $test..."
|
2012-11-07 13:58:14 -08:00
|
|
|
$glcpp < $test > $test.out 2>&1
|
2010-07-19 17:48:17 -07:00
|
|
|
total=$((total+1))
|
2010-08-10 18:27:31 -07:00
|
|
|
if cmp $test.expected $test.out >/dev/null 2>&1; then
|
2010-07-19 17:48:17 -07:00
|
|
|
echo "PASS"
|
|
|
|
|
pass=$((pass+1))
|
|
|
|
|
else
|
|
|
|
|
echo "FAIL"
|
|
|
|
|
diff -u $test.expected $test.out
|
|
|
|
|
fi
|
2010-05-10 16:21:10 -07:00
|
|
|
done
|
2010-07-19 17:48:17 -07:00
|
|
|
|
2010-07-19 17:49:23 -07:00
|
|
|
echo ""
|
2010-07-19 17:48:17 -07:00
|
|
|
echo "$pass/$total tests returned correct results"
|
|
|
|
|
echo ""
|
|
|
|
|
|
2011-04-14 14:55:52 -07:00
|
|
|
if [ "$do_valgrind" = "yes" ]; then
|
|
|
|
|
echo "====== Testing for valgrind cleanliness ======"
|
2012-11-07 13:58:14 -08:00
|
|
|
for test in $testdir/*.c; do
|
2011-04-14 14:55:52 -07:00
|
|
|
echo -n "Testing $test with valgrind..."
|
2012-11-07 13:58:14 -08:00
|
|
|
valgrind --error-exitcode=31 --log-file=$test.valgrind-errors $glcpp < $test >/dev/null 2>&1
|
2011-04-14 14:55:52 -07:00
|
|
|
if [ "$?" = "31" ]; then
|
|
|
|
|
echo "ERRORS"
|
|
|
|
|
cat $test.valgrind-errors
|
|
|
|
|
else
|
|
|
|
|
echo "CLEAN"
|
|
|
|
|
clean=$((clean+1))
|
|
|
|
|
rm $test.valgrind-errors
|
|
|
|
|
fi
|
|
|
|
|
done
|
2010-07-19 17:49:23 -07:00
|
|
|
|
2011-04-14 14:55:52 -07:00
|
|
|
echo ""
|
|
|
|
|
echo "$pass/$total tests returned correct results"
|
|
|
|
|
echo "$clean/$total tests are valgrind-clean"
|
|
|
|
|
fi
|
2010-07-19 17:49:23 -07:00
|
|
|
|
2012-01-28 22:08:39 -05:00
|
|
|
if [ "$pass" = "$total" ] && [ "$do_valgrind" != "yes" ] || [ "$pass" = "$total" ]; then
|
2010-07-19 17:48:17 -07:00
|
|
|
exit 0
|
|
|
|
|
else
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|