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

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

Issue 1736026: Change PYTHONPATH handling in tools/valgrind so we can un-revert http://coder... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 7 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 | « tools/valgrind/chrome_tests.bat ('k') | tools/valgrind/chrome_tests.sh » ('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
11 import logging 11 import logging
12 import optparse 12 import optparse
13 import os 13 import os
14 import stat 14 import stat
15 import sys 15 import sys
16 16
17 import google.logging_utils 17 import logging_utils
18 import google.path_utils 18 import path_utils
19 19
20 import common 20 import common
21 import valgrind_test 21 import valgrind_test
22 22
23 class TestNotFound(Exception): pass 23 class TestNotFound(Exception): pass
24 24
25 def Dir2IsNewer(dir1, dir2): 25 def Dir2IsNewer(dir1, dir2):
26 if dir2 == None or not os.path.isdir(dir2): 26 if dir2 == None or not os.path.isdir(dir2):
27 return False 27 return False
28 if dir1 == None or not os.path.isdir(dir1): 28 if dir1 == None or not os.path.isdir(dir1):
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 "app": self.TestApp, "app_unittests": self.TestApp, 77 "app": self.TestApp, "app_unittests": self.TestApp,
78 } 78 }
79 79
80 if test not in self._test_list: 80 if test not in self._test_list:
81 raise TestNotFound("Unknown test: %s" % test) 81 raise TestNotFound("Unknown test: %s" % test)
82 82
83 self._options = options 83 self._options = options
84 self._args = args 84 self._args = args
85 self._test = test 85 self._test = test
86 86
87 script_dir = google.path_utils.ScriptDir() 87 script_dir = path_utils.ScriptDir()
88 # Compute the top of the tree (the "source dir") from the script dir (where 88 # Compute the top of the tree (the "source dir") from the script dir (where
89 # this script lives). We assume that the script dir is in tools/valgrind/ 89 # this script lives). We assume that the script dir is in tools/valgrind/
90 # relative to the top of the tree. 90 # relative to the top of the tree.
91 self._source_dir = os.path.dirname(os.path.dirname(script_dir)) 91 self._source_dir = os.path.dirname(os.path.dirname(script_dir))
92 # since this path is used for string matching, make sure it's always 92 # since this path is used for string matching, make sure it's always
93 # an absolute Unix-style path 93 # an absolute Unix-style path
94 self._source_dir = os.path.abspath(self._source_dir).replace('\\', '/') 94 self._source_dir = os.path.abspath(self._source_dir).replace('\\', '/')
95 valgrind_test_script = os.path.join(script_dir, "valgrind_test.py") 95 valgrind_test_script = os.path.join(script_dir, "valgrind_test.py")
96 self._command_preamble = [valgrind_test_script, 96 self._command_preamble = [valgrind_test_script,
97 "--source_dir=%s" % (self._source_dir)] 97 "--source_dir=%s" % (self._source_dir)]
98 98
99 def _DefaultCommand(self, module, exe=None, valgrind_test_args=None): 99 def _DefaultCommand(self, module, exe=None, valgrind_test_args=None):
100 '''Generates the default command array that most tests will use.''' 100 '''Generates the default command array that most tests will use.'''
101 module_dir = os.path.join(self._source_dir, module) 101 module_dir = os.path.join(self._source_dir, module)
102 102
103 # We need multiple data dirs, the current script directory and a module 103 # We need multiple data dirs, the current script directory and a module
104 # specific one. The global suppression file lives in our directory, and the 104 # specific one. The global suppression file lives in our directory, and the
105 # module specific suppression file lives with the module. 105 # module specific suppression file lives with the module.
106 self._data_dirs = [google.path_utils.ScriptDir()] 106 self._data_dirs = [path_utils.ScriptDir()]
107 107
108 if module == "chrome": 108 if module == "chrome":
109 # unfortunately, not all modules have the same directory structure 109 # unfortunately, not all modules have the same directory structure
110 self._data_dirs.append(os.path.join(module_dir, "test", "data", 110 self._data_dirs.append(os.path.join(module_dir, "test", "data",
111 "valgrind")) 111 "valgrind"))
112 else: 112 else:
113 self._data_dirs.append(os.path.join(module_dir, "data", "valgrind")) 113 self._data_dirs.append(os.path.join(module_dir, "data", "valgrind"))
114 114
115 if not self._options.build_dir: 115 if not self._options.build_dir:
116 if common.IsWine(): 116 if common.IsWine():
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 # to avoid valgrinding python. 287 # to avoid valgrinding python.
288 # Start by building the valgrind_test.py commandline. 288 # Start by building the valgrind_test.py commandline.
289 cmd = self._DefaultCommand("webkit") 289 cmd = self._DefaultCommand("webkit")
290 cmd.append("--trace_children") 290 cmd.append("--trace_children")
291 cmd.append("--indirect") 291 cmd.append("--indirect")
292 cmd.append("--ignore_exit_code") 292 cmd.append("--ignore_exit_code")
293 # Now build script_cmd, the run_webkits_tests.py commandline 293 # Now build script_cmd, the run_webkits_tests.py commandline
294 # Store each chunk in its own directory so that we can find the data later 294 # Store each chunk in its own directory so that we can find the data later
295 chunk_dir = os.path.join("layout", "chunk_%05d" % chunk_num) 295 chunk_dir = os.path.join("layout", "chunk_%05d" % chunk_num)
296 test_shell = os.path.join(self._options.build_dir, "test_shell") 296 test_shell = os.path.join(self._options.build_dir, "test_shell")
297 out_dir = os.path.join(google.path_utils.ScriptDir(), "latest") 297 out_dir = os.path.join(path_utils.ScriptDir(), "latest")
298 out_dir = os.path.join(out_dir, chunk_dir) 298 out_dir = os.path.join(out_dir, chunk_dir)
299 if os.path.exists(out_dir): 299 if os.path.exists(out_dir):
300 old_files = glob.glob(os.path.join(out_dir, "*.txt")) 300 old_files = glob.glob(os.path.join(out_dir, "*.txt"))
301 for f in old_files: 301 for f in old_files:
302 os.remove(f) 302 os.remove(f)
303 else: 303 else:
304 os.makedirs(out_dir) 304 os.makedirs(out_dir)
305 script = os.path.join(self._source_dir, "webkit", "tools", "layout_tests", 305 script = os.path.join(self._source_dir, "webkit", "tools", "layout_tests",
306 "run_webkit_tests.py") 306 "run_webkit_tests.py")
307 script_cmd = ["python", script, "--run-singly", "-v", 307 script_cmd = ["python", script, "--run-singly", "-v",
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 # My machine can do about 120 layout tests/hour in release mode. 397 # My machine can do about 120 layout tests/hour in release mode.
398 # Let's do 30 minutes worth per run. 398 # Let's do 30 minutes worth per run.
399 # The CPU is mostly idle, so perhaps we can raise this when 399 # The CPU is mostly idle, so perhaps we can raise this when
400 # we figure out how to run them more efficiently. 400 # we figure out how to run them more efficiently.
401 parser.add_option("-n", "--num_tests", default=60, type="int", 401 parser.add_option("-n", "--num_tests", default=60, type="int",
402 help="for layout tests: # of subtests per run. 0 for all.") 402 help="for layout tests: # of subtests per run. 0 for all.")
403 403
404 options, args = parser.parse_args() 404 options, args = parser.parse_args()
405 405
406 if options.verbose: 406 if options.verbose:
407 google.logging_utils.config_root(logging.DEBUG) 407 logging_utils.config_root(logging.DEBUG)
408 else: 408 else:
409 google.logging_utils.config_root() 409 logging_utils.config_root()
410 410
411 if not options.test or not len(options.test): 411 if not options.test or not len(options.test):
412 parser.error("--test not specified") 412 parser.error("--test not specified")
413 413
414 for t in options.test: 414 for t in options.test:
415 tests = ChromeTests(options, args, t) 415 tests = ChromeTests(options, args, t)
416 ret = tests.Run() 416 ret = tests.Run()
417 if ret: return ret 417 if ret: return ret
418 return 0 418 return 0
419 419
420 420
421 if __name__ == "__main__": 421 if __name__ == "__main__":
422 ret = _main(sys.argv) 422 ret = _main(sys.argv)
423 sys.exit(ret) 423 sys.exit(ret)
OLDNEW
« no previous file with comments | « tools/valgrind/chrome_tests.bat ('k') | tools/valgrind/chrome_tests.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698