]> git.notmuchmail.org Git - notmuch/commitdiff
test: Fix test suite so that --valgrind option works.
authorCarl Worth <cworth@cworth.org>
Mon, 20 Sep 2010 20:42:59 +0000 (13:42 -0700)
committerCarl Worth <cworth@cworth.org>
Mon, 20 Sep 2010 20:44:32 +0000 (13:44 -0700)
The output is ugly, and we need a better suppressions file, but this
is at least a start.

test/basic
test/test-lib.sh
test/valgrind/default.supp [new file with mode: 0644]
test/valgrind/valgrind.sh [new file with mode: 0755]

index 8e68ef8ac5fac8960725fc07aecdd26c0a324f63..88704a17c6e930f04757d49f7bb08b894314fef8 100755 (executable)
@@ -52,7 +52,7 @@ test_expect_code 2 'failure to clean up causes the test to fail' '
 # Ensure that all tests are being run
 test_begin_subtest 'Ensure that all available tests will be run by notmuch-test'
 tests_in_suite=$(grep TESTS= ../notmuch-test | sed -e "s/TESTS=\"\(.*\)\"/\1/" | tr " " "\n" | sort)
-available=$(ls -1 ../ | grep -v -E "^(aggregate-results.sh|Makefile|Makefile.local|notmuch-test|README|test-lib.sh|test-results|tmp.*)" | sort)
+available=$(ls -1 ../ | grep -v -E "^(aggregate-results.sh|Makefile|Makefile.local|notmuch-test|README|test-lib.sh|test-results|tmp.*|valgrind)" | sort)
 test_expect_equal "$tests_in_suite" "$available"
 
 ################################################################
index 152387051061f19a7e6670d70cfc0f2c01ea4256..42dfde1399b8d43a5baef038411c53d8b2a5e7ad 100644 (file)
@@ -740,7 +740,6 @@ find_notmuch_path ()
 # Test the binaries we have just built.  The tests are kept in
 # test/ subdirectory and are run in 'trash directory' subdirectory.
 TEST_DIRECTORY=$(pwd)
-# FIXME: Only the normal case bellow is updated to notmuch
 if test -n "$valgrind"
 then
        make_symlink () {
@@ -786,15 +785,12 @@ then
        # override all git executables in TEST_DIRECTORY/..
        GIT_VALGRIND=$TEST_DIRECTORY/valgrind
        mkdir -p "$GIT_VALGRIND"/bin
-       for file in $TEST_DIRECTORY/../git* $TEST_DIRECTORY/../test-*
-       do
-               make_valgrind_symlink $file
-       done
+       make_valgrind_symlink $TEST_DIRECTORY/../notmuch
        OLDIFS=$IFS
        IFS=:
        for path in $PATH
        do
-               ls "$path"/git-* 2> /dev/null |
+               ls "$path"/notmuch 2> /dev/null |
                while read file
                do
                        make_valgrind_symlink "$file"
@@ -804,11 +800,6 @@ then
        PATH=$GIT_VALGRIND/bin:$PATH
        GIT_EXEC_PATH=$GIT_VALGRIND/bin
        export GIT_VALGRIND
-elif test -n "$GIT_TEST_INSTALLED" ; then
-       GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path)  ||
-       error "Cannot run git from $GIT_TEST_INSTALLED."
-       PATH=$GIT_TEST_INSTALLED:$TEST_DIRECTORY/..:$PATH
-       GIT_EXEC_PATH=${GIT_TEST_EXEC_PATH:-$GIT_EXEC_PATH}
 else # normal case
        notmuch_path=`find_notmuch_path "$TEST_DIRECTORY"`
        test -n "$notmuch_path" && PATH="$notmuch_path:$PATH"
diff --git a/test/valgrind/default.supp b/test/valgrind/default.supp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/valgrind/valgrind.sh b/test/valgrind/valgrind.sh
new file mode 100755 (executable)
index 0000000..582b4dc
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+base=$(basename "$0")
+
+TRACK_ORIGINS=
+
+VALGRIND_VERSION=$(valgrind --version)
+VALGRIND_MAJOR=$(expr "$VALGRIND_VERSION" : '[^0-9]*\([0-9]*\)')
+VALGRIND_MINOR=$(expr "$VALGRIND_VERSION" : '[^0-9]*[0-9]*\.\([0-9]*\)')
+test 3 -gt "$VALGRIND_MAJOR" ||
+test 3 -eq "$VALGRIND_MAJOR" -a 4 -gt "$VALGRIND_MINOR" ||
+TRACK_ORIGINS=--track-origins=yes
+
+exec valgrind -q --error-exitcode=126 \
+       --leak-check=no \
+       --suppressions="$GIT_VALGRIND/default.supp" \
+       --gen-suppressions=all \
+       $TRACK_ORIGINS \
+       --log-fd=4 \
+       --input-fd=4 \
+       $GIT_VALGRIND_OPTIONS \
+       "$GIT_VALGRIND"/../../"$base" "$@"