summaryrefslogtreecommitdiffstats
path: root/tools/valgrind/memcheck_analyze.py
diff options
context:
space:
mode:
authordank@chromium.org <dank@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-17 14:32:48 +0000
committerdank@chromium.org <dank@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-17 14:32:48 +0000
commit7d880a2c51d3d00701a36b3f94ed822026bd6b82 (patch)
tree55a584fe8de90b15c2fa618b900dc2f64be69014 /tools/valgrind/memcheck_analyze.py
parent5fa6dcb2fa87ee8bbc4300a224b2856ed00f0089 (diff)
downloadchromium_src-7d880a2c51d3d00701a36b3f94ed822026bd6b82.zip
chromium_src-7d880a2c51d3d00701a36b3f94ed822026bd6b82.tar.gz
chromium_src-7d880a2c51d3d00701a36b3f94ed822026bd6b82.tar.bz2
Temporary workaround for valgrind outputting garbage after </valgrindoutput>.
Will do more artful one later if this gets the mac ui bots to yield good partial results instead of dying 100% of the time as they do now. TBR=thestig TEST=mac valgrind ui bot 1 of 3 should produce some useful results BUG=none Review URL: http://codereview.chromium.org/171044 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23544 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/valgrind/memcheck_analyze.py')
-rwxr-xr-xtools/valgrind/memcheck_analyze.py30
1 files changed, 22 insertions, 8 deletions
diff --git a/tools/valgrind/memcheck_analyze.py b/tools/valgrind/memcheck_analyze.py
index b5e192e..6cbf22e 100755
--- a/tools/valgrind/memcheck_analyze.py
+++ b/tools/valgrind/memcheck_analyze.py
@@ -196,6 +196,17 @@ class ValgrindError:
def __eq__(self, rhs):
return self.UniqueString() == rhs
+def find_and_truncate(f):
+ f.seek(0)
+ while True:
+ line = f.readline()
+ if line == "":
+ return False
+ if '</valgrindoutput>' in line:
+ # valgrind often has garbage after </valgrindoutput> upon crash
+ f.truncate()
+ return True
+
class MemcheckAnalyze:
''' Given a set of Valgrind XML files, parse all the errors out of them,
unique them and output the results.'''
@@ -216,20 +227,23 @@ class MemcheckAnalyze:
for file in files:
# Wait up to three minutes for valgrind to finish writing all files,
# but after that, just skip incomplete files and warn.
- f = open(file, "r")
+ f = open(file, "r+")
found = False
firstrun = True
- while (firstrun or ((time.time() - start) < 180.0)):
+ origsize = os.path.getsize(file)
+ while (not found and (firstrun or ((time.time() - start) < 180.0))):
firstrun = False
f.seek(0)
- if sum((1 for line in f if '</valgrindoutput>' in line)) > 0:
- found = True
- break
- time.sleep(1)
+ found = find_and_truncate(f)
+ if not found:
+ time.sleep(1)
f.close()
if not found:
badfiles.add(file)
else:
+ newsize = os.path.getsize(file)
+ if origsize > newsize+1:
+ logging.warn(str(origsize - newsize) + " bytes of junk were after </valgrindoutput> in %s!" % file)
try:
raw_errors = parse(file).getElementsByTagName("error")
for raw_error in raw_errors:
@@ -259,8 +273,8 @@ class MemcheckAnalyze:
if len(badfiles) > 0:
logging.warn("valgrind didn't finish writing %d files?!" % len(badfiles))
for file in badfiles:
- logging.warn("Last 100 lines of %s :" % file)
- os.system("tail -n 100 '%s'" % file)
+ logging.warn("Last 20 lines of %s :" % file)
+ os.system("tail -n 20 '%s' 1>&2" % file)
def Report(self):
if self._parse_failed: