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

Side by Side Diff: tools/valgrind/valgrind_analyze.py

Issue 55034: Support valgrinding layout tests. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # valgrind_analyze.py 6 # valgrind_analyze.py
7 7
8 ''' Given a valgrind XML file, parses errors and uniques them.''' 8 ''' Given a valgrind XML file, parses errors and uniques them.'''
9 9
10 import logging 10 import logging
11 import optparse 11 import optparse
12 import os 12 import os
13 import sys 13 import sys
14 import time
14 from xml.dom.minidom import parse 15 from xml.dom.minidom import parse
15 16
16 # These are functions (using C++ mangled names) that we look for in stack 17 # These are functions (using C++ mangled names) that we look for in stack
17 # traces. We don't show stack frames while pretty printing when they are below 18 # traces. We don't show stack frames while pretty printing when they are below
18 # any of the following: 19 # any of the following:
19 _TOP_OF_STACK_POINTS = [ 20 _TOP_OF_STACK_POINTS = [
20 # Don't show our testing framework. 21 # Don't show our testing framework.
21 "testing::Test::Run()", 22 "testing::Test::Run()",
22 # Also don't show the internals of libc/pthread. 23 # Also don't show the internals of libc/pthread.
23 "start_thread" 24 "start_thread"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 '''Reads in a set of files. 183 '''Reads in a set of files.
183 184
184 Args: 185 Args:
185 source_dir: Path to top of source tree for this build 186 source_dir: Path to top of source tree for this build
186 files: A list of filenames. 187 files: A list of filenames.
187 show_all_leaks: whether to show even less important leaks 188 show_all_leaks: whether to show even less important leaks
188 ''' 189 '''
189 190
190 self._errors = set() 191 self._errors = set()
191 for file in files: 192 for file in files:
193 # Wait up to a minute for valgrind to finish writing.
194 f = open(file, "r")
195 ntries = 60
196 for tries in range(0, ntries):
197 f.seek(0)
198 if sum((1 for line in f if '</valgrindoutput>' in line)) > 0:
199 break
200 time.sleep(1)
201 f.close()
202 if tries == ntries-1:
Erik does not do reviews 2009/03/30 16:22:48 space around operator
203 logging.error("valgrind never finished?")
192 raw_errors = parse(file).getElementsByTagName("error") 204 raw_errors = parse(file).getElementsByTagName("error")
193 for raw_error in raw_errors: 205 for raw_error in raw_errors:
194 # Ignore "possible" leaks for now by default. 206 # Ignore "possible" leaks for now by default.
195 if (show_all_leaks or getTextOf(raw_error, "kind") != "Leak_PossiblyLost "): 207 if (show_all_leaks or
208 getTextOf(raw_error, "kind") != "Leak_PossiblyLost"):
196 self._errors.add(ValgrindError(source_dir, raw_error)) 209 self._errors.add(ValgrindError(source_dir, raw_error))
197 210
198 def Report(self): 211 def Report(self):
199 if self._errors: 212 if self._errors:
200 logging.error("FAIL! There were %s errors: " % len(self._errors)) 213 logging.error("FAIL! There were %s errors: " % len(self._errors))
201 214
202 for error in self._errors: 215 for error in self._errors:
203 logging.error(error) 216 logging.error(error)
204 217
205 return -1 218 return -1
(...skipping 14 matching lines...) Expand all
220 parser.error("no filename specified") 233 parser.error("no filename specified")
221 filenames = args 234 filenames = args
222 235
223 analyzer = ValgrindAnalyze(options.source_dir, filenames) 236 analyzer = ValgrindAnalyze(options.source_dir, filenames)
224 retcode = analyzer.Report() 237 retcode = analyzer.Report()
225 238
226 sys.exit(retcode) 239 sys.exit(retcode)
227 240
228 if __name__ == "__main__": 241 if __name__ == "__main__":
229 _main() 242 _main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698