2010-05-10 16:21:10 -07:00
|
|
|
#!/bin/sh
|
2010-05-25 13:09:03 -07:00
|
|
|
|
2017-02-28 12:02:35 +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 ""
|
|
|
|
|
|
|
|
|
|
# Should point to `dirname Makefile.glsl.am`
|
|
|
|
|
srcdir=./../../../
|
|
|
|
|
cd `dirname "$0"`
|
|
|
|
|
# Should point to `dirname Makefile` equivalent to the above.
|
|
|
|
|
abs_builddir=`pwd`/../../../
|
2012-11-07 13:58:14 -08:00
|
|
|
fi
|
|
|
|
|
|
2017-02-28 12:02:35 +00:00
|
|
|
testdir=$srcdir/glsl/glcpp/tests
|
|
|
|
|
outdir=$abs_builddir/glsl/glcpp/tests
|
|
|
|
|
glcpp=$abs_builddir/glsl/glcpp/glcpp
|
|
|
|
|
|
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:
|
|
|
|
|
|
glsl/glcpp: Add test script for testing various line-termination characters
The GLSL specification has a very broad definition of what is a
newline. Namely, it can be the carriage-return character, '\r', the newline
character, '\n', or any combination of the two, (though in combination, the
two are treated as a single newline).
Here, we add a new test-runner, glcpp-test-cr-lf, that, for each possible
line-termination combination, runs through the existing test suite with all
source files modified to use those line-termination characters. Instead of
using the .expected files for this, this script assumes that the regular test
suite has been run already and expects the output to match the .out
files. This avoids getting 4 test failures for any one bug, and instead will
hopefully only report bugs actually related to the line-termination
characters.
The new testing is not yet integrated into "make check". For that, some
munging of the testdir option will be necessary, (to support "make check" with
out-of-tree builds). For now, the scripts can just be run directly by hand.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2014-07-02 17:14:51 -07:00
|
|
|
--testdir=<DIR> Use tests in the given <DIR> (default is ".")
|
2011-04-14 14:55:52 -07:00
|
|
|
--valgrind Run the test suite a second time under valgrind
|
|
|
|
|
EOF
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-05 13:32:32 -08:00
|
|
|
test_specific_args ()
|
|
|
|
|
{
|
|
|
|
|
test="$1"
|
|
|
|
|
|
2014-07-02 22:58:57 -07:00
|
|
|
tr "\r" "\n" < "$test" | grep 'glcpp-args:' | sed -e 's,^.*glcpp-args: *,,'
|
2012-12-05 13:32:32 -08:00
|
|
|
}
|
|
|
|
|
|
2011-04-14 14:55:52 -07:00
|
|
|
# Parse command-line options
|
|
|
|
|
for option; do
|
glsl/glcpp: Add test script for testing various line-termination characters
The GLSL specification has a very broad definition of what is a
newline. Namely, it can be the carriage-return character, '\r', the newline
character, '\n', or any combination of the two, (though in combination, the
two are treated as a single newline).
Here, we add a new test-runner, glcpp-test-cr-lf, that, for each possible
line-termination combination, runs through the existing test suite with all
source files modified to use those line-termination characters. Instead of
using the .expected files for this, this script assumes that the regular test
suite has been run already and expects the output to match the .out
files. This avoids getting 4 test failures for any one bug, and instead will
hopefully only report bugs actually related to the line-termination
characters.
The new testing is not yet integrated into "make check". For that, some
munging of the testdir option will be necessary, (to support "make check" with
out-of-tree builds). For now, the scripts can just be run directly by hand.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2014-07-02 17:14:51 -07:00
|
|
|
case "${option}" in
|
|
|
|
|
"--help")
|
|
|
|
|
usage
|
|
|
|
|
exit 0
|
|
|
|
|
;;
|
|
|
|
|
"--valgrind")
|
|
|
|
|
do_valgrind=yes
|
|
|
|
|
;;
|
|
|
|
|
"--testdir="*)
|
|
|
|
|
testdir="${option#--testdir=}"
|
2014-12-07 23:43:00 -08:00
|
|
|
outdir="${outdir}/${option#--testdir=}"
|
glsl/glcpp: Add test script for testing various line-termination characters
The GLSL specification has a very broad definition of what is a
newline. Namely, it can be the carriage-return character, '\r', the newline
character, '\n', or any combination of the two, (though in combination, the
two are treated as a single newline).
Here, we add a new test-runner, glcpp-test-cr-lf, that, for each possible
line-termination combination, runs through the existing test suite with all
source files modified to use those line-termination characters. Instead of
using the .expected files for this, this script assumes that the regular test
suite has been run already and expects the output to match the .out
files. This avoids getting 4 test failures for any one bug, and instead will
hopefully only report bugs actually related to the line-termination
characters.
The new testing is not yet integrated into "make check". For that, some
munging of the testdir option will be necessary, (to support "make check" with
out-of-tree builds). For now, the scripts can just be run directly by hand.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2014-07-02 17:14:51 -07:00
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
echo "Unrecognized option: $option" >&2
|
|
|
|
|
echo >&2
|
|
|
|
|
usage
|
|
|
|
|
exit 1
|
|
|
|
|
;;
|
|
|
|
|
esac
|
2011-04-14 14:55:52 -07:00
|
|
|
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
|
|
|
|
2014-12-07 23:43:00 -08:00
|
|
|
mkdir -p $outdir
|
|
|
|
|
|
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
|
2014-12-07 23:43:00 -08:00
|
|
|
out=$outdir/${test##*/}.out
|
|
|
|
|
|
2017-02-28 12:08:52 +00:00
|
|
|
printf "Testing `basename $test`... "
|
2014-12-07 23:43:00 -08:00
|
|
|
$glcpp $(test_specific_args $test) < $test > $out 2>&1
|
2010-07-19 17:48:17 -07:00
|
|
|
total=$((total+1))
|
2014-12-07 23:43:00 -08:00
|
|
|
if cmp $test.expected $out >/dev/null 2>&1; then
|
2010-07-19 17:48:17 -07:00
|
|
|
echo "PASS"
|
|
|
|
|
pass=$((pass+1))
|
|
|
|
|
else
|
|
|
|
|
echo "FAIL"
|
2014-12-07 23:43:00 -08:00
|
|
|
diff -u $test.expected $out
|
2010-07-19 17:48:17 -07:00
|
|
|
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
|
2017-02-28 12:08:52 +00:00
|
|
|
printf "Testing `basename $test` with valgrind..."
|
2012-12-05 13:32:32 -08:00
|
|
|
valgrind --error-exitcode=31 --log-file=$test.valgrind-errors $glcpp $(test_specific_args $test) < $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
|
|
|
|
|
|