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