aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/tools/run-valgrind.py
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/tools/run-valgrind.py')
-rwxr-xr-xdeps/v8/tools/run-valgrind.py56
1 files changed, 34 insertions, 22 deletions
diff --git a/deps/v8/tools/run-valgrind.py b/deps/v8/tools/run-valgrind.py
index f8c23da6d1..49c1b70312 100755
--- a/deps/v8/tools/run-valgrind.py
+++ b/deps/v8/tools/run-valgrind.py
@@ -30,36 +30,48 @@
# Simple wrapper for running valgrind and checking the output on
# stderr for memory leaks.
-import os
-import socket
import subprocess
import sys
import re
-VALGRIND = os.environ.get('VALGRIND', 'valgrind')
-
VALGRIND_ARGUMENTS = [
- VALGRIND,
- '--log-socket=127.0.0.1:15151',
- '--error-exitcode=247',
- '--leak-check=no',
- '--smc-check=all',
+ 'valgrind',
+ '--error-exitcode=1',
+ '--leak-check=full',
+ '--smc-check=all'
]
-server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-server.bind(('127.0.0.1', 15151))
-server.listen(1)
-
+# 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_RE = r"(?:definitely|indirectly|possibly) lost: "
+LEAK_LINE_MATCHER = re.compile(LEAK_RE)
+LEAK_OKAY_MATCHER = re.compile(r"lost: 0 bytes in 0 blocks")
+leaks = []
+for line in errors:
+ if LEAK_LINE_MATCHER.search(line):
+ leaks.append(line)
+ if not LEAK_OKAY_MATCHER.search(line):
+ sys.stderr.writelines(errors)
+ sys.exit(1)
-errors = ''
-conn, addr = server.accept()
-while True:
- data = conn.recv(8192)
- if not data: break
- errors += data
+# 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)
-code = process.wait()
-if code == 247: sys.stderr.writelines(errors)
-sys.exit(code)
+# No leaks found.
+sys.exit(0)