OLD | NEW |
(Empty) | |
| 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 |
| 3 # found in the LICENSE file. |
| 4 |
| 5 """Common dispatcher for all test types.""" |
| 6 |
| 7 import logging |
| 8 |
| 9 from pylib import android_commands |
| 10 from pylib.base import shard |
| 11 |
| 12 |
| 13 def Dispatch(options, tests, test_runner_factory, sharding='distribute', |
| 14 setup_timeout=None): |
| 15 """Dispatches a particular set of tests. |
| 16 |
| 17 This is a common function used by all test dispatchers. |
| 18 |
| 19 Args: |
| 20 options: command line options. |
| 21 tests: a list of tests. |
| 22 test_runner_factory: a function which accepts (device, shard_index) and |
| 23 returns the test runner that the sharder uses to run tests. |
| 24 sharding: a string to indicate whether we should distribute all tests as a |
| 25 common pool to draw from, or duplicate all tests onto every test runner. |
| 26 Must be either 'distribute' or 'duplicate' |
| 27 setup_timeout: timeout for setup. |
| 28 |
| 29 Returns: |
| 30 A tuple of (base_test_result.TestRunResults object, exit code) |
| 31 """ |
| 32 |
| 33 # Device setup |
| 34 attached_devices = [] |
| 35 |
| 36 attached_devices = android_commands.GetAttachedDevices() |
| 37 if options.test_device: |
| 38 assert options.test_device in attached_devices |
| 39 attached_devices = [options.test_device] |
| 40 |
| 41 options.ensure_value('wait_for_debugger', False) |
| 42 if len(attached_devices) > 1 and options.wait_for_debugger: |
| 43 logging.warning('Debugger can not be sharded, using first available device') |
| 44 attached_devices = attached_devices[:1] |
| 45 |
| 46 test_results, exit_code = shard.ShardAndRunTests( |
| 47 test_runner_factory, attached_devices, tests, options.build_type, |
| 48 test_timeout=None, num_retries=options.num_retries, sharding=sharding, |
| 49 setup_timeout=(setup_timeout or shard.DEFAULT_TIMEOUT)) |
| 50 |
| 51 return (test_results, exit_code) |
OLD | NEW |