| Index: build/android/pylib/dispatch.py
|
| diff --git a/build/android/pylib/dispatch.py b/build/android/pylib/dispatch.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..1e3e047218b77f06280d273bd79a9d22c32bbe52
|
| --- /dev/null
|
| +++ b/build/android/pylib/dispatch.py
|
| @@ -0,0 +1,51 @@
|
| +# Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +"""Common dispatcher for all test types."""
|
| +
|
| +import logging
|
| +
|
| +from pylib import android_commands
|
| +from pylib.base import shard
|
| +
|
| +
|
| +def Dispatch(options, tests, test_runner_factory, sharding='distribute',
|
| + setup_timeout=None):
|
| + """Dispatches a particular set of tests.
|
| +
|
| + This is a common function used by all test dispatchers.
|
| +
|
| + Args:
|
| + options: command line options.
|
| + tests: a list of tests.
|
| + test_runner_factory: a function which accepts (device, shard_index) and
|
| + returns the test runner that the sharder uses to run tests.
|
| + sharding: a string to indicate whether we should distribute all tests as a
|
| + common pool to draw from, or duplicate all tests onto every test runner.
|
| + Must be either 'distribute' or 'duplicate'
|
| + setup_timeout: timeout for setup.
|
| +
|
| + Returns:
|
| + A tuple of (base_test_result.TestRunResults object, exit code)
|
| + """
|
| +
|
| + # Device setup
|
| + attached_devices = []
|
| +
|
| + attached_devices = android_commands.GetAttachedDevices()
|
| + if options.test_device:
|
| + assert options.test_device in attached_devices
|
| + attached_devices = [options.test_device]
|
| +
|
| + options.ensure_value('wait_for_debugger', False)
|
| + if len(attached_devices) > 1 and options.wait_for_debugger:
|
| + logging.warning('Debugger can not be sharded, using first available device')
|
| + attached_devices = attached_devices[:1]
|
| +
|
| + test_results, exit_code = shard.ShardAndRunTests(
|
| + test_runner_factory, attached_devices, tests, options.build_type,
|
| + test_timeout=None, num_retries=options.num_retries, sharding=sharding,
|
| + setup_timeout=(setup_timeout or shard.DEFAULT_TIMEOUT))
|
| +
|
| + return (test_results, exit_code)
|
|
|