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

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

Issue 3436022: Fix lost suppressions with --tool=tsan_rv. Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 10 years, 3 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
« no previous file with comments | « no previous file | tools/valgrind/valgrind_test.py » ('j') | 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 # chrome_tests.py 6 # chrome_tests.py
7 7
8 ''' Runs various chrome tests through valgrind_test.py.''' 8 ''' Runs various chrome tests through valgrind_test.py.'''
9 9
10 import glob 10 import glob
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 78
79 script_dir = path_utils.ScriptDir() 79 script_dir = path_utils.ScriptDir()
80 # Compute the top of the tree (the "source dir") from the script dir (where 80 # Compute the top of the tree (the "source dir") from the script dir (where
81 # this script lives). We assume that the script dir is in tools/valgrind/ 81 # this script lives). We assume that the script dir is in tools/valgrind/
82 # relative to the top of the tree. 82 # relative to the top of the tree.
83 self._source_dir = os.path.dirname(os.path.dirname(script_dir)) 83 self._source_dir = os.path.dirname(os.path.dirname(script_dir))
84 # since this path is used for string matching, make sure it's always 84 # since this path is used for string matching, make sure it's always
85 # an absolute Unix-style path 85 # an absolute Unix-style path
86 self._source_dir = os.path.abspath(self._source_dir).replace('\\', '/') 86 self._source_dir = os.path.abspath(self._source_dir).replace('\\', '/')
87 valgrind_test_script = os.path.join(script_dir, "valgrind_test.py") 87 valgrind_test_script = os.path.join(script_dir, "valgrind_test.py")
88 self._command_preamble = [valgrind_test_script, 88 self._command_preamble = ["--source_dir=%s" % (self._source_dir)]
89 "--source_dir=%s" % (self._source_dir)]
90 89
91 def _DefaultCommand(self, module, exe=None, valgrind_test_args=None): 90 def _DefaultCommand(self, tool, module, exe=None, valgrind_test_args=None):
92 '''Generates the default command array that most tests will use.''' 91 '''Generates the default command array that most tests will use.'''
93 module_dir = os.path.join(self._source_dir, module) 92 module_dir = os.path.join(self._source_dir, module)
94 93
95 # We need multiple data dirs, the current script directory and a module 94 # We need multiple data dirs, the current script directory and a module
96 # specific one. The global suppression file lives in our directory, and the 95 # specific one. The global suppression file lives in our directory, and the
97 # module specific suppression file lives with the module. 96 # module specific suppression file lives with the module.
98 self._data_dirs = [path_utils.ScriptDir()] 97 self._data_dirs = [path_utils.ScriptDir()]
99 98
100 if module == "chrome": 99 if module == "chrome":
101 # unfortunately, not all modules have the same directory structure 100 # unfortunately, not all modules have the same directory structure
(...skipping 12 matching lines...) Expand all
114 os.path.join(self._source_dir, "sconsbuild", "Debug"), 113 os.path.join(self._source_dir, "sconsbuild", "Debug"),
115 os.path.join(self._source_dir, "out", "Debug"), 114 os.path.join(self._source_dir, "out", "Debug"),
116 ] 115 ]
117 if exe: 116 if exe:
118 self._options.build_dir = FindDirContainingNewestFile(dirs, exe) 117 self._options.build_dir = FindDirContainingNewestFile(dirs, exe)
119 else: 118 else:
120 self._options.build_dir = FindNewestDir(dirs) 119 self._options.build_dir = FindNewestDir(dirs)
121 120
122 cmd = list(self._command_preamble) 121 cmd = list(self._command_preamble)
123 for directory in self._data_dirs: 122 for directory in self._data_dirs:
124 tool_name = self._options.valgrind_tool 123 tool_name = tool.ToolName();
125 suppression_file = os.path.join(directory, 124 suppression_file = os.path.join(directory,
126 "%s/suppressions.txt" % tool_name) 125 "%s/suppressions.txt" % tool_name)
127 if os.path.exists(suppression_file): 126 if os.path.exists(suppression_file):
128 cmd.append("--suppressions=%s" % suppression_file) 127 cmd.append("--suppressions=%s" % suppression_file)
129 # Platform specific suppression 128 # Platform specific suppression
130 for suppression_platform in common.PlatformNames(): 129 for suppression_platform in common.PlatformNames():
131 suppression_file_platform = \ 130 suppression_file_platform = \
132 os.path.join(directory, 131 os.path.join(directory,
133 '%s/suppressions_%s.txt' % (tool_name, suppression_platform)) 132 '%s/suppressions_%s.txt' % (tool_name, suppression_platform))
134 if os.path.exists(suppression_file_platform): 133 if os.path.exists(suppression_file_platform):
135 cmd.append("--suppressions=%s" % suppression_file_platform) 134 cmd.append("--suppressions=%s" % suppression_file_platform)
136 135
137 cmd.append("--tool=%s" % self._options.valgrind_tool)
138 if self._options.valgrind_tool_flags: 136 if self._options.valgrind_tool_flags:
139 cmd += self._options.valgrind_tool_flags.split(" ") 137 cmd += self._options.valgrind_tool_flags.split(" ")
140 if valgrind_test_args != None: 138 if valgrind_test_args != None:
141 for arg in valgrind_test_args: 139 for arg in valgrind_test_args:
142 cmd.append(arg) 140 cmd.append(arg)
143 if exe: 141 if exe:
144 if common.IsWine(): 142 if common.IsWine():
145 cmd.append(os.environ.get('WINE')) 143 cmd.append(os.environ.get('WINE'))
146 exe = exe + '.exe' 144 exe = exe + '.exe'
147 cmd.append(os.path.join(self._options.build_dir, exe)) 145 cmd.append(os.path.join(self._options.build_dir, exe))
148 # Valgrind runs tests slowly, so slow tests hurt more; show elapased time 146 # Valgrind runs tests slowly, so slow tests hurt more; show elapased time
149 # so we can find the slowpokes. 147 # so we can find the slowpokes.
150 cmd.append("--gtest_print_time") 148 cmd.append("--gtest_print_time")
151 if self._options.gtest_repeat: 149 if self._options.gtest_repeat:
152 cmd.append("--gtest_repeat=%s" % self._options.gtest_repeat) 150 cmd.append("--gtest_repeat=%s" % self._options.gtest_repeat)
153 return cmd 151 return cmd
154 152
155 def Run(self): 153 def Run(self):
156 ''' Runs the test specified by command-line argument --test ''' 154 ''' Runs the test specified by command-line argument --test '''
157 logging.info("running test %s" % (self._test)) 155 logging.info("running test %s" % (self._test))
158 return self._test_list[self._test](self) 156 return self._test_list[self._test](self)
159 157
160 def _ReadGtestFilterFile(self, name, cmd): 158 def _ReadGtestFilterFile(self, tool, name, cmd):
161 '''Read a file which is a list of tests to filter out with --gtest_filter 159 '''Read a file which is a list of tests to filter out with --gtest_filter
162 and append the command-line option to cmd. 160 and append the command-line option to cmd.
163 ''' 161 '''
164 filters = [] 162 filters = []
165 for directory in self._data_dirs: 163 for directory in self._data_dirs:
166 gtest_filter_files = [ 164 gtest_filter_files = [
167 os.path.join(directory, name + ".gtest.txt"), 165 os.path.join(directory, name + ".gtest.txt"),
168 os.path.join(directory, name + ".gtest-%s.txt" % \ 166 os.path.join(directory, name + ".gtest-%s.txt" % \
169 self._options.valgrind_tool)] 167 tool.ToolName())]
170 for platform_suffix in common.PlatformNames(): 168 for platform_suffix in common.PlatformNames():
171 gtest_filter_files += [ 169 gtest_filter_files += [
172 os.path.join(directory, name + ".gtest_%s.txt" % platform_suffix), 170 os.path.join(directory, name + ".gtest_%s.txt" % platform_suffix),
173 os.path.join(directory, name + ".gtest-%s_%s.txt" % \ 171 os.path.join(directory, name + ".gtest-%s_%s.txt" % \
174 (self._options.valgrind_tool, platform_suffix))] 172 (tool.ToolName(), platform_suffix))]
175 for filename in gtest_filter_files: 173 for filename in gtest_filter_files:
176 if os.path.exists(filename): 174 if os.path.exists(filename):
177 logging.info("reading gtest filters from %s" % filename) 175 logging.info("reading gtest filters from %s" % filename)
178 f = open(filename, 'r') 176 f = open(filename, 'r')
179 for line in f.readlines(): 177 for line in f.readlines():
180 if line.startswith("#") or line.startswith("//") or line.isspace(): 178 if line.startswith("#") or line.startswith("//") or line.isspace():
181 continue 179 continue
182 line = line.rstrip() 180 line = line.rstrip()
183 test_prefixes = ["FLAKY", "FAILS"] 181 test_prefixes = ["FLAKY", "FAILS"]
184 for p in test_prefixes: 182 for p in test_prefixes:
(...skipping 13 matching lines...) Expand all
198 gtest_filter += ":" 196 gtest_filter += ":"
199 if gtest_filter.find("-") < 0: 197 if gtest_filter.find("-") < 0:
200 gtest_filter += "-" 198 gtest_filter += "-"
201 else: 199 else:
202 gtest_filter = "-" 200 gtest_filter = "-"
203 gtest_filter += ":".join(filters) 201 gtest_filter += ":".join(filters)
204 if gtest_filter: 202 if gtest_filter:
205 cmd.append("--gtest_filter=%s" % gtest_filter) 203 cmd.append("--gtest_filter=%s" % gtest_filter)
206 204
207 def SimpleTest(self, module, name, valgrind_test_args=None, cmd_args=None): 205 def SimpleTest(self, module, name, valgrind_test_args=None, cmd_args=None):
208 cmd = self._DefaultCommand(module, name, valgrind_test_args) 206 tool = valgrind_test.CreateTool(self._options.valgrind_tool)
209 self._ReadGtestFilterFile(name, cmd) 207 cmd = self._DefaultCommand(tool, module, name, valgrind_test_args)
208 self._ReadGtestFilterFile(tool, name, cmd)
210 if cmd_args: 209 if cmd_args:
211 cmd.extend(["--"]) 210 cmd.extend(["--"])
212 cmd.extend(cmd_args) 211 cmd.extend(cmd_args)
213 212
214 # Sets LD_LIBRARY_PATH to the build folder so external libraries can be 213 # Sets LD_LIBRARY_PATH to the build folder so external libraries can be
215 # loaded. 214 # loaded.
216 if (os.getenv("LD_LIBRARY_PATH")): 215 if (os.getenv("LD_LIBRARY_PATH")):
217 os.putenv("LD_LIBRARY_PATH", "%s:%s" % (os.getenv("LD_LIBRARY_PATH"), 216 os.putenv("LD_LIBRARY_PATH", "%s:%s" % (os.getenv("LD_LIBRARY_PATH"),
218 self._options.build_dir)) 217 self._options.build_dir))
219 else: 218 else:
220 os.putenv("LD_LIBRARY_PATH", self._options.build_dir) 219 os.putenv("LD_LIBRARY_PATH", self._options.build_dir)
221 return valgrind_test.RunTool(cmd, module) 220 return tool.Run(cmd, module)
222 221
223 def TestBase(self): 222 def TestBase(self):
224 return self.SimpleTest("base", "base_unittests") 223 return self.SimpleTest("base", "base_unittests")
225 224
226 def TestBrowser(self): 225 def TestBrowser(self):
227 return self.SimpleTest("chrome", "browser_tests") 226 return self.SimpleTest("chrome", "browser_tests")
228 227
229 def TestGURL(self): 228 def TestGURL(self):
230 return self.SimpleTest("chrome", "googleurl_unittests") 229 return self.SimpleTest("chrome", "googleurl_unittests")
231 230
232 def TestCourgette(self): 231 def TestCourgette(self):
233 return self.SimpleTest("courgette", "courgette_unittests") 232 return self.SimpleTest("courgette", "courgette_unittests")
234 233
235 def TestMedia(self): 234 def TestMedia(self):
236 return self.SimpleTest("chrome", "media_unittests") 235 return self.SimpleTest("chrome", "media_unittests")
237 236
238 def TestNotifier(self): 237 def TestNotifier(self):
239 return self.SimpleTest("chrome", "notifier_unit_tests") 238 return self.SimpleTest("chrome", "notifier_unit_tests")
240 239
241 def TestPrinting(self): 240 def TestPrinting(self):
242 return self.SimpleTest("chrome", "printing_unittests") 241 return self.SimpleTest("chrome", "printing_unittests")
243 242
244 def TestRemoting(self): 243 def TestRemoting(self):
245 return self.SimpleTest("chrome", "remoting_unittests") 244 return self.SimpleTest("chrome", "remoting_unittests")
246 245
247 def TestIpc(self): 246 def TestIpc(self):
248 return self.SimpleTest("ipc", "ipc_tests", 247 return self.SimpleTest("ipc", "ipc_tests",
249 valgrind_test_args=["--trace_children"]) 248 valgrind_test_args=["--trace_children"])
250 249
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 # list of tests. Wrap around to beginning of list at end. 290 # list of tests. Wrap around to beginning of list at end.
292 # If chunk_size is zero, run all tests in the list once. 291 # If chunk_size is zero, run all tests in the list once.
293 # If a text file is given as argument, it is used as the list of tests. 292 # If a text file is given as argument, it is used as the list of tests.
294 # 293 #
295 # Build the ginormous commandline in 'cmd'. 294 # Build the ginormous commandline in 'cmd'.
296 # It's going to be roughly 295 # It's going to be roughly
297 # python valgrind_test.py ... python run_webkit_tests.py ... 296 # python valgrind_test.py ... python run_webkit_tests.py ...
298 # but we'll use the --indirect flag to valgrind_test.py 297 # but we'll use the --indirect flag to valgrind_test.py
299 # to avoid valgrinding python. 298 # to avoid valgrinding python.
300 # Start by building the valgrind_test.py commandline. 299 # Start by building the valgrind_test.py commandline.
301 cmd = self._DefaultCommand("webkit") 300 tool = valgrind_test.CreateTool(self._options.valgrind_tool)
301 cmd = self._DefaultCommand(tool, "webkit")
302 cmd.append("--trace_children") 302 cmd.append("--trace_children")
303 cmd.append("--indirect") 303 cmd.append("--indirect")
304 cmd.append("--ignore_exit_code") 304 cmd.append("--ignore_exit_code")
305 # Now build script_cmd, the run_webkits_tests.py commandline 305 # Now build script_cmd, the run_webkits_tests.py commandline
306 # Store each chunk in its own directory so that we can find the data later 306 # Store each chunk in its own directory so that we can find the data later
307 chunk_dir = os.path.join("layout", "chunk_%05d" % chunk_num) 307 chunk_dir = os.path.join("layout", "chunk_%05d" % chunk_num)
308 test_shell = os.path.join(self._options.build_dir, "test_shell") 308 test_shell = os.path.join(self._options.build_dir, "test_shell")
309 out_dir = os.path.join(path_utils.ScriptDir(), "latest") 309 out_dir = os.path.join(path_utils.ScriptDir(), "latest")
310 out_dir = os.path.join(out_dir, chunk_dir) 310 out_dir = os.path.join(out_dir, chunk_dir)
311 if os.path.exists(out_dir): 311 if os.path.exists(out_dir):
(...skipping 15 matching lines...) Expand all
327 if self._options.build_dir.endswith("Debug"): 327 if self._options.build_dir.endswith("Debug"):
328 script_cmd.append("--debug"); 328 script_cmd.append("--debug");
329 if (chunk_size > 0): 329 if (chunk_size > 0):
330 script_cmd.append("--run-chunk=%d:%d" % (chunk_num, chunk_size)) 330 script_cmd.append("--run-chunk=%d:%d" % (chunk_num, chunk_size))
331 if len(self._args): 331 if len(self._args):
332 # if the arg is a txt file, then treat it as a list of tests 332 # if the arg is a txt file, then treat it as a list of tests
333 if os.path.isfile(self._args[0]) and self._args[0][-4:] == ".txt": 333 if os.path.isfile(self._args[0]) and self._args[0][-4:] == ".txt":
334 script_cmd.append("--test-list=%s" % self._args[0]) 334 script_cmd.append("--test-list=%s" % self._args[0])
335 else: 335 else:
336 script_cmd.extend(self._args) 336 script_cmd.extend(self._args)
337 self._ReadGtestFilterFile("layout", script_cmd) 337 self._ReadGtestFilterFile(tool, "layout", script_cmd)
338 # Now run script_cmd with the wrapper in cmd 338 # Now run script_cmd with the wrapper in cmd
339 cmd.extend(["--"]) 339 cmd.extend(["--"])
340 cmd.extend(script_cmd) 340 cmd.extend(script_cmd)
341 return valgrind_test.RunTool(cmd, "layout") 341 return tool.Run(cmd, "layout")
342 342
343 def TestLayout(self): 343 def TestLayout(self):
344 # A "chunk file" is maintained in the local directory so that each test 344 # A "chunk file" is maintained in the local directory so that each test
345 # runs a slice of the layout tests of size chunk_size that increments with 345 # runs a slice of the layout tests of size chunk_size that increments with
346 # each run. Since tests can be added and removed from the layout tests at 346 # each run. Since tests can be added and removed from the layout tests at
347 # any time, this is not going to give exact coverage, but it will allow us 347 # any time, this is not going to give exact coverage, but it will allow us
348 # to continuously run small slices of the layout tests under valgrind rather 348 # to continuously run small slices of the layout tests under valgrind rather
349 # than having to run all of them in one shot. 349 # than having to run all of them in one shot.
350 chunk_size = self._options.num_tests 350 chunk_size = self._options.num_tests
351 if (chunk_size == 0): 351 if (chunk_size == 0):
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 for t in options.test: 452 for t in options.test:
453 tests = ChromeTests(options, args, t) 453 tests = ChromeTests(options, args, t)
454 ret = tests.Run() 454 ret = tests.Run()
455 if ret: return ret 455 if ret: return ret
456 return 0 456 return 0
457 457
458 458
459 if __name__ == "__main__": 459 if __name__ == "__main__":
460 ret = _main(sys.argv) 460 ret = _main(sys.argv)
461 sys.exit(ret) 461 sys.exit(ret)
OLDNEW
« no previous file with comments | « no previous file | tools/valgrind/valgrind_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698