OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 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 all the native unit tests. | 7 """Runs all the native unit tests. |
8 | 8 |
9 1. Copy over test binary to /data/local on device. | 9 1. Copy over test binary to /data/local on device. |
10 2. Resources: chrome/unit_tests requires resources (chrome.pak and en-US.pak) | 10 2. Resources: chrome/unit_tests requires resources (chrome.pak and en-US.pak) |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 self.gtest_filter = gtest_filter or '' | 201 self.gtest_filter = gtest_filter or '' |
202 self.test_arguments = test_arguments | 202 self.test_arguments = test_arguments |
203 self.timeout = timeout | 203 self.timeout = timeout |
204 self.rebaseline = rebaseline | 204 self.rebaseline = rebaseline |
205 self.performance_test = performance_test | 205 self.performance_test = performance_test |
206 self.cleanup_test_files = cleanup_test_files | 206 self.cleanup_test_files = cleanup_test_files |
207 self.tool = tool | 207 self.tool = tool |
208 self.log_dump_name = log_dump_name | 208 self.log_dump_name = log_dump_name |
209 self.fast_and_loose = fast_and_loose | 209 self.fast_and_loose = fast_and_loose |
210 self.build_type = build_type | 210 self.build_type = build_type |
211 test = SingleTestRunner(self.attached_devices[0], test_suite, gtest_filter, | |
212 test_arguments, timeout, rebaseline, | |
213 performance_test, cleanup_test_files, tool, 0, | |
214 not not self.log_dump_name, fast_and_loose, | |
215 build_type) | |
216 self.tests = [] | 211 self.tests = [] |
217 if not self.gtest_filter: | 212 if not self.gtest_filter: |
218 # No filter has been specified, let's add all tests then. | 213 # No filter has been specified, let's add all tests then. |
219 # The executable/apk needs to be copied before we can call GetAllTests. | 214 self.tests, self.attached_devices = self._GetTests() |
220 test.test_package.StripAndCopyExecutable() | 215 |
221 all_tests = test.test_package.GetAllTests() | 216 def _GetTests(self): |
222 if not rebaseline: | 217 """Returns a tuple of (all_tests, available_devices). |
223 disabled_list = test.GetDisabledTests() | 218 |
224 # Only includes tests that do not have any match in the disabled list. | 219 Tries to obtain the list of available tests. |
225 all_tests = filter(lambda t: | 220 Raises Exception if all devices failed. |
226 not any([fnmatch.fnmatch(t, disabled_pattern) | 221 """ |
227 for disabled_pattern in disabled_list]), | 222 available_devices = list(self.attached_devices) |
228 all_tests) | 223 while available_devices: |
229 self.tests = all_tests | 224 try: |
225 logging.info('Obtaining tests from %s', available_devices[-1]) | |
226 all_tests = self._GetTestsFromDevice(available_devices[-1]) | |
227 return all_tests, available_devices | |
Yaron
2012/10/31 17:18:51
Don't you want to collect all the devices and merg
bulach
2012/10/31 18:10:35
sort of the latter (see 211 on the other side), bu
Yaron
2012/10/31 18:37:23
My point should've read "and you _don't_ need to q
| |
228 break | |
Yaron
2012/10/31 17:18:51
"break" unnecessary given "return" above
bulach
2012/10/31 18:10:35
Done.
| |
229 except Exception as e: | |
230 logging.info('Failed obtaining tests from %s %s', | |
231 available_devices[-1], e) | |
232 available_devices.pop() | |
233 raise Exception('No device available to get the list of tests.') | |
234 | |
235 def _GetTestsFromDevice(self, device): | |
236 test = SingleTestRunner(device, self.test_suite, self.gtest_filter, | |
237 self.test_arguments, self.timeout, self.rebaseline, | |
238 self.performance_test, self.cleanup_test_files, | |
239 self.tool, 0, | |
240 not not self.log_dump_name, self.fast_and_loose, | |
241 self.build_type) | |
242 # The executable/apk needs to be copied before we can call GetAllTests. | |
243 test.test_package.StripAndCopyExecutable() | |
244 all_tests = test.test_package.GetAllTests() | |
245 if not self.rebaseline: | |
246 disabled_list = test.GetDisabledTests() | |
247 # Only includes tests that do not have any match in the disabled list. | |
248 all_tests = filter(lambda t: | |
249 not any([fnmatch.fnmatch(t, disabled_pattern) | |
250 for disabled_pattern in disabled_list]), | |
251 all_tests) | |
252 return all_tests | |
230 | 253 |
231 def CreateShardedTestRunner(self, device, index): | 254 def CreateShardedTestRunner(self, device, index): |
232 """Creates a suite-specific test runner. | 255 """Creates a suite-specific test runner. |
233 | 256 |
234 Args: | 257 Args: |
235 device: Device serial where this shard will run. | 258 device: Device serial where this shard will run. |
236 index: Index of this device in the pool. | 259 index: Index of this device in the pool. |
237 | 260 |
238 Returns: | 261 Returns: |
239 A SingleTestRunner object. | 262 A SingleTestRunner object. |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
443 # the batch (this happens because the exit status is a sum of all failures | 466 # the batch (this happens because the exit status is a sum of all failures |
444 # from all suites, but the buildbot associates the exit status only with the | 467 # from all suites, but the buildbot associates the exit status only with the |
445 # most recent step). | 468 # most recent step). |
446 if options.exit_code: | 469 if options.exit_code: |
447 return failed_tests_count | 470 return failed_tests_count |
448 return 0 | 471 return 0 |
449 | 472 |
450 | 473 |
451 if __name__ == '__main__': | 474 if __name__ == '__main__': |
452 sys.exit(main(sys.argv)) | 475 sys.exit(main(sys.argv)) |
OLD | NEW |