OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 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 """Implements test sharding logic.""" | 5 """Implements test sharding logic.""" |
6 | 6 |
7 import logging | 7 import logging |
8 import threading | 8 import threading |
9 | 9 |
10 from pylib import android_commands | 10 from pylib import android_commands |
11 from pylib import constants | 11 from pylib import constants |
| 12 from pylib import forwarder |
12 from pylib.utils import reraiser_thread | 13 from pylib.utils import reraiser_thread |
13 from pylib.utils import watchdog_timer | 14 from pylib.utils import watchdog_timer |
14 | 15 |
15 import base_test_result | 16 import base_test_result |
16 | 17 |
17 | 18 |
18 DEFAULT_TIMEOUT = 7 * 60 # seven minutes | 19 DEFAULT_TIMEOUT = 7 * 60 # seven minutes |
19 | 20 |
20 | 21 |
21 class _ThreadSafeCounter(object): | 22 class _ThreadSafeCounter(object): |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 num_retries: number of retries for a test. | 286 num_retries: number of retries for a test. |
286 | 287 |
287 Returns: | 288 Returns: |
288 A tuple of (base_test_result.TestRunResults object, exit code). | 289 A tuple of (base_test_result.TestRunResults object, exit code). |
289 """ | 290 """ |
290 if not tests: | 291 if not tests: |
291 logging.error('No tests to run.') | 292 logging.error('No tests to run.') |
292 return (base_test_result.TestRunResults(), constants.ERROR_EXIT_CODE) | 293 return (base_test_result.TestRunResults(), constants.ERROR_EXIT_CODE) |
293 | 294 |
294 logging.info('Will run %d tests: %s', len(tests), str(tests)) | 295 logging.info('Will run %d tests: %s', len(tests), str(tests)) |
| 296 forwarder.Forwarder.KillHost(build_type) |
295 runners = _CreateRunners(runner_factory, devices, setup_timeout) | 297 runners = _CreateRunners(runner_factory, devices, setup_timeout) |
296 try: | 298 try: |
297 return _RunAllTests(runners, tests, num_retries, test_timeout) | 299 return _RunAllTests(runners, tests, num_retries, test_timeout) |
298 finally: | 300 finally: |
299 try: | 301 try: |
300 _TearDownRunners(runners, setup_timeout) | 302 _TearDownRunners(runners, setup_timeout) |
301 except android_commands.errors.DeviceUnresponsiveError as e: | 303 except android_commands.errors.DeviceUnresponsiveError as e: |
302 logging.warning('Device unresponsive during TearDown: [%s]', e) | 304 logging.warning('Device unresponsive during TearDown: [%s]', e) |
| 305 finally: |
| 306 forwarder.Forwarder.KillHost(build_type) |
OLD | NEW |