From 7d880a2c51d3d00701a36b3f94ed822026bd6b82 Mon Sep 17 00:00:00 2001 From: "dank@chromium.org" Date: Mon, 17 Aug 2009 14:32:48 +0000 Subject: Temporary workaround for valgrind outputting garbage after . 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 --- tools/valgrind/memcheck_analyze.py | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'tools') 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 '' in line: + # valgrind often has garbage after 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 '' 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 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: -- cgit v1.1