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

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

Issue 1964183003: Fixed coverage dir for instrumentation tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 4 years, 7 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 os
6 import re 7 import re
7 import time 8 import time
8 9
9 from devil.android import device_errors 10 from devil.android import device_errors
10 from devil.android import flag_changer 11 from devil.android import flag_changer
11 from devil.utils import reraiser_thread 12 from devil.utils import reraiser_thread
12 from pylib import valgrind_tools 13 from pylib import valgrind_tools
13 from pylib.base import base_test_result 14 from pylib.base import base_test_result
14 from pylib.local.device import local_device_test_run 15 from pylib.local.device import local_device_test_run
15 16
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 if flags.remove: 180 if flags.remove:
180 display_name = '%s without {%s}' % (display_name, ' '.join(flags.remove)) 181 display_name = '%s without {%s}' % (display_name, ' '.join(flags.remove))
181 return display_name 182 return display_name
182 183
183 #override 184 #override
184 def _RunTest(self, device, test): 185 def _RunTest(self, device, test):
185 extras = {} 186 extras = {}
186 187
187 flags = None 188 flags = None
188 test_timeout_scale = None 189 test_timeout_scale = None
190 if self._test_instance.coverage_directory:
191 coverage_basename = '%s.ec' % ('%s_group' % test[0]['method']
192 if isinstance(test, list) else test['method'])
193 extras['coverage'] = 'true'
194 coverage_directory = os.path.join(
195 device.GetExternalStoragePath(), 'chrome', 'test', 'coverage')
196 coverage_device_file = os.path.join(
197 coverage_directory, coverage_basename)
198 extras['coverageFile'] = coverage_device_file
199
189 if isinstance(test, list): 200 if isinstance(test, list):
190 if not self._test_instance.driver_apk: 201 if not self._test_instance.driver_apk:
191 raise Exception('driver_apk does not exist. ' 202 raise Exception('driver_apk does not exist. '
192 'Please build it and try again.') 203 'Please build it and try again.')
193 204
194 def name_and_timeout(t): 205 def name_and_timeout(t):
195 n = self._GetTestName(t) 206 n = self._GetTestName(t)
196 i = self._GetTimeoutFromAnnotations(t['annotations'], n) 207 i = self._GetTimeoutFromAnnotations(t['annotations'], n)
197 return (n, i) 208 return (n, i)
198 209
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 self._test_instance.apk_under_test.GetPermissions() 283 self._test_instance.apk_under_test.GetPermissions()
273 if self._test_instance.apk_under_test 284 if self._test_instance.apk_under_test
274 else None) 285 else None)
275 device.ClearApplicationState(self._test_instance.package_info.package, 286 device.ClearApplicationState(self._test_instance.package_info.package,
276 permissions=permissions) 287 permissions=permissions)
277 288
278 else: 289 else:
279 logging.debug('raw output from %s:', test_display_name) 290 logging.debug('raw output from %s:', test_display_name)
280 for l in output: 291 for l in output:
281 logging.debug(' %s', l) 292 logging.debug(' %s', l)
282 293 if self._test_instance.coverage_directory:
294 device.PullFile(coverage_directory,
295 self._test_instance.coverage_directory)
296 device.RunShellCommand('rm -f %s' % os.path.join(coverage_directory,
297 '*'))
283 return results 298 return results
284 299
285 #override 300 #override
286 def _ShouldShard(self): 301 def _ShouldShard(self):
287 return True 302 return True
288 303
289 @classmethod 304 @classmethod
290 def _GetTimeoutScaleFromAnnotations(cls, annotations): 305 def _GetTimeoutScaleFromAnnotations(cls, annotations):
291 try: 306 try:
292 return int(annotations.get('TimeoutScale', 1)) 307 return int(annotations.get('TimeoutScale', 1))
293 except ValueError as e: 308 except ValueError as e:
294 logging.warning("Non-integer value of TimeoutScale ignored. (%s)", str(e)) 309 logging.warning("Non-integer value of TimeoutScale ignored. (%s)", str(e))
295 return 1 310 return 1
296 311
297 @classmethod 312 @classmethod
298 def _GetTimeoutFromAnnotations(cls, annotations, test_name): 313 def _GetTimeoutFromAnnotations(cls, annotations, test_name):
299 for k, v in TIMEOUT_ANNOTATIONS: 314 for k, v in TIMEOUT_ANNOTATIONS:
300 if k in annotations: 315 if k in annotations:
301 timeout = v 316 timeout = v
302 break 317 break
303 else: 318 else:
304 logging.warning('Using default 1 minute timeout for %s', test_name) 319 logging.warning('Using default 1 minute timeout for %s', test_name)
305 timeout = 60 320 timeout = 60
306 321
307 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) 322 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations)
308 323
309 return timeout 324 return timeout
310 325
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698