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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Name: svn:executable
+ *
OLDNEW
(Empty)
1 #!/usr/bin/python
Christian Plesner Hansen 2009/03/11 15:12:54 Copyright?
2
3 # Simple wrapper for running valgrind and checking the output on
4 # stderr for memory leaks.
5
6 import subprocess
7 import sys
8 import re
9
10 VALGRIND_ARGUMENTS = [
11 'valgrind',
12 '--error-exitcode=1',
13 '--leak-check=full',
14 '--smc-check=all'
15 ]
16
17 # Compute the command line.
18 command = VALGRIND_ARGUMENTS + sys.argv[1:]
19
20 # Run valgrind.
21 process = subprocess.Popen(command, stderr=subprocess.PIPE)
22 code = process.wait();
23 errors = process.stderr.readlines();
24
25 # If valgrind produced an error, we report that to the user.
26 if code != 0:
27 sys.stderr.writelines(errors)
28 sys.exit(code)
29
30 # Look through the leak details and make sure that we don't
31 # have any definitely, indirectly, and possibly lost bytes.
32 LEAK_LINE = re.compile(r"definitely lost: \d+ bytes in \d+ blocks.|"
33 "indirectly lost: \d+ bytes in \d+ blocks.|"
34 " 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
35 LEAK_OKAY = re.compile(r"lost: 0 bytes in 0 blocks.")
36 leaks = []
37 for line in errors:
Christian Plesner Hansen 2009/03/11 15:12:54 Simpler might be to use re.findall.
38 if LEAK_LINE.search(line):
39 leaks.append(line)
40 if not LEAK_OKAY.search(line):
41 sys.stderr.writelines(errors)
42 sys.exit(1)
43
44 # Make sure we found between 2 and 3 leak lines.
45 if len(leaks) < 2 or len(leaks) > 3:
46 sys.stderr.writelines(errors)
47 sys.stderr.write('\n\n#### Malformed valgrind output.\n#### Exiting.\n')
48 sys.exit(1)
49
50 # No leaks found.
51 sys.exit(0)
OLDNEW
« 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