Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

test: fix up `make valgrind-test`

* valgrind complained too much about memory leaks from the V8 heap to be
  useful, run it with --leak-check=no. Not ideal, needs to be revisited,
  preferably with a suppression file.

* tools/run-valgrind.py didn't deal with tests that logged to stderr, rewrite
  the heuristic and make valgrind write to a socket instead of stderr.

Fixes #3869.
  • Loading branch information
bnoordhuis committed Aug 14, 2012
1 parent de32b38 commit 90ea68107a94b33e6b20cd9c2af8547b8c41da7c
Showing with 22 additions and 34 deletions.
  1. +22 −34 deps/v8/tools/run-valgrind.py
@@ -30,48 +30,36 @@
# 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',
'--error-exitcode=1',
'--leak-check=full',
'--smc-check=all'
VALGRIND,
'--log-socket=127.0.0.1:15151',
'--error-exitcode=247',
'--leak-check=no',
'--smc-check=all',
]

# Compute the command line.
command = VALGRIND_ARGUMENTS + sys.argv[1:]
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(('127.0.0.1', 15151))
server.listen(1)

# Run valgrind.
command = VALGRIND_ARGUMENTS + sys.argv[1:]
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)

# 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)
errors = ''
conn, addr = server.accept()
while True:
data = conn.recv(8192)
if not data: break
errors += data

# No leaks found.
sys.exit(0)
code = process.wait()
if code == 247: sys.stderr.writelines(errors)
sys.exit(code)

0 comments on commit 90ea681

Please sign in to comment.
You can’t perform that action at this time.