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

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

Issue 147209: Teach tools/valgrind about the output directory used by the Make build. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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 | webkit/tools/layout_tests/layout_package/platform_utils_linux.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 This file is a copy of ../purify/chrome_tests.py. Eventually, it would be nice 10 This file is a copy of ../purify/chrome_tests.py. Eventually, it would be nice
(...skipping 17 matching lines...) Expand all
28 # TODO(erg): Copy/Move the relevant functions from the layout_package version 28 # TODO(erg): Copy/Move the relevant functions from the layout_package version
29 # of platform_utils back up to google.platform_utils 29 # of platform_utils back up to google.platform_utils
30 # package. http://crbug.com/6164 30 # package. http://crbug.com/6164
31 import layout_package.platform_utils 31 import layout_package.platform_utils
32 32
33 import common 33 import common
34 34
35 35
36 class TestNotFound(Exception): pass 36 class TestNotFound(Exception): pass
37 37
38 def Dir2IsNewer(dir1, dir2):
39 if dir2 == None or not os.path.isdir(dir2):
40 return False
41 if dir1 == None or not os.path.isdir(dir1):
42 return True
43 return (os.stat(dir2)[stat.ST_MTIME] - os.stat(dir1)[stat.ST_MTIME]) > 0
44
45 def FindNewestDir(dirs):
46 newest_dir = None
47 for dir in dirs:
48 if Dir2IsNewer(newest_dir, dir):
49 newest_dir = dir
50 return newest_dir
51
52 def File2IsNewer(file1, file2):
53 if file2 == None or not os.path.isfile(file2):
54 return False
55 if file1 == None or not os.path.isfile(file1):
56 return True
57 return (os.stat(file2)[stat.ST_MTIME] - os.stat(file1)[stat.ST_MTIME]) > 0
58
59 def FindDirContainingNewestFile(dirs, file):
60 newest_dir = None
61 newest_file = None
62 for dir in dirs:
63 the_file = os.path.join(dir, file)
64 if File2IsNewer(newest_file, the_file):
65 newest_dir = dir
66 newest_file = the_file
67 if newest_dir == None:
68 logging.error("cannot find file %s anywhere, have you built it?" % file)
69 sys.exit(-1)
70 return newest_dir
38 71
39 class ChromeTests: 72 class ChromeTests:
40 '''This class is derived from the chrome_tests.py file in ../purify/. 73 '''This class is derived from the chrome_tests.py file in ../purify/.
41 ''' 74 '''
42 75
43 def __init__(self, options, args, test): 76 def __init__(self, options, args, test):
44 # The known list of tests. 77 # The known list of tests.
45 # Recognise the original abbreviations as well as full executable names. 78 # Recognise the original abbreviations as well as full executable names.
46 self._test_list = { 79 self._test_list = {
47 "base": self.TestBase, "base_unittests": self.TestBase, 80 "base": self.TestBase, "base_unittests": self.TestBase,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 self._data_dirs = [google.path_utils.ScriptDir()] 120 self._data_dirs = [google.path_utils.ScriptDir()]
88 121
89 if module == "chrome": 122 if module == "chrome":
90 # unfortunately, not all modules have the same directory structure 123 # unfortunately, not all modules have the same directory structure
91 self._data_dirs.append(os.path.join(module_dir, "test", "data", 124 self._data_dirs.append(os.path.join(module_dir, "test", "data",
92 "valgrind")) 125 "valgrind"))
93 else: 126 else:
94 self._data_dirs.append(os.path.join(module_dir, "data", "valgrind")) 127 self._data_dirs.append(os.path.join(module_dir, "data", "valgrind"))
95 128
96 if not self._options.build_dir: 129 if not self._options.build_dir:
97 builddir = { 130 dirs = [
98 'darwin': 'xcodebuild', 131 os.path.join(self._source_dir, "xcodebuild", "Debug"),
99 'linux2': 'sconsbuild' 132 os.path.join(self._source_dir, "sconsbuild", "Debug"),
100 }[sys.platform] 133 os.path.join(self._source_dir, "out", "Debug"),
101 dir_chrome = os.path.join(self._source_dir, builddir, "Debug") 134 ]
102 dir_module = os.path.join(module_dir, "Debug")
103 if exe: 135 if exe:
104 exe_chrome = os.path.join(dir_chrome, exe) 136 self._options.build_dir = FindDirContainingNewestFile(dirs, exe)
105 exe_module = os.path.join(dir_module, exe)
106 if os.path.isfile(exe_chrome) and not os.path.isfile(exe_module):
107 self._options.build_dir = dir_chrome
108 elif os.path.isfile(exe_module) and not os.path.isfile(exe_chrome):
109 self._options.build_dir = dir_module
110 elif (os.stat(exe_module)[stat.ST_MTIME] >
111 os.stat(exe_chrome)[stat.ST_MTIME]):
112 self._options.build_dir = dir_module
113 else:
114 self._options.build_dir = dir_chrome
115 else: 137 else:
116 if os.path.isdir(dir_chrome) and not os.path.isdir(dir_module): 138 self._options.build_dir = FindNewestDir(dirs)
117 self._options.build_dir = dir_chrome
118 elif os.path.isdir(dir_module) and not os.path.isdir(dir_chrome):
119 self._options.build_dir = dir_module
120 elif (os.stat(dir_module)[stat.ST_MTIME] >
121 os.stat(dir_chrome)[stat.ST_MTIME]):
122 self._options.build_dir = dir_module
123 else:
124 self._options.build_dir = dir_chrome
125 139
126 cmd = list(self._command_preamble) 140 cmd = list(self._command_preamble)
127 for directory in self._data_dirs: 141 for directory in self._data_dirs:
128 suppression_file = os.path.join(directory, "suppressions.txt") 142 suppression_file = os.path.join(directory, "suppressions.txt")
129 if os.path.exists(suppression_file): 143 if os.path.exists(suppression_file):
130 cmd.append("--suppressions=%s" % suppression_file) 144 cmd.append("--suppressions=%s" % suppression_file)
131 # Platform specific suppression 145 # Platform specific suppression
132 suppression_platform = { 146 suppression_platform = {
133 'darwin': 'mac', 147 'darwin': 'mac',
134 'linux2': 'linux' 148 'linux2': 'linux'
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 for t in options.test: 412 for t in options.test:
399 tests = ChromeTests(options, args, t) 413 tests = ChromeTests(options, args, t)
400 ret = tests.Run() 414 ret = tests.Run()
401 if ret: return ret 415 if ret: return ret
402 return 0 416 return 0
403 417
404 418
405 if __name__ == "__main__": 419 if __name__ == "__main__":
406 ret = _main(sys.argv) 420 ret = _main(sys.argv)
407 sys.exit(ret) 421 sys.exit(ret)
OLDNEW
« no previous file with comments | « no previous file | webkit/tools/layout_tests/layout_package/platform_utils_linux.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698