git/list[1] front-page[2] threads[3] people[4] search[5] about
 

valgrind test script integration

From
Jeff King <peff@peff.net>
Date
Jan 12, 2008, 11:10 UTC
Message-ID
<20080112111044.GA24257@coredump.intra.peff.net>
In-Reply-To
<20080112090432.GA6134@coredump.intra.peff.net>
On Sat, Jan 12, 2008 at 04:04:32AM -0500, Jeff King wrote:
> I couldn't reproduce this just running the test, but running it under
> valgrind showed a memory access error. Fix is below.

BTW, this could have been caught automagically if we had valgrind integration in the test scripts. Below is a rudimentary patch to do so. I'm not that familiar with valgrind, so input from those more knowledgeable is appreciated, and maybe we can get something official post-1.5.4.

You can use it like "./t7300-clean.sh -m"; each call to 'git' is run through valgrind, and returns an error if the original program had an error, or if valgrind turned up any errors.

It of course runs horribly slowly. I've just kicked off a
  make GIT_TEST_OPTS='-i -m'
now. A few caveats:
 - It barfs on _any_ valgrind error. On my Debian unstable system,
   anything that touches nss ends up with an error deep in the dlopen
   code.  Therefore to make this useful, I had to put
     {
       dl hack
       Memcheck:Addr4
       obj:/lib/ld-2.7.so
     }
   into /usr/lib/valgrind/default.supp
   We should maybe have a 'git.supp' error suppression file, but in this
   case, the error really seems to be platform-specific.
 - We only catch calls to 'git', not 'git-foo' (and in fact for that
   reason this doesn't catch the t7300 bug by itself, since that uses
   git-clean). A follow-on patch will deal with this.
---
 t/test-lib.sh |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 90b6844..415e918 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -84,6 +84,8 @@ do
 	--no-python)
 		# noop now...
 		shift ;;
+	-m|--m|--me|--mem|--memc|--memch|--memche|--memchec|--memcheck)
+		alias git='memcheck git'; shift ;;
 	*)
 		break ;;
 	esac
@@ -120,6 +122,12 @@ say () {
 	say_color info "$*"
 }
 
+memcheck() {
+	valgrind -q --error-exitcode=1 --leak-check=no "$@" && return 0
+	echo >&2 valgrind failure: "$@"
+	return 1
+}
+
 test "${test_description}" != "" ||
 error "Test script did not set test_description."
 
-- 
1.5.4.rc3.1.g027628-dirty
Previous: Jeff KingNext: Jeff King
Message 8 of 29 in “[ANNOUNCE] GIT 1.5.4-rc3”
  1. Junio C HamanoJan 12, 2008
  2. Ismail DönmezJan 12, 2008
  3. Junio C HamanoJan 12, 2008
  4. Ismail DönmezJan 12, 2008
  5. Junio C HamanoJan 12, 2008
  6. Jeff KingJan 12, 2008
  7. Jeff KingJan 12, 2008
  8. valgrind test script integrationJeff King, Jan 12, 2008
  9. Jeff KingJan 12, 2008
  10. Johannes SchindelinJan 12, 2008
  11. Jeff KingJan 12, 2008
  12. René ScharfeJan 12, 2008
  13. Ismail DönmezJan 12, 2008
  14. Johannes SchindelinJan 12, 2008
  15. Jeff KingJan 12, 2008
  16. Junio C HamanoJan 12, 2008
  17. Roger C. SoaresJan 12, 2008
  18. Junio C HamanoJan 12, 2008
  19. [ANNOUNCE] GIT 1.5.4-rc4Junio C Hamano, Jan 21, 2008
  20. [ANNOUNCE] GIT 1.5.4-rc5Junio C Hamano, Jan 28, 2008
  21. Jeff KingJan 28, 2008
  22. Gustaf HendebyJan 29, 2008
  23. Junio C HamanoJan 29, 2008
  24. Jeff KingJan 29, 2008
  25. Steffen ProhaskaJan 29, 2008
  26. Steffen ProhaskaJan 13, 2008
  27. Steffen ProhaskaJan 21, 2008
  28. Johannes SchindelinJan 22, 2008
  29. Steffen ProhaskaJan 22, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.