OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 """Dispatches tests, either sharding or replicating them. | 5 """Dispatches tests, either sharding or replicating them. |
6 | 6 |
7 Performs the following steps: | 7 Performs the following steps: |
8 * Create a test collection factory, using the given tests | 8 * Create a test collection factory, using the given tests |
9 - If sharding: test collection factory returns the same shared test collection | 9 - If sharding: test collection factory returns the same shared test collection |
10 to all test runners | 10 to all test runners |
11 - If replciating: test collection factory returns a unique test collection to | 11 - If replciating: test collection factory returns a unique test collection to |
12 each test runner, with the same set of tests in each. | 12 each test runner, with the same set of tests in each. |
13 * Create a test runner for each device. | 13 * Create a test runner for each device. |
14 * Run each test runner in its own thread, grabbing tests from the test | 14 * Run each test runner in its own thread, grabbing tests from the test |
15 collection until there are no tests left. | 15 collection until there are no tests left. |
16 """ | 16 """ |
17 | 17 |
18 # TODO(jbudorick) Deprecate and remove this class after any relevant parts have | 18 # TODO(jbudorick) Deprecate and remove this class after any relevant parts have |
19 # been ported to the new environment / test instance model. | 19 # been ported to the new environment / test instance model. |
20 | 20 |
21 import logging | 21 import logging |
22 import threading | 22 import threading |
23 | 23 |
| 24 from devil.android import device_errors |
| 25 from devil.utils import reraiser_thread |
| 26 from devil.utils import watchdog_timer |
24 from pylib import constants | 27 from pylib import constants |
25 from pylib.base import base_test_result | 28 from pylib.base import base_test_result |
26 from pylib.base import test_collection | 29 from pylib.base import test_collection |
27 from pylib.device import device_errors | |
28 from pylib.utils import reraiser_thread | |
29 from pylib.utils import watchdog_timer | |
30 | 30 |
31 | 31 |
32 DEFAULT_TIMEOUT = 7 * 60 # seven minutes | 32 DEFAULT_TIMEOUT = 7 * 60 # seven minutes |
33 | 33 |
34 | 34 |
35 class _ThreadSafeCounter(object): | 35 class _ThreadSafeCounter(object): |
36 """A threadsafe counter.""" | 36 """A threadsafe counter.""" |
37 | 37 |
38 def __init__(self): | 38 def __init__(self): |
39 self._lock = threading.Lock() | 39 self._lock = threading.Lock() |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 try: | 326 try: |
327 return _RunAllTests(runners, test_collection_factory, | 327 return _RunAllTests(runners, test_collection_factory, |
328 num_retries, test_timeout, tag_results_with_device) | 328 num_retries, test_timeout, tag_results_with_device) |
329 finally: | 329 finally: |
330 try: | 330 try: |
331 _TearDownRunners(runners, setup_timeout) | 331 _TearDownRunners(runners, setup_timeout) |
332 except device_errors.DeviceUnreachableError as e: | 332 except device_errors.DeviceUnreachableError as e: |
333 logging.warning('Device unresponsive during TearDown: [%s]', e) | 333 logging.warning('Device unresponsive during TearDown: [%s]', e) |
334 except Exception as e: | 334 except Exception as e: |
335 logging.error('Unexpected exception caught during TearDown: %s' % str(e)) | 335 logging.error('Unexpected exception caught during TearDown: %s' % str(e)) |
OLD | NEW |