sparse-index: loose integration with cache_tree_verify()
[git] / t / valgrind / valgrind.sh
1 #!/bin/sh
2
3 base=$(basename "$0")
4 case "$base" in
5 test-*)
6         program="$GIT_VALGRIND/../../t/helper/$base"
7         ;;
8 *)
9         program="$GIT_VALGRIND/../../$base"
10         ;;
11 esac
12
13 TOOL_OPTIONS='--leak-check=no'
14
15 test -z "$GIT_VALGRIND_ENABLED" &&
16 exec "$program" "$@"
17
18 case "$GIT_VALGRIND_MODE" in
19 memcheck-fast)
20         ;;
21 memcheck)
22         VALGRIND_VERSION=$(valgrind --version)
23         VALGRIND_MAJOR=$(expr "$VALGRIND_VERSION" : '[^0-9]*\([0-9]*\)')
24         VALGRIND_MINOR=$(expr "$VALGRIND_VERSION" : '[^0-9]*[0-9]*\.\([0-9]*\)')
25         test 3 -gt "$VALGRIND_MAJOR" ||
26         test 3 -eq "$VALGRIND_MAJOR" -a 4 -gt "$VALGRIND_MINOR" ||
27         TOOL_OPTIONS="$TOOL_OPTIONS --track-origins=yes"
28         ;;
29 *)
30         TOOL_OPTIONS="--tool=$GIT_VALGRIND_MODE"
31 esac
32
33 exec valgrind -q --error-exitcode=126 \
34         --gen-suppressions=all \
35         --suppressions="$GIT_VALGRIND/default.supp" \
36         $TOOL_OPTIONS \
37         --log-fd=4 \
38         --input-fd=4 \
39         $GIT_VALGRIND_OPTIONS \
40         "$program" "$@"