Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8499)

Unified Diff: build/android/pylib/dispatch.py

Issue 18444004: Makes host driven tests use the common sharder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes calls to Dispatch and the RunTests functions Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/pylib/browsertests/dispatch.py ('k') | build/android/pylib/gtest/dispatch.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..03f15121b911c7166f00f84413cc7fc313ca0a3f
--- /dev/null
+++ b/build/android/pylib/dispatch.py
@@ -0,0 +1,65 @@
+# 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
+
+
+VALID_SHARDING_OPTIONS = ['shard', 'replicate']
+
+
+def Dispatch(options, tests, test_runner_factory, distribution='shard',
+ 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.
+ distribution: 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 'shard' or 'replicate'
+ setup_timeout: timeout for setup.
+
+ Returns:
+ A tuple of (base_test_result.TestRunResults object, exit code)
+ """
+
+ # Validation
+ if distribution not in VALID_SHARDING_OPTIONS:
+ raise ValueError('Invalid value for sharding. Options are: %s'
+ % ', '.join(VALID_SHARDING_OPTIONS))
+
+ # 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]
+
+ if distribution == 'shard':
+ test_results, exit_code = shard.ShardAndRunTests(
+ tests, test_runner_factory, attached_devices, options.build_type,
+ test_timeout=None, num_retries=options.num_retries,
+ setup_timeout=(setup_timeout or shard.DEFAULT_TIMEOUT))
+ else: # Replicate
+ test_results, exit_code = shard.ReplicateAndRunTests(
+ tests, test_runner_factory, attached_devices, options.build_type,
+ test_timeout=None, num_retries=options.num_retries,
+ setup_timeout=(setup_timeout or shard.DEFAULT_TIMEOUT))
+
+ return (test_results, exit_code)
« no previous file with comments | « build/android/pylib/browsertests/dispatch.py ('k') | build/android/pylib/gtest/dispatch.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698