glcpp: Add --valgrind option to the glcpp-test utility

The common case for this test suite is to quickly test that everything
returns the correct results. In this case, the second run of the test
suite under valgrind was just annoying, (and the user would often
interrupt it).

Now, do what is wanted in the common case by default (just run the
test suite), and require a run with "glcpp-test --valgrind" in order
to test with valgrind.
This commit is contained in:
Carl Worth
2011-04-14 14:55:52 -07:00
parent 6affa4806a
commit 0b80f2d4c9

View File

@@ -2,6 +2,34 @@
trap 'rm $test.valgrind-errors; exit 1' INT QUIT trap 'rm $test.valgrind-errors; exit 1' INT QUIT
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
total=0 total=0
pass=0 pass=0
clean=0 clean=0
@@ -24,23 +52,25 @@ echo ""
echo "$pass/$total tests returned correct results" echo "$pass/$total tests returned correct results"
echo "" echo ""
echo "====== Testing for valgrind cleanliness ======" if [ "$do_valgrind" = "yes" ]; then
for test in *.c; do echo "====== Testing for valgrind cleanliness ======"
echo -n "Testing $test with valgrind..." for test in *.c; do
valgrind --error-exitcode=31 --log-file=$test.valgrind-errors ../glcpp < $test >/dev/null 2>&1 echo -n "Testing $test with valgrind..."
if [ "$?" = "31" ]; then valgrind --error-exitcode=31 --log-file=$test.valgrind-errors ../glcpp < $test >/dev/null 2>&1
echo "ERRORS" if [ "$?" = "31" ]; then
cat $test.valgrind-errors echo "ERRORS"
else cat $test.valgrind-errors
echo "CLEAN" else
clean=$((clean+1)) echo "CLEAN"
rm $test.valgrind-errors clean=$((clean+1))
fi rm $test.valgrind-errors
done fi
done
echo "" echo ""
echo "$pass/$total tests returned correct results" echo "$pass/$total tests returned correct results"
echo "$clean/$total tests are valgrind-clean" echo "$clean/$total tests are valgrind-clean"
fi
if [ "$pass" = "$total" ] && [ "$clean" = "$total" ]; then if [ "$pass" = "$total" ] && [ "$clean" = "$total" ]; then
exit 0 exit 0