OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import collections | 5 import collections |
6 import itertools | 6 import itertools |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import posixpath | 9 import posixpath |
10 | 10 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 self._delegate = _ExeDelegate(self, self._test_instance.exe_dist_dir) | 225 self._delegate = _ExeDelegate(self, self._test_instance.exe_dist_dir) |
226 self._crashes = set() | 226 self._crashes = set() |
227 self._servers = collections.defaultdict(list) | 227 self._servers = collections.defaultdict(list) |
228 | 228 |
229 #override | 229 #override |
230 def TestPackage(self): | 230 def TestPackage(self): |
231 return self._test_instance.suite | 231 return self._test_instance.suite |
232 | 232 |
233 #override | 233 #override |
234 def SetUp(self): | 234 def SetUp(self): |
235 @local_device_test_run.handle_shard_failures_with( | 235 @local_device_environment.handle_shard_failures_with( |
236 on_failure=self._env.BlacklistDevice) | 236 on_failure=self._env.BlacklistDevice) |
237 def individual_device_set_up(dev): | 237 def individual_device_set_up(dev): |
238 def install_apk(): | 238 def install_apk(): |
239 # Install test APK. | 239 # Install test APK. |
240 self._delegate.Install(dev) | 240 self._delegate.Install(dev) |
241 | 241 |
242 def push_test_data(): | 242 def push_test_data(): |
243 # Push data dependencies. | 243 # Push data dependencies. |
244 device_root = posixpath.join(dev.GetExternalStoragePath(), | 244 device_root = posixpath.join(dev.GetExternalStoragePath(), |
245 'chromium_tests_root') | 245 'chromium_tests_root') |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 # When the exact list of tests to run is given via command-line (e.g. when | 306 # When the exact list of tests to run is given via command-line (e.g. when |
307 # locally iterating on a specific test), skip querying the device (which | 307 # locally iterating on a specific test), skip querying the device (which |
308 # takes ~3 seconds). | 308 # takes ~3 seconds). |
309 tests = _ExtractTestsFromFilter(self._test_instance.gtest_filter) | 309 tests = _ExtractTestsFromFilter(self._test_instance.gtest_filter) |
310 if tests: | 310 if tests: |
311 return tests | 311 return tests |
312 | 312 |
313 # Even when there's only one device, it still makes sense to retrieve the | 313 # Even when there's only one device, it still makes sense to retrieve the |
314 # test list so that tests can be split up and run in batches rather than all | 314 # test list so that tests can be split up and run in batches rather than all |
315 # at once (since test output is not streamed). | 315 # at once (since test output is not streamed). |
316 @local_device_test_run.handle_shard_failures_with( | 316 @local_device_environment.handle_shard_failures_with( |
317 on_failure=self._env.BlacklistDevice) | 317 on_failure=self._env.BlacklistDevice) |
318 def list_tests(dev): | 318 def list_tests(dev): |
319 raw_test_list = self._delegate.Run( | 319 raw_test_list = self._delegate.Run( |
320 None, dev, flags='--gtest_list_tests', timeout=30) | 320 None, dev, flags='--gtest_list_tests', timeout=30) |
321 tests = gtest_test_instance.ParseGTestListTests(raw_test_list) | 321 tests = gtest_test_instance.ParseGTestListTests(raw_test_list) |
322 if not tests: | 322 if not tests: |
323 logging.info('No tests found. Output:') | 323 logging.info('No tests found. Output:') |
324 for l in raw_test_list: | 324 for l in raw_test_list: |
325 logging.info(' %s', l) | 325 logging.info(' %s', l) |
326 tests = self._test_instance.FilterTests(tests) | 326 tests = self._test_instance.FilterTests(tests) |
(...skipping 29 matching lines...) Expand all Loading... |
356 # TODO(jbudorick): Transition test scripts away from parsing stdout. | 356 # TODO(jbudorick): Transition test scripts away from parsing stdout. |
357 results = gtest_test_instance.ParseGTestOutput(output) | 357 results = gtest_test_instance.ParseGTestOutput(output) |
358 | 358 |
359 # Check whether there are any crashed testcases. | 359 # Check whether there are any crashed testcases. |
360 self._crashes.update(r.GetName() for r in results | 360 self._crashes.update(r.GetName() for r in results |
361 if r.GetType() == base_test_result.ResultType.CRASH) | 361 if r.GetType() == base_test_result.ResultType.CRASH) |
362 return results | 362 return results |
363 | 363 |
364 #override | 364 #override |
365 def TearDown(self): | 365 def TearDown(self): |
366 @local_device_test_run.handle_shard_failures | 366 @local_device_environment.handle_shard_failures |
367 def individual_device_tear_down(dev): | 367 def individual_device_tear_down(dev): |
368 for s in self._servers.get(str(dev), []): | 368 for s in self._servers.get(str(dev), []): |
369 s.TearDown() | 369 s.TearDown() |
370 | 370 |
371 tool = self.GetTool(dev) | 371 tool = self.GetTool(dev) |
372 tool.CleanUpEnvironment() | 372 tool.CleanUpEnvironment() |
373 | 373 |
374 self._env.parallel_devices.pMap(individual_device_tear_down) | 374 self._env.parallel_devices.pMap(individual_device_tear_down) |
OLD | NEW |