Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Unified Diff: tools/run-valgrind.py

Issue 43073: Add support for running the tests through valgrind. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/run-valgrind.py
===================================================================
--- tools/run-valgrind.py (revision 0)
+++ tools/run-valgrind.py (revision 0)
@@ -0,0 +1,51 @@
+#!/usr/bin/python
Christian Plesner Hansen 2009/03/11 15:12:54 Copyright?
+
+# Simple wrapper for running valgrind and checking the output on
+# stderr for memory leaks.
+
+import subprocess
+import sys
+import re
+
+VALGRIND_ARGUMENTS = [
+ 'valgrind',
+ '--error-exitcode=1',
+ '--leak-check=full',
+ '--smc-check=all'
+]
+
+# Compute the command line.
+command = VALGRIND_ARGUMENTS + sys.argv[1:]
+
+# Run valgrind.
+process = subprocess.Popen(command, stderr=subprocess.PIPE)
+code = process.wait();
+errors = process.stderr.readlines();
+
+# If valgrind produced an error, we report that to the user.
+if code != 0:
+ sys.stderr.writelines(errors)
+ sys.exit(code)
+
+# Look through the leak details and make sure that we don't
+# have any definitely, indirectly, and possibly lost bytes.
+LEAK_LINE = re.compile(r"definitely lost: \d+ bytes in \d+ blocks.|"
+ "indirectly lost: \d+ bytes in \d+ blocks.|"
+ " possibly lost: \d+ bytes in \d+ blocks.")
Christian Plesner Hansen 2009/03/11 15:12:54 Any reason not to use r"(?:definitely|indirectly|p
+LEAK_OKAY = re.compile(r"lost: 0 bytes in 0 blocks.")
+leaks = []
+for line in errors:
Christian Plesner Hansen 2009/03/11 15:12:54 Simpler might be to use re.findall.
+ if LEAK_LINE.search(line):
+ leaks.append(line)
+ if not LEAK_OKAY.search(line):
+ sys.stderr.writelines(errors)
+ sys.exit(1)
+
+# Make sure we found between 2 and 3 leak lines.
+if len(leaks) < 2 or len(leaks) > 3:
+ sys.stderr.writelines(errors)
+ sys.stderr.write('\n\n#### Malformed valgrind output.\n#### Exiting.\n')
+ sys.exit(1)
+
+# No leaks found.
+sys.exit(0)
Property changes on: tools/run-valgrind.py
___________________________________________________________________
Name: svn:executable
+ *
« no previous file with comments | « no previous file | tools/test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698