test: Fix test suite so that --valgrind option works.

The output is ugly, and we need a better suppressions file, but this
is at least a start.
This commit is contained in:
Carl Worth 2010-09-20 13:42:59 -07:00
parent 265de5006f
commit 60c599036e
4 changed files with 25 additions and 12 deletions

View file

@ -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"
################################################################

View 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"

View file

22
test/valgrind/valgrind.sh Executable file
View file

@ -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" "$@"