Index: build/android/pylib/base/test_dispatcher.py |
diff --git a/build/android/pylib/base/test_dispatcher.py b/build/android/pylib/base/test_dispatcher.py |
index c513d9abebf9fe9336a18eb3b771b6fa422cc8c4..c11d52e8b39e7738115586ee8611478e76d4d773 100644 |
--- a/build/android/pylib/base/test_dispatcher.py |
+++ b/build/android/pylib/base/test_dispatcher.py |
@@ -21,6 +21,7 @@ Performs the following steps: |
import logging |
import threading |
+from devil.android import device_blacklist |
from devil.android import device_errors |
from devil.utils import reraiser_thread |
from devil.utils import watchdog_timer |
@@ -130,7 +131,8 @@ def _RunTestsFromQueue(runner, collection, out_results, watcher, |
collection.test_completed() |
-def _SetUp(runner_factory, device, out_runners, threadsafe_counter): |
+def _SetUp(runner_factory, device, out_runners, threadsafe_counter, |
+ blacklist_file=None): |
"""Creates a test runner for each device and calls SetUp() in parallel. |
Note: if a device is unresponsive the corresponding TestRunner will not be |
@@ -142,10 +144,20 @@ def _SetUp(runner_factory, device, out_runners, threadsafe_counter): |
device: The device serial number to set up. |
out_runners: List to add the successfully set up TestRunner object. |
threadsafe_counter: A _ThreadSafeCounter object used to get shard indices. |
+ blacklist_file: Path to device blacklist. |
""" |
try: |
index = threadsafe_counter.GetAndIncrement() |
logging.warning('Creating shard %s for device %s.', index, device) |
+ |
+ blacklist = (device_blacklist.Blacklist(blacklist_file).Read() |
jbudorick
2016/06/06 22:52:27
This isn't the right place to do this; it'll get r
rnephew (Reviews Here)
2016/06/06 23:33:21
Yeah, that makes for a much much simpler solution.
|
+ if blacklist_file |
+ else None) |
+ if blacklist and str(device) in blacklist: |
+ logging.info('Device %s is in blacklist. Not creating shard %s', |
+ str(device), index) |
+ return |
+ |
runner = runner_factory(device, index) |
runner.SetUp() |
out_runners.append(runner) |
@@ -214,7 +226,7 @@ def _RunAllTests(runners, test_collection_factory, num_retries, timeout=None, |
return (run_results, exit_code) |
-def _CreateRunners(runner_factory, devices, timeout=None): |
+def _CreateRunners(runner_factory, devices, timeout=None, blacklist_file=None): |
"""Creates a test runner for each device and calls SetUp() in parallel. |
Note: if a device is unresponsive the corresponding TestRunner will not be |
@@ -225,6 +237,7 @@ def _CreateRunners(runner_factory, devices, timeout=None): |
TestRunner object. |
devices: List of device serial numbers as strings. |
timeout: Watchdog timeout in seconds, defaults to the default timeout. |
+ blacklist_file: Path to device blacklist file. |
Returns: |
A list of TestRunner objects. |
@@ -235,7 +248,8 @@ def _CreateRunners(runner_factory, devices, timeout=None): |
counter = _ThreadSafeCounter() |
threads = reraiser_thread.ReraiserThreadGroup( |
[reraiser_thread.ReraiserThread(_SetUp, |
- [runner_factory, d, runners, counter], |
+ [runner_factory, d, runners, counter, |
+ blacklist_file], |
name=str(d)[-4:]) |
for d in devices]) |
threads.StartAll() |
@@ -281,7 +295,7 @@ def ApplyMaxPerRun(tests, max_per_run): |
def RunTests(tests, runner_factory, devices, shard=True, |
test_timeout=DEFAULT_TIMEOUT, setup_timeout=DEFAULT_TIMEOUT, |
- num_retries=2, max_per_run=256): |
+ num_retries=2, max_per_run=256, blacklist_file=None): |
"""Run all tests on attached devices, retrying tests that don't pass. |
Args: |
@@ -299,6 +313,7 @@ def RunTests(tests, runner_factory, devices, shard=True, |
test runners. |
num_retries: Number of retries for a test. |
max_per_run: Maximum number of tests to run in any group. |
+ blacklist_file: Path to blacklist file. |
Returns: |
A tuple of (base_test_result.TestRunResults object, exit code). |
@@ -326,7 +341,8 @@ def RunTests(tests, runner_factory, devices, shard=True, |
logging.info('Will run %d tests (%s): %s', |
len(tests_expanded), log_string, str(tests_expanded)) |
- runners = _CreateRunners(runner_factory, devices, setup_timeout) |
+ runners = _CreateRunners(runner_factory, devices, setup_timeout, |
+ blacklist_file=blacklist_file) |
try: |
return _RunAllTests(runners, test_collection_factory, |
num_retries, test_timeout, tag_results_with_device) |