OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 ''' Runs various chrome tests through heapcheck_test.py. | 7 ''' Runs various chrome tests through heapcheck_test.py. |
8 | 8 |
9 Most of this code is copied from ../valgrind/chrome_tests.py. | 9 Most of this code is copied from ../valgrind/chrome_tests.py. |
10 TODO(glider): put common functions to a standalone module. | 10 TODO(glider): put common functions to a standalone module. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 '''Generates the default command array that most tests will use. | 127 '''Generates the default command array that most tests will use. |
128 | 128 |
129 Args: | 129 Args: |
130 module: The module name (corresponds to the dir in src/ where the test | 130 module: The module name (corresponds to the dir in src/ where the test |
131 data resides). | 131 data resides). |
132 exe: The executable name. | 132 exe: The executable name. |
133 heapcheck_test_args: additional arguments to append to the command line. | 133 heapcheck_test_args: additional arguments to append to the command line. |
134 Returns: | 134 Returns: |
135 A string with the command to run the test. | 135 A string with the command to run the test. |
136 ''' | 136 ''' |
137 module_dir = os.path.join(self._source_dir, module) | |
138 | |
139 # We need multiple data dirs, the current script directory and a module | |
140 # specific one. The global suppression file lives in our directory, and the | |
141 # module specific suppression file lives with the module. | |
142 self._data_dirs = [path_utils.ScriptDir()] | |
143 | |
144 if module == "chrome": | |
145 # Unfortunately, not all modules have the same directory structure. | |
146 self._data_dirs.append(os.path.join(module_dir, "test", "data", | |
147 "heapcheck")) | |
148 else: | |
149 self._data_dirs.append(os.path.join(module_dir, "data", "heapcheck")) | |
150 | |
151 if not self._options.build_dir: | 137 if not self._options.build_dir: |
152 dirs = [ | 138 dirs = [ |
153 os.path.join(self._source_dir, "xcodebuild", "Debug"), | 139 os.path.join(self._source_dir, "xcodebuild", "Debug"), |
154 os.path.join(self._source_dir, "out", "Debug"), | 140 os.path.join(self._source_dir, "out", "Debug"), |
155 ] | 141 ] |
156 if exe: | 142 if exe: |
157 self._options.build_dir = FindDirContainingNewestFile(dirs, exe) | 143 self._options.build_dir = FindDirContainingNewestFile(dirs, exe) |
158 else: | 144 else: |
159 self._options.build_dir = FindNewestDir(dirs) | 145 self._options.build_dir = FindNewestDir(dirs) |
160 | 146 |
161 cmd = list(self._command_preamble) | 147 cmd = list(self._command_preamble) |
162 | 148 |
163 if heapcheck_test_args != None: | 149 if heapcheck_test_args != None: |
164 for arg in heapcheck_test_args: | 150 for arg in heapcheck_test_args: |
165 cmd.append(arg) | 151 cmd.append(arg) |
166 if exe: | 152 if exe: |
167 cmd.append(os.path.join(self._options.build_dir, exe)) | 153 cmd.append(os.path.join(self._options.build_dir, exe)) |
168 # Heapcheck runs tests slowly, so slow tests hurt more; show elapased time | 154 # Heapcheck runs tests slowly, so slow tests hurt more; show elapased time |
169 # so we can find the slowpokes. | 155 # so we can find the slowpokes. |
170 cmd.append("--gtest_print_time") | 156 cmd.append("--gtest_print_time") |
171 if self._options.gtest_repeat: | 157 if self._options.gtest_repeat: |
172 cmd.append("--gtest_repeat=%s" % self._options.gtest_repeat) | 158 cmd.append("--gtest_repeat=%s" % self._options.gtest_repeat) |
173 return cmd | 159 return cmd |
174 | 160 |
175 def Suppressions(self): | 161 def Suppressions(self): |
176 '''Builds the list of available suppressions files.''' | 162 '''Builds the list of available suppressions files.''' |
177 ret = [] | 163 ret = [] |
178 for directory in self._data_dirs: | 164 directory = path_utils.ScriptDir() |
179 suppression_file = os.path.join(directory, "suppressions.txt") | 165 suppression_file = os.path.join(directory, "suppressions.txt") |
180 if os.path.exists(suppression_file): | 166 if os.path.exists(suppression_file): |
181 ret.append(suppression_file) | 167 ret.append(suppression_file) |
182 suppression_file = os.path.join(directory, "suppressions_linux.txt") | 168 suppression_file = os.path.join(directory, "suppressions_linux.txt") |
183 if os.path.exists(suppression_file): | 169 if os.path.exists(suppression_file): |
184 ret.append(suppression_file) | 170 ret.append(suppression_file) |
185 return ret | 171 return ret |
186 | 172 |
187 def Run(self): | 173 def Run(self): |
188 '''Runs the test specified by command-line argument --test.''' | 174 '''Runs the test specified by command-line argument --test.''' |
189 logging.info("running test %s" % (self._test)) | 175 logging.info("running test %s" % (self._test)) |
190 return self._test_list[self._test]() | 176 return self._test_list[self._test]() |
191 | 177 |
192 def _ReadGtestFilterFile(self, name, cmd): | 178 def _ReadGtestFilterFile(self, name, cmd): |
193 '''Reads files which contain lists of tests to filter out with | 179 '''Reads files which contain lists of tests to filter out with |
194 --gtest_filter and appends the command-line option to |cmd|. | 180 --gtest_filter and appends the command-line option to |cmd|. |
195 | 181 |
196 Args: | 182 Args: |
197 name: the test executable name. | 183 name: the test executable name. |
198 cmd: the test running command line to be modified. | 184 cmd: the test running command line to be modified. |
199 ''' | 185 ''' |
200 filters = [] | 186 filters = [] |
201 for directory in self._data_dirs: | 187 directory = path_utils.ScriptDir() |
202 gtest_filter_files = [ | 188 gtest_filter_files = [ |
203 os.path.join(directory, name + ".gtest.txt"), | 189 os.path.join(directory, name + ".gtest-heapcheck.txt"), |
Timur Iskhodzhanov
2011/08/16 09:46:05
we don't use this
| |
204 os.path.join(directory, name + ".gtest-heapcheck.txt"), | 190 # TODO(glider): Linux vs. CrOS? |
205 os.path.join(directory, name + ".gtest_linux.txt")] | 191 ] |
Timur Iskhodzhanov
2011/08/16 09:46:05
we don't use this yet
| |
206 for filename in gtest_filter_files: | 192 logging.info("Reading gtest exclude filter files:") |
207 if os.path.exists(filename): | 193 for filename in gtest_filter_files: |
208 logging.info("reading gtest filters from %s" % filename) | 194 # strip the leading absolute path (may be very long on the bot) |
209 f = open(filename, 'r') | 195 # and the following / or \. |
210 for line in f.readlines(): | 196 readable_filename = filename.replace(self._source_dir, "")[1:] |
211 if line.startswith("#") or line.startswith("//") or line.isspace(): | 197 if not os.path.exists(filename): |
212 continue | 198 logging.info(" \"%s\" - not found" % readable_filename) |
213 line = line.rstrip() | 199 continue |
214 filters.append(line) | 200 logging.info(" \"%s\" - OK" % readable_filename) |
201 f = open(filename, 'r') | |
202 for line in f.readlines(): | |
203 if line.startswith("#") or line.startswith("//") or line.isspace(): | |
204 continue | |
205 line = line.rstrip() | |
206 filters.append(line) | |
215 gtest_filter = self._options.gtest_filter | 207 gtest_filter = self._options.gtest_filter |
216 if len(filters): | 208 if len(filters): |
217 if gtest_filter: | 209 if gtest_filter: |
218 gtest_filter += ":" | 210 gtest_filter += ":" |
219 if gtest_filter.find("-") < 0: | 211 if gtest_filter.find("-") < 0: |
220 gtest_filter += "-" | 212 gtest_filter += "-" |
221 else: | 213 else: |
222 gtest_filter = "-" | 214 gtest_filter = "-" |
223 gtest_filter += ":".join(filters) | 215 gtest_filter += ":".join(filters) |
224 if gtest_filter: | 216 if gtest_filter: |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
460 return 0 | 452 return 0 |
461 | 453 |
462 | 454 |
463 if __name__ == "__main__": | 455 if __name__ == "__main__": |
464 if sys.platform.startswith('linux'): | 456 if sys.platform.startswith('linux'): |
465 ret = _main(sys.argv) | 457 ret = _main(sys.argv) |
466 else: | 458 else: |
467 logging.error("Heap checking works only on Linux at the moment.") | 459 logging.error("Heap checking works only on Linux at the moment.") |
468 ret = 1 | 460 ret = 1 |
469 sys.exit(ret) | 461 sys.exit(ret) |
OLD | NEW |