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

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: cjhopman comment 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 #override 123 #override
124 def _GetTests(self): 124 def _GetTests(self):
125 return self._test_instance.GetTests() 125 return self._test_instance.GetTests()
126 126
127 #override 127 #override
128 def _GetTestName(self, test): 128 def _GetTestName(self, test):
129 return '%s#%s' % (test['class'], test['method']) 129 return '%s#%s' % (test['class'], test['method'])
130 130
131 #override 131 #override
132 def _RunTest(self, device, test): 132 def _RunTest(self, device, test):
133 test_name = self._GetTestName(test) 133 extras = self._test_instance.GetHttpServerEnvironmentVars()
134
135 if isinstance(test, list):
136 if not self._test_instance.driver_apk:
137 raise Exception('driver_apk does not exist. '
138 'Please build it and try again.')
139
140 def name_and_timeout(t):
141 n = self._GetTestName(t)
142 i = self._GetTimeoutFromAnnotations(t['annotations'], n)
143 return (n, i)
144
145 test_names, timeouts = zip(*(name_and_timeout(t) for t in test))
146
147 test_name = ','.join(test_names)
148 target = '%s/%s' % (
149 self._test_instance.driver_package,
150 self._test_instance.driver_name)
151 extras.update(
152 self._test_instance.GetDriverEnvironmentVars(
153 test_list=test_names))
154 timeout = sum(timeouts)
155 else:
156 test_name = self._GetTestName(test)
157 target = '%s/%s' % (
158 self._test_instance.test_package, self._test_instance.test_runner)
159 extras['class'] = test_name
160 timeout = self._GetTimeoutFromAnnotations(test['annotations'], test_name)
161
134 logging.info('preparing to run %s: %s' % (test_name, test)) 162 logging.info('preparing to run %s: %s' % (test_name, test))
135 163
136 extras = {
137 'class': test_name,
138 'org.chromium.chrome.test.ChromeInstrumentationTestRunner'
139 '.EnableTestHttpServer': '',
140 }
141 timeout = self._GetTimeoutFromAnnotations(test['annotations'], test_name)
142
143 time_ms = lambda: int(time.time() * 1e3) 164 time_ms = lambda: int(time.time() * 1e3)
144 start_ms = time_ms() 165 start_ms = time_ms()
145 output = device.StartInstrumentation( 166 output = device.StartInstrumentation(
146 '%s/%s' % (self._test_instance.test_package, 167 target, raw=True, extras=extras, timeout=timeout, retries=0)
147 self._test_instance.test_runner),
148 raw=True, extras=extras, timeout=timeout, retries=0)
149 duration_ms = time_ms() - start_ms 168 duration_ms = time_ms() - start_ms
150 169
151 # TODO(jbudorick): Make instrumentation tests output a JSON so this 170 # TODO(jbudorick): Make instrumentation tests output a JSON so this
152 # doesn't have to parse the output. 171 # doesn't have to parse the output.
153 logging.debug('output from %s:', test_name) 172 logging.debug('output from %s:', test_name)
154 for l in output: 173 for l in output:
155 logging.debug(' %s', l) 174 logging.debug(' %s', l)
156 175
157 result_code, result_bundle, statuses = ( 176 result_code, result_bundle, statuses = (
158 self._test_instance.ParseAmInstrumentRawOutput(output)) 177 self._test_instance.ParseAmInstrumentRawOutput(output))
(...skipping 20 matching lines...) Expand all
179 198
180 try: 199 try:
181 scale = int(annotations.get('TimeoutScale', 1)) 200 scale = int(annotations.get('TimeoutScale', 1))
182 except ValueError as e: 201 except ValueError as e:
183 logging.warning("Non-integer value of TimeoutScale ignored. (%s)", str(e)) 202 logging.warning("Non-integer value of TimeoutScale ignored. (%s)", str(e))
184 scale = 1 203 scale = 1
185 timeout *= scale 204 timeout *= scale
186 205
187 return timeout 206 return timeout
188 207
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698