tests: parameterize --valgrind option
Running tests under helgrind and DRD recently proved useful in tracking down thread interaction issues. This can unfortunately not be done through GIT_VALGRIND_OPTIONS because any tool other than memcheck would complain about unknown options. Let --valgrind take an optional parameter that describes the valgrind tool to invoke. The default mode is to run memcheck as before. Signed-off-by: Thomas Rast <trast@inf.ethz.ch> Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Thomas Rast committed
Mar 31, 2013 at 10:00 UTC
952af3511c5dc7b7efd4c374d8b56d2c11d09d07
3 files changed
+34
-16
t/README
+10
-5
@@ -92,16 +92,21 @@ appropriately before running "make".
92
This causes additional long-running tests to be run (where
93
available), for more exhaustive testing.
94
95
---valgrind::
96
- Execute all Git binaries with valgrind and exit with status
97
- 126 on errors (just like regular tests, this will only stop
98
- the test script when running under -i).
95
+--valgrind=<tool>::
96
+ Execute all Git binaries under valgrind tool <tool> and exit
97
+ with status 126 on errors (just like regular tests, this will
98
+ only stop the test script when running under -i).
99
100
Since it makes no sense to run the tests with --valgrind and
101
not see any output, this option implies --verbose. For
102
convenience, it also implies --tee.
103
104
- Note that valgrind is run with the option --leak-check=no,
104
+ <tool> defaults to 'memcheck', just like valgrind itself.
105
+ Other particularly useful choices include 'helgrind' and
106
+ 'drd', but you may use any tool recognized by your valgrind
107
+ installation.
108
+
109
+ Note that memcheck is run with the option --leak-check=no,
110
as the git process is short-lived and some errors are not
111
interesting. In order to run a single command under the same
112
conditions manually, you should set GIT_VALGRIND to point to
t/test-lib.sh
+9
-1
@@ -193,7 +193,11 @@ do
193
--no-color)
194
color=; shift ;;
195
--va|--val|--valg|--valgr|--valgri|--valgrin|--valgrind)
196
- valgrind=t; verbose=t; shift ;;
196
+ valgrind=memcheck
197
+ shift ;;
198
+ --valgrind=*)
199
+ valgrind=$(expr "z$1" : 'z[^=]*=\(.*\)')
200
+ shift ;;
201
--tee)
202
shift ;; # was handled already
203
--root=*)
@@ -204,6 +208,8 @@ do
208
esac
209
done
210
211
+test -n "$valgrind" && verbose=t
212
+
213
if test -n "$color"
214
then
215
say_color () {
@@ -530,6 +536,8 @@ then
536
PATH=$GIT_VALGRIND/bin:$PATH
537
GIT_EXEC_PATH=$GIT_VALGRIND/bin
538
export GIT_VALGRIND
539
+ GIT_VALGRIND_MODE="$valgrind"
540
+ export GIT_VALGRIND_MODE
541
elif test -n "$GIT_TEST_INSTALLED"
542
then
543
GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path) ||
t/valgrind/valgrind.sh
+15
-10
@@ -2,20 +2,25 @@
2
3
base=$(basename "$0")
4
5
-TRACK_ORIGINS=
5
+TOOL_OPTIONS='--leak-check=no'
6
7
-VALGRIND_VERSION=$(valgrind --version)
8
-VALGRIND_MAJOR=$(expr "$VALGRIND_VERSION" : '[^0-9]*\([0-9]*\)')
9
-VALGRIND_MINOR=$(expr "$VALGRIND_VERSION" : '[^0-9]*[0-9]*\.\([0-9]*\)')
10
-test 3 -gt "$VALGRIND_MAJOR" ||
11
-test 3 -eq "$VALGRIND_MAJOR" -a 4 -gt "$VALGRIND_MINOR" ||
12
-TRACK_ORIGINS=--track-origins=yes
7
+case "$GIT_VALGRIND_MODE" in
8
+memcheck)
9
+ VALGRIND_VERSION=$(valgrind --version)
10
+ VALGRIND_MAJOR=$(expr "$VALGRIND_VERSION" : '[^0-9]*\([0-9]*\)')
11
+ VALGRIND_MINOR=$(expr "$VALGRIND_VERSION" : '[^0-9]*[0-9]*\.\([0-9]*\)')
12
+ test 3 -gt "$VALGRIND_MAJOR" ||
13
+ test 3 -eq "$VALGRIND_MAJOR" -a 4 -gt "$VALGRIND_MINOR" ||
14
+ TOOL_OPTIONS="$TOOL_OPTIONS --track-origins=yes"
15
+ ;;
16
+*)
17
+ TOOL_OPTIONS="--tool=$GIT_VALGRIND_MODE"
18
+esac
19
20
exec valgrind -q --error-exitcode=126 \
15
- --leak-check=no \
16
- --suppressions="$GIT_VALGRIND/default.supp" \
21
--gen-suppressions=all \
18
- $TRACK_ORIGINS \
22
+ --suppressions="$GIT_VALGRIND/default.supp" \
23
+ $TOOL_OPTIONS \
24
--log-fd=4 \
25
--input-fd=4 \
26
$GIT_VALGRIND_OPTIONS \