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

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

Issue 2491373005: [Android] Fix instrumentation test filtering for parameterized tests. (Closed)
Patch Set: Created 4 years, 1 month 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 os 6 import os
7 import posixpath 7 import posixpath
8 import re 8 import re
9 import time 9 import time
10 10
11 from devil.android import device_errors 11 from devil.android import device_errors
12 from devil.android import flag_changer 12 from devil.android import flag_changer
13 from devil.utils import reraiser_thread 13 from devil.utils import reraiser_thread
14 from pylib import valgrind_tools 14 from pylib import valgrind_tools
15 from pylib.base import base_test_result 15 from pylib.base import base_test_result
16 from pylib.instrumentation import instrumentation_test_instance
16 from pylib.local.device import local_device_environment 17 from pylib.local.device import local_device_environment
17 from pylib.local.device import local_device_test_run 18 from pylib.local.device import local_device_test_run
18 import tombstones 19 import tombstones
19 20
20 21
21 _TAG = 'test_runner_py' 22 _TAG = 'test_runner_py'
22 23
23 TIMEOUT_ANNOTATIONS = [ 24 TIMEOUT_ANNOTATIONS = [
24 ('Manual', 10 * 60 * 60), 25 ('Manual', 10 * 60 * 60),
25 ('IntegrationTest', 30 * 60), 26 ('IntegrationTest', 30 * 60),
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 device, self._test_instance.package_info.cmdline_file) 174 device, self._test_instance.package_info.cmdline_file)
174 175
175 #override 176 #override
176 def _CreateShards(self, tests): 177 def _CreateShards(self, tests):
177 return tests 178 return tests
178 179
179 #override 180 #override
180 def _GetTests(self): 181 def _GetTests(self):
181 return self._test_instance.GetTests() 182 return self._test_instance.GetTests()
182 183
183 def _GetTestName(self, test):
184 # pylint: disable=no-self-use
185 return '%s#%s' % (test['class'], test['method'])
186
187 #override 184 #override
188 def _GetUniqueTestName(self, test): 185 def _GetUniqueTestName(self, test):
189 display_name = self._GetTestName(test) 186 return instrumentation_test_instance.GetUniqueTestName(test)
190 if 'flags' in test:
191 flags = test['flags']
192 if flags.add:
193 display_name = '%s with {%s}' % (display_name, ' '.join(flags.add))
194 if flags.remove:
195 display_name = '%s without {%s}' % (
196 display_name, ' '.join(flags.remove))
197 return display_name
198 187
199 #override 188 #override
200 def _RunTest(self, device, test): 189 def _RunTest(self, device, test):
201 extras = {} 190 extras = {}
202 191
203 flags = None 192 flags = None
204 test_timeout_scale = None 193 test_timeout_scale = None
205 if self._test_instance.coverage_directory: 194 if self._test_instance.coverage_directory:
206 coverage_basename = '%s.ec' % ('%s_group' % test[0]['method'] 195 coverage_basename = '%s.ec' % ('%s_group' % test[0]['method']
207 if isinstance(test, list) else test['method']) 196 if isinstance(test, list) else test['method'])
208 extras['coverage'] = 'true' 197 extras['coverage'] = 'true'
209 coverage_directory = os.path.join( 198 coverage_directory = os.path.join(
210 device.GetExternalStoragePath(), 'chrome', 'test', 'coverage') 199 device.GetExternalStoragePath(), 'chrome', 'test', 'coverage')
211 coverage_device_file = os.path.join( 200 coverage_device_file = os.path.join(
212 coverage_directory, coverage_basename) 201 coverage_directory, coverage_basename)
213 extras['coverageFile'] = coverage_device_file 202 extras['coverageFile'] = coverage_device_file
214 203
215 if isinstance(test, list): 204 if isinstance(test, list):
216 if not self._test_instance.driver_apk: 205 if not self._test_instance.driver_apk:
217 raise Exception('driver_apk does not exist. ' 206 raise Exception('driver_apk does not exist. '
218 'Please build it and try again.') 207 'Please build it and try again.')
219 208
220 def name_and_timeout(t): 209 def name_and_timeout(t):
221 n = self._GetTestName(t) 210 n = instrumentation_test_instance.GetTestName(t)
222 i = self._GetTimeoutFromAnnotations(t['annotations'], n) 211 i = self._GetTimeoutFromAnnotations(t['annotations'], n)
223 return (n, i) 212 return (n, i)
224 213
225 test_names, timeouts = zip(*(name_and_timeout(t) for t in test)) 214 test_names, timeouts = zip(*(name_and_timeout(t) for t in test))
226 215
227 test_name = ','.join(test_names) 216 test_name = ','.join(test_names)
228 test_display_name = test_name 217 test_display_name = test_name
229 target = '%s/%s' % ( 218 target = '%s/%s' % (
230 self._test_instance.driver_package, 219 self._test_instance.driver_package,
231 self._test_instance.driver_name) 220 self._test_instance.driver_name)
232 extras.update( 221 extras.update(
233 self._test_instance.GetDriverEnvironmentVars( 222 self._test_instance.GetDriverEnvironmentVars(
234 test_list=test_names)) 223 test_list=test_names))
235 timeout = sum(timeouts) 224 timeout = sum(timeouts)
236 else: 225 else:
237 test_name = self._GetTestName(test) 226 test_name = instrumentation_test_instance.GetTestName(test)
238 test_display_name = self._GetUniqueTestName(test) 227 test_display_name = self._GetUniqueTestName(test)
239 target = '%s/%s' % ( 228 target = '%s/%s' % (
240 self._test_instance.test_package, self._test_instance.test_runner) 229 self._test_instance.test_package, self._test_instance.test_runner)
241 extras['class'] = test_name 230 extras['class'] = test_name
242 if 'flags' in test: 231 if 'flags' in test:
243 flags = test['flags'] 232 flags = test['flags']
244 timeout = self._GetTimeoutFromAnnotations( 233 timeout = self._GetTimeoutFromAnnotations(
245 test['annotations'], test_display_name) 234 test['annotations'], test_display_name)
246 235
247 test_timeout_scale = self._GetTimeoutScaleFromAnnotations( 236 test_timeout_scale = self._GetTimeoutScaleFromAnnotations(
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 timeout = v 369 timeout = v
381 break 370 break
382 else: 371 else:
383 logging.warning('Using default 1 minute timeout for %s', test_name) 372 logging.warning('Using default 1 minute timeout for %s', test_name)
384 timeout = 60 373 timeout = 60
385 374
386 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) 375 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations)
387 376
388 return timeout 377 return timeout
389 378
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698