Mesa (master): glcpp: Add --valgrind option to the glcpp-test utility

Carl Worth cworth at kemper.freedesktop.org
Thu Apr 14 16:05:26 PDT 2011


Module: Mesa
Branch: master
Commit: 0b80f2d4c9fd672d75d647104bf0b0fdafec9dda
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0b80f2d4c9fd672d75d647104bf0b0fdafec9dda

Author: Carl Worth <cworth at cworth.org>
Date:   Thu Apr 14 14:55:52 2011 -0700

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.

---

 src/glsl/glcpp/tests/glcpp-test |   62 +++++++++++++++++++++++++++++----------
 1 files changed, 46 insertions(+), 16 deletions(-)

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



More information about the mesa-commit mailing list