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

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

Issue 45053: When running ui_tests, need to tell valgrind to also trace child processes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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
« chrome/test/ui/ui_test.cc ('K') | « tools/valgrind/chrome_tests.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 # purify_test.py 6 # purify_test.py
7 7
8 '''Runs an exe through Valgrind and puts the intermediate files in a 8 '''Runs an exe through Valgrind and puts the intermediate files in a
9 directory. 9 directory.
10 ''' 10 '''
11 11
12 import datetime 12 import datetime
13 import glob 13 import glob
14 import logging 14 import logging
15 import optparse 15 import optparse
16 import os 16 import os
17 import shutil 17 import shutil
18 import stat
18 import sys 19 import sys
20 import tempfile
19 21
20 import common 22 import common
21 23
22 import valgrind_analyze 24 import valgrind_analyze
23 25
24 import google.logging_utils 26 import google.logging_utils
25 27
26 rmtree = shutil.rmtree 28 rmtree = shutil.rmtree
27 29
28 class Valgrind(object): 30 class Valgrind(object):
(...skipping 22 matching lines...) Expand all
51 help="path to top of source tree for this build" 53 help="path to top of source tree for this build"
52 "(used to normalize source paths in baseline)") 54 "(used to normalize source paths in baseline)")
53 self._parser.add_option("", "--suppressions", default=["."], 55 self._parser.add_option("", "--suppressions", default=["."],
54 action="append", 56 action="append",
55 help="path to a valgrind suppression file") 57 help="path to a valgrind suppression file")
56 self._parser.add_option("", "--gtest_filter", default="", 58 self._parser.add_option("", "--gtest_filter", default="",
57 help="which test case to run") 59 help="which test case to run")
58 self._parser.add_option("", "--gtest_print_time", action="store_true", 60 self._parser.add_option("", "--gtest_print_time", action="store_true",
59 default=False, 61 default=False,
60 help="show how long each test takes") 62 help="show how long each test takes")
63 self._parser.add_option("", "--trace_children", action="store_true",
64 default=False,
65 help="also trace child processes")
66 self._parser.add_option("", "--indirect", action="store_true",
67 default=False,
68 help="set BROWSER_WRAPPER rather than running valgri nd directly")
Dean McNamee 2009/03/27 11:34:55 80 cols
61 self._parser.add_option("", "--show_all_leaks", action="store_true", 69 self._parser.add_option("", "--show_all_leaks", action="store_true",
62 default=False, 70 default=False,
63 help="also show less blatant leaks") 71 help="also show less blatant leaks")
64 self._parser.add_option("", "--generate_suppressions", action="store_true", 72 self._parser.add_option("", "--generate_suppressions", action="store_true",
65 default=False, 73 default=False,
66 help="Skip analysis and generate suppressions") 74 help="Skip analysis and generate suppressions")
67 self._parser.add_option("-v", "--verbose", action="store_true", default=Fals e, 75 self._parser.add_option("-v", "--verbose", action="store_true", default=Fals e,
68 help="verbose output - enable debug log messages") 76 help="verbose output - enable debug log messages")
69 self._parser.description = __doc__ 77 self._parser.description = __doc__
70 78
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 """Get the valgrind command to run.""" 178 """Get the valgrind command to run."""
171 # note that self._args begins with the exe to be run 179 # note that self._args begins with the exe to be run
172 # TODO(erg): We probably want to get a version of valgrind that supports 180 # TODO(erg): We probably want to get a version of valgrind that supports
173 # the "--track-origins" option... 181 # the "--track-origins" option...
174 proc = ["valgrind", "--smc-check=all", "--leak-check=full", 182 proc = ["valgrind", "--smc-check=all", "--leak-check=full",
175 "--num-callers=30"] 183 "--num-callers=30"]
176 184
177 if self._options.show_all_leaks: 185 if self._options.show_all_leaks:
178 proc += ["--show-reachable=yes"]; 186 proc += ["--show-reachable=yes"];
179 187
188 if self._options.trace_children:
189 proc += ["--trace-children=yes"];
190
180 # Either generate suppressions or load them. 191 # Either generate suppressions or load them.
181 if self._generate_suppressions: 192 if self._generate_suppressions:
182 proc += ["--gen-suppressions=all"] 193 proc += ["--gen-suppressions=all"]
183 else: 194 else:
184 proc += ["--xml=yes"] 195 proc += ["--xml=yes"]
185 196
186 suppression_count = 0 197 suppression_count = 0
187 for suppression_file in self._suppressions: 198 for suppression_file in self._suppressions:
188 if os.path.exists(suppression_file): 199 if os.path.exists(suppression_file):
189 suppression_count += 1 200 suppression_count += 1
190 proc += ["--suppressions=%s" % suppression_file] 201 proc += ["--suppressions=%s" % suppression_file]
191 202
192 if not suppression_count: 203 if not suppression_count:
193 logging.warning("WARNING: NOT USING SUPPRESSIONS!") 204 logging.warning("WARNING: NOT USING SUPPRESSIONS!")
194 205
195 proc += ["--log-file=" + self.TMP_DIR + "/valgrind.%p"] + self._args 206 proc += ["--log-file=" + self.TMP_DIR + "/valgrind.%p"]
207
208 if self._options.indirect:
209 # The program being run invokes Python or something else
210 # that can't stand to be valgrinded, and also invokes
211 # the Chrome browser. Set an environment variable to
212 # tell the program to prefix the Chrome commandline
213 # with a magic wrapper. Build the magic wrapper here.
214 (fd, indirect_fname) = tempfile.mkstemp(dir=self.TMP_DIR, prefix="browser_ wrapper.", text=True)
215 f = os.fdopen(fd, "w");
216 f.write("#!/bin/sh\n")
217 f.write(" ".join(proc))
218 f.write(' "$@"\n')
219 f.close()
220 os.chmod(indirect_fname, stat.S_IRUSR|stat.S_IXUSR)
221 os.putenv("BROWSER_WRAPPER", indirect_fname)
222 logging.info('export BROWSER_WRAPPER=' + indirect_fname);
223 proc = []
224
225 proc += self._args
196 return proc 226 return proc
197 227
198 228
199 class ValgrindMac(Valgrind): 229 class ValgrindMac(Valgrind):
200 230
201 """Valgrind on Mac OS X. 231 """Valgrind on Mac OS X.
202 232
203 Valgrind on OS X does not support suppressions (yet). 233 Valgrind on OS X does not support suppressions (yet).
204 """ 234 """
205 235
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 valgrind = ValgrindMac() 277 valgrind = ValgrindMac()
248 retcode = valgrind.Main() 278 retcode = valgrind.Main()
249 sys.exit(retcode) 279 sys.exit(retcode)
250 elif sys.platform == 'linux2': # Linux 280 elif sys.platform == 'linux2': # Linux
251 valgrind = ValgrindLinux() 281 valgrind = ValgrindLinux()
252 retcode = valgrind.Main() 282 retcode = valgrind.Main()
253 sys.exit(retcode) 283 sys.exit(retcode)
254 else: 284 else:
255 logging.error("Unknown platform: %s" % sys.platform) 285 logging.error("Unknown platform: %s" % sys.platform)
256 sys.exit(1) 286 sys.exit(1)
OLDNEW
« chrome/test/ui/ui_test.cc ('K') | « tools/valgrind/chrome_tests.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698