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

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

Issue 2078563002: [Android] Stop gtests & instrumentation tests on receiving SIGTERM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | « no previous file | build/android/test_runner.pydeps » ('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 a1ad7ef6ef5a0665d4239838e352de81e6b7863c..544fbf0e41107c40545c0875c8c99e30a963dbf5 100644
--- a/build/android/pylib/local/device/local_device_test_run.py
+++ b/build/android/pylib/local/device/local_device_test_run.py
@@ -6,9 +6,13 @@ import fnmatch
import functools
import imp
import logging
+import signal
+import thread
+import threading
from devil import base_error
from devil.android import device_errors
+from devil.utils import signal_handler
from pylib import valgrind_tools
from pylib.base import base_test_result
from pylib.base import test_run
@@ -67,8 +71,10 @@ def handle_shard_failures_with(on_failure):
except device_errors.DeviceUnreachableError:
logging.exception('Shard died: %s(%s)', f.__name__, str(dev))
except base_error.BaseError:
- logging.exception('Shard failed: %s(%s)', f.__name__,
- str(dev))
+ logging.exception('Shard failed: %s(%s)', f.__name__, str(dev))
+ except SystemExit:
+ logging.exception('Shard killed: %s(%s)', f.__name__, str(dev))
mikecase (wrong mikecase) 2016/06/16 19:13:13 Did anything functionally change except for adding
+ raise
if on_failure:
on_failure(dev, f.__name__)
return None
@@ -88,9 +94,14 @@ class LocalDeviceTestRun(test_run.TestRun):
def RunTests(self):
tests = self._GetTests()
+ exit_now = threading.Event()
+
@handle_shard_failures
def run_tests_on_device(dev, tests, results):
for test in tests:
+ if exit_now.isSet():
+ thread.exit()
+
result = None
try:
result = self._RunTest(dev, test)
@@ -112,34 +123,38 @@ class LocalDeviceTestRun(test_run.TestRun):
logging.info('Finished running tests on this device.')
- tries = 0
- results = []
- while tries < self._env.max_tries and tests:
- logging.info('STARTING TRY #%d/%d', tries + 1, self._env.max_tries)
- logging.info('Will run %d tests on %d devices: %s',
- len(tests), len(self._env.devices),
- ', '.join(str(d) for d in self._env.devices))
- for t in tests:
- logging.debug(' %s', t)
-
- 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)
-
- results.append(try_results)
- tries += 1
- tests = self._GetTestsToRetry(tests, try_results)
-
- logging.info('FINISHED TRY #%d/%d', tries, self._env.max_tries)
- if tests:
- logging.info('%d failed tests remain.', len(tests))
- else:
- logging.info('All tests completed.')
+ def stop_tests(_signum, _frame):
+ exit_now.set()
+
+ with signal_handler.AddSignalHandler(signal.SIGTERM, stop_tests):
+ tries = 0
+ results = []
+ while tries < self._env.max_tries and tests:
+ logging.info('STARTING TRY #%d/%d', tries + 1, self._env.max_tries)
+ logging.info('Will run %d tests on %d devices: %s',
+ len(tests), len(self._env.devices),
+ ', '.join(str(d) for d in self._env.devices))
+ for t in tests:
+ logging.debug(' %s', t)
+
+ 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)
+
+ results.append(try_results)
+ tries += 1
+ tests = self._GetTestsToRetry(tests, try_results)
+
+ logging.info('FINISHED TRY #%d/%d', tries, self._env.max_tries)
+ if tests:
+ logging.info('%d failed tests remain.', len(tests))
+ else:
+ logging.info('All tests completed.')
return results
« no previous file with comments | « no previous file | build/android/test_runner.pydeps » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698