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

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

Issue 1034053002: [Android] Add an out-of-app instrumentation driver APK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix unittest_apk gn template Created 5 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 import re 6 import re
7 import time 7 import time
8 8
9 from pylib import flag_changer 9 from pylib import flag_changer
10 from pylib.base import base_test_result 10 from pylib.base import base_test_result
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 #override 120 #override
121 def _GetTests(self): 121 def _GetTests(self):
122 return self._test_instance.GetTests() 122 return self._test_instance.GetTests()
123 123
124 #override 124 #override
125 def _GetTestName(self, test): 125 def _GetTestName(self, test):
126 return '%s#%s' % (test['class'], test['method']) 126 return '%s#%s' % (test['class'], test['method'])
127 127
128 #override 128 #override
129 def _RunTest(self, device, test): 129 def _RunTest(self, device, test):
130 test_name = self._GetTestName(test) 130 extras = self._test_instance.GetHttpServerEnvironmentVars()
131
132 if isinstance(test, list):
133 if not self._test_instance.driver_apk:
134 raise Exception('driver_apk does not exist. '
135 'Please build it and try again.')
136
137 def name_and_timeout(t):
138 n = self._GetTestName(t)
139 i = self._GetTimeoutFromAnnotations(t['annotations'], n)
140 return (n, i)
141
142 test_names, timeouts = zip(*(name_and_timeout(t) for t in test))
143
144 test_name = ','.join(test_names)
145 target = '%s/%s' % (
146 self._test_instance.driver_package,
147 self._test_instance.driver_name)
148 extras.update(
149 self._test_instance.GetDriverEnvironmentVars(
150 test_list=test_names))
151 timeout = sum(timeouts)
152 else:
153 test_name = self._GetTestName(test)
154 target = '%s/%s' % (
155 self._test_instance.test_package, self._test_instance.test_runner)
156 extras['class'] = test_name
157 timeout = self._GetTimeoutFromAnnotations(test['annotations'], test_name)
158
131 logging.info('preparing to run %s: %s' % (test_name, test)) 159 logging.info('preparing to run %s: %s' % (test_name, test))
132 160
133 extras = {
134 'class': test_name,
135 'org.chromium.chrome.test.ChromeInstrumentationTestRunner'
136 '.EnableTestHttpServer': '',
137 }
138 timeout = self._GetTimeoutFromAnnotations(test['annotations'], test_name)
139
140 time_ms = lambda: int(time.time() * 1e3) 161 time_ms = lambda: int(time.time() * 1e3)
141 start_ms = time_ms() 162 start_ms = time_ms()
142 output = device.StartInstrumentation( 163 output = device.StartInstrumentation(
143 '%s/%s' % (self._test_instance.test_package, 164 target, raw=True, extras=extras, timeout=timeout, retries=0)
144 self._test_instance.test_runner),
145 raw=True, extras=extras, timeout=timeout, retries=0)
146 duration_ms = time_ms() - start_ms 165 duration_ms = time_ms() - start_ms
147 166
148 # TODO(jbudorick): Make instrumentation tests output a JSON so this 167 # TODO(jbudorick): Make instrumentation tests output a JSON so this
149 # doesn't have to parse the output. 168 # doesn't have to parse the output.
150 logging.debug('output from %s:', test_name) 169 logging.debug('output from %s:', test_name)
151 for l in output: 170 for l in output:
152 logging.debug(' %s', l) 171 logging.debug(' %s', l)
153 172
154 result_code, result_bundle, statuses = ( 173 result_code, result_bundle, statuses = (
155 self._test_instance.ParseAmInstrumentRawOutput(output)) 174 self._test_instance.ParseAmInstrumentRawOutput(output))
(...skipping 20 matching lines...) Expand all
176 195
177 try: 196 try:
178 scale = int(annotations.get('TimeoutScale', 1)) 197 scale = int(annotations.get('TimeoutScale', 1))
179 except ValueError as e: 198 except ValueError as e:
180 logging.warning("Non-integer value of TimeoutScale ignored. (%s)", str(e)) 199 logging.warning("Non-integer value of TimeoutScale ignored. (%s)", str(e))
181 scale = 1 200 scale = 1
182 timeout *= scale 201 timeout *= scale
183 202
184 return timeout 203 return timeout
185 204
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698