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

Unified Diff: build/android/pylib/local/device/local_device_test_run.py

Issue 1358593002: [Android] Switch gtests to platform mode. (RELAND) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed Created 5 years, 3 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/local/device/local_device_gtest_run.py ('k') | build/android/test_runner.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/local/device/local_device_test_run.py
diff --git a/build/android/pylib/local/device/local_device_test_run.py b/build/android/pylib/local/device/local_device_test_run.py
index e10f04a71cb40c4a077c5a311e31017714ff1717..db19fe30d5104bfe1873875c6fdd4dd4af745795 100644
--- a/build/android/pylib/local/device/local_device_test_run.py
+++ b/build/android/pylib/local/device/local_device_test_run.py
@@ -11,6 +11,27 @@ from pylib.base import test_run
from pylib.base import test_collection
+def handle_shard_failures(f):
+ """A decorator that handles device failures for per-device functions.
+
+ Args:
+ f: the function being decorated. The function must take at least one
+ argument, and that argument must be the device.
+ """
+ def wrapper(dev, *args, **kwargs):
+ try:
+ return f(dev, *args, **kwargs)
+ except device_errors.CommandFailedError:
+ logging.exception('Shard failed: %s(%s)', f.__name__, str(dev))
+ except device_errors.CommandTimeoutError:
+ logging.exception('Shard timed out: %s(%s)', f.__name__, str(dev))
+ except device_errors.DeviceUnreachableError:
+ logging.exception('Shard died: %s(%s)', f.__name__, str(dev))
+ return None
+
+ return wrapper
+
+
class LocalDeviceTestRun(test_run.TestRun):
def __init__(self, env, test_instance):
@@ -21,6 +42,7 @@ class LocalDeviceTestRun(test_run.TestRun):
def RunTests(self):
tests = self._GetTests()
+ @handle_shard_failures
def run_tests_on_device(dev, tests, results):
for test in tests:
try:
@@ -52,21 +74,14 @@ class LocalDeviceTestRun(test_run.TestRun):
for t in tests:
logging.debug(' %s', t)
- try:
- try_results = base_test_result.TestRunResults()
- if self._ShouldShard():
- tc = test_collection.TestCollection(self._CreateShards(tests))
- self._env.parallel_devices.pMap(
- run_tests_on_device, tc, try_results).pGet(None)
- else:
- self._env.parallel_devices.pMap(
- run_tests_on_device, tests, try_results).pGet(None)
- except device_errors.CommandFailedError:
- logging.exception('Shard terminated: command failed')
- except device_errors.CommandTimeoutError:
- logging.exception('Shard terminated: command timed out')
- except device_errors.DeviceUnreachableError:
- logging.exception('Shard terminated: device became unreachable')
+ try_results = base_test_result.TestRunResults()
+ if self._ShouldShard():
+ tc = test_collection.TestCollection(self._CreateShards(tests))
+ self._env.parallel_devices.pMap(
+ run_tests_on_device, tc, try_results).pGet(None)
+ else:
+ self._env.parallel_devices.pMap(
+ run_tests_on_device, tests, try_results).pGet(None)
for result in try_results.GetAll():
if result.GetType() in (base_test_result.ResultType.PASS,
« no previous file with comments | « build/android/pylib/local/device/local_device_gtest_run.py ('k') | build/android/test_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698