All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] wrap-for-bin.sh: facilitate running Git executables under valgrind
@ 2018-05-09 13:28 Antonio Ospite
  2018-05-09 14:49 ` Jeff King
  2018-05-09 15:25 ` Elijah Newren
  0 siblings, 2 replies; 4+ messages in thread
From: Antonio Ospite @ 2018-05-09 13:28 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Antonio Ospite

Testing locally built git executables under valgrind is not immediate.

Something like the following does not work:

  $ valgrind ./bin-wrappers/git

because the wrapper script forks and execs the command and valgrind does
not track children processes by default.

Something like the following may work:

  $ valgrind --trace-children=yes ./bin-wrappers/git

However it's counterintuitive and not ideal anyways because valgrind is
supposed to be called on the actual executable, not on wrapper scripts.

So, following the idea from commit 6a94088cc ("test: facilitate
debugging Git executables in tests with gdb", 2015-10-30) provide
a mechanism in the wrapper script to call valgrind directly on the
actual executable.

This mechanism could even be used by the test infrastructure in the
future, but it is already useful by its own on the command line:

  $ GIT_TEST_VALGRIND=1 \
    GIT_VALGRIND_OPTIONS="--leak-check=full" \
    ./bin-wrappers/git

Signed-off-by: Antonio Ospite <ao2@ao2.it>
---
 wrap-for-bin.sh | 4 ++++
 1 file changed, 4 insertions(+)
 mode change 100644 => 100755 wrap-for-bin.sh

diff --git a/wrap-for-bin.sh b/wrap-for-bin.sh
old mode 100644
new mode 100755
index 584240881..502d567bd
--- a/wrap-for-bin.sh
+++ b/wrap-for-bin.sh
@@ -24,6 +24,10 @@ if test -n "$GIT_TEST_GDB"
 then
 	unset GIT_TEST_GDB
 	exec gdb --args "${GIT_EXEC_PATH}/@@PROG@@" "$@"
+elif test -n "$GIT_TEST_VALGRIND"
+then
+	unset GIT_TEST_VALGRIND
+	exec valgrind $GIT_VALGRIND_OPTIONS "${GIT_EXEC_PATH}/@@PROG@@" "$@"
 else
 	exec "${GIT_EXEC_PATH}/@@PROG@@" "$@"
 fi
-- 
2.17.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-05-09 15:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-09 13:28 [PATCH] wrap-for-bin.sh: facilitate running Git executables under valgrind Antonio Ospite
2018-05-09 14:49 ` Jeff King
2018-05-09 15:25 ` Elijah Newren
2018-05-09 15:56   ` Antonio Ospite

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.