Chromium Code Reviews| 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): |
|
Isaac (away)
2012/10/31 19:18:14
I wonder if this would be more stable if we did th
bulach
2012/10/31 19:27:31
we have no mechanism to do that, and it doesn't lo
| |
| 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: |
|
Isaac (away)
2012/10/31 19:18:14
nit: Might be cleaner with a local variable for th
bulach
2012/10/31 19:27:31
then line 227 would be more complicated, as it'd t
| |
| 225 logging.info('Obtaining tests from %s', available_devices[-1]) | |
| 226 all_tests = self._GetTestsFromDevice(available_devices[-1]) | |
| 227 return all_tests, available_devices | |
| 228 except Exception as e: | |
| 229 logging.info('Failed obtaining tests from %s %s', | |
| 230 available_devices[-1], e) | |
| 231 available_devices.pop() | |
| 232 raise Exception('No device available to get the list of tests.') | |
| 233 | |
| 234 def _GetTestsFromDevice(self, device): | |
| 235 test = SingleTestRunner(device, self.test_suite, self.gtest_filter, | |
| 236 self.test_arguments, self.timeout, self.rebaseline, | |
| 237 self.performance_test, self.cleanup_test_files, | |
| 238 self.tool, 0, | |
| 239 not not self.log_dump_name, self.fast_and_loose, | |
| 240 self.build_type) | |
| 241 # The executable/apk needs to be copied before we can call GetAllTests. | |
| 242 test.test_package.StripAndCopyExecutable() | |
| 243 all_tests = test.test_package.GetAllTests() | |
| 244 if not self.rebaseline: | |
| 245 disabled_list = test.GetDisabledTests() | |
| 246 # Only includes tests that do not have any match in the disabled list. | |
| 247 all_tests = filter(lambda t: | |
| 248 not any([fnmatch.fnmatch(t, disabled_pattern) | |
| 249 for disabled_pattern in disabled_list]), | |
| 250 all_tests) | |
| 251 return all_tests | |
| 230 | 252 |
| 231 def CreateShardedTestRunner(self, device, index): | 253 def CreateShardedTestRunner(self, device, index): |
| 232 """Creates a suite-specific test runner. | 254 """Creates a suite-specific test runner. |
| 233 | 255 |
| 234 Args: | 256 Args: |
| 235 device: Device serial where this shard will run. | 257 device: Device serial where this shard will run. |
| 236 index: Index of this device in the pool. | 258 index: Index of this device in the pool. |
| 237 | 259 |
| 238 Returns: | 260 Returns: |
| 239 A SingleTestRunner object. | 261 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 | 465 # 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 | 466 # from all suites, but the buildbot associates the exit status only with the |
| 445 # most recent step). | 467 # most recent step). |
| 446 if options.exit_code: | 468 if options.exit_code: |
| 447 return failed_tests_count | 469 return failed_tests_count |
| 448 return 0 | 470 return 0 |
| 449 | 471 |
| 450 | 472 |
| 451 if __name__ == '__main__': | 473 if __name__ == '__main__': |
| 452 sys.exit(main(sys.argv)) | 474 sys.exit(main(sys.argv)) |
| OLD | NEW |