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

Side by Side Diff: build/android/pylib/local/device/local_device_test_run.py

Issue 1363643002: [Android] Fix miscellaneous small issues with gtest platform mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: back out timeout changes 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 unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 6
7 from devil.android import device_errors 7 from devil.android import device_errors
8 from pylib import valgrind_tools 8 from pylib import valgrind_tools
9 from pylib.base import base_test_result 9 from pylib.base import base_test_result
10 from pylib.base import test_run 10 from pylib.base import test_run
(...skipping 11 matching lines...) Expand all
22 try: 22 try:
23 return f(dev, *args, **kwargs) 23 return f(dev, *args, **kwargs)
24 except device_errors.CommandFailedError: 24 except device_errors.CommandFailedError:
25 logging.exception('Shard failed: %s(%s)', f.__name__, str(dev)) 25 logging.exception('Shard failed: %s(%s)', f.__name__, str(dev))
26 except device_errors.CommandTimeoutError: 26 except device_errors.CommandTimeoutError:
27 logging.exception('Shard timed out: %s(%s)', f.__name__, str(dev)) 27 logging.exception('Shard timed out: %s(%s)', f.__name__, str(dev))
28 except device_errors.DeviceUnreachableError: 28 except device_errors.DeviceUnreachableError:
29 logging.exception('Shard died: %s(%s)', f.__name__, str(dev)) 29 logging.exception('Shard died: %s(%s)', f.__name__, str(dev))
30 return None 30 return None
31 31
32 wrapper.__name__ = f.__name__
32 return wrapper 33 return wrapper
33 34
34 35
35 class LocalDeviceTestRun(test_run.TestRun): 36 class LocalDeviceTestRun(test_run.TestRun):
36 37
37 def __init__(self, env, test_instance): 38 def __init__(self, env, test_instance):
38 super(LocalDeviceTestRun, self).__init__(env, test_instance) 39 super(LocalDeviceTestRun, self).__init__(env, test_instance)
39 self._tools = {} 40 self._tools = {}
40 41
41 #override 42 #override
42 def RunTests(self): 43 def RunTests(self):
43 tests = self._GetTests() 44 tests = self._GetTests()
44 45
46 def run_test(dev, test):
47 try:
48 return self._RunTest(dev, test)
49 except device_errors.CommandFailedError:
50 logging.exception('Test failed: %s', test)
51 except device_errors.CommandTimeoutError:
52 logging.exception('Test timed out: %s', test)
53 return None
54
45 @handle_shard_failures 55 @handle_shard_failures
46 def run_tests_on_device(dev, tests, results): 56 def run_tests_on_device(dev, tests, results):
47 for test in tests: 57 for test in tests:
58 result = None
48 try: 59 try:
49 result = self._RunTest(dev, test) 60 result = run_test(dev, test)
50 if isinstance(result, base_test_result.BaseTestResult):
51 results.AddResult(result)
52 elif isinstance(result, list):
53 results.AddResults(result)
54 else:
55 raise Exception(
56 'Unexpected result type: %s' % type(result).__name__)
57 except:
58 if isinstance(tests, test_collection.TestCollection):
59 tests.add(test)
60 raise
61 finally: 61 finally:
62 if isinstance(tests, test_collection.TestCollection): 62 if isinstance(tests, test_collection.TestCollection):
63 if not result:
64 tests.add(test)
63 tests.test_completed() 65 tests.test_completed()
66
67 if isinstance(result, base_test_result.BaseTestResult):
68 results.AddResult(result)
69 elif isinstance(result, list):
70 results.AddResults(result)
71
64 logging.info('Finished running tests on this device.') 72 logging.info('Finished running tests on this device.')
65 73
66 tries = 0 74 tries = 0
67 results = base_test_result.TestRunResults() 75 results = base_test_result.TestRunResults()
68 all_fail_results = {} 76 all_fail_results = {}
69 while tries < self._env.max_tries and tests: 77 while tries < self._env.max_tries and tests:
70 logging.info('STARTING TRY #%d/%d', tries + 1, self._env.max_tries) 78 logging.info('STARTING TRY #%d/%d', tries + 1, self._env.max_tries)
71 logging.info('Will run %d tests on %d devices: %s', 79 logging.info('Will run %d tests on %d devices: %s',
72 len(tests), len(self._env.devices), 80 len(tests), len(self._env.devices),
73 ', '.join(str(d) for d in self._env.devices)) 81 ', '.join(str(d) for d in self._env.devices))
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 return test 137 return test
130 138
131 def _GetTests(self): 139 def _GetTests(self):
132 raise NotImplementedError 140 raise NotImplementedError
133 141
134 def _RunTest(self, device, test): 142 def _RunTest(self, device, test):
135 raise NotImplementedError 143 raise NotImplementedError
136 144
137 def _ShouldShard(self): 145 def _ShouldShard(self):
138 raise NotImplementedError 146 raise NotImplementedError
OLDNEW
« no previous file with comments | « build/android/pylib/local/device/local_device_gtest_run.py ('k') | chrome/test/android/unit_tests_apk/AndroidManifest.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698