OLD | NEW |
---|---|
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 Loading... | |
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 | |
191 if self._test_instance.CoverageDirectory(): | |
192 coverage_basename = '%s.ec' % test['method'] | |
mikecase (-- gone --)
2016/05/11 17:39:58
This will crash if test is a list, which I think i
BigBossZhiling
2016/05/20 18:38:08
Done.
| |
193 extras['coverage'] = 'true' | |
194 coverage_device_file = '%s/%s/%s' % ( | |
195 device.GetExternalStoragePath(), 'chrome/test/coverage', | |
196 coverage_basename) | |
mikecase (-- gone --)
2016/05/11 17:39:58
This indentation is a bit off. Probably do somethi
jbudorick
2016/05/17 00:07:33
This should instead be:
coverage_device_file =
BigBossZhiling
2016/05/20 18:38:09
Done.
| |
197 coverage_host_file = os.path.join( | |
198 self._test_instance.CoverageDirectory(), coverage_basename) | |
199 extras['coverageFile'] = coverage_device_file | |
200 | |
189 if isinstance(test, list): | 201 if isinstance(test, list): |
jbudorick
2016/05/17 00:07:33
yes, test can be a list.
BigBossZhiling
2016/05/20 18:38:08
Done.
| |
190 if not self._test_instance.driver_apk: | 202 if not self._test_instance.driver_apk: |
191 raise Exception('driver_apk does not exist. ' | 203 raise Exception('driver_apk does not exist. ' |
192 'Please build it and try again.') | 204 'Please build it and try again.') |
193 | 205 |
194 def name_and_timeout(t): | 206 def name_and_timeout(t): |
195 n = self._GetTestName(t) | 207 n = self._GetTestName(t) |
196 i = self._GetTimeoutFromAnnotations(t['annotations'], n) | 208 i = self._GetTimeoutFromAnnotations(t['annotations'], n) |
197 return (n, i) | 209 return (n, i) |
198 | 210 |
199 test_names, timeouts = zip(*(name_and_timeout(t) for t in test)) | 211 test_names, timeouts = zip(*(name_and_timeout(t) for t in test)) |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 for l in output: | 279 for l in output: |
268 logging.info(' %s', l) | 280 logging.info(' %s', l) |
269 if (not self._env.skip_clear_data | 281 if (not self._env.skip_clear_data |
270 and self._test_instance.package_info): | 282 and self._test_instance.package_info): |
271 device.ClearApplicationState(self._test_instance.package_info.package) | 283 device.ClearApplicationState(self._test_instance.package_info.package) |
272 else: | 284 else: |
273 logging.debug('raw output from %s:', test_display_name) | 285 logging.debug('raw output from %s:', test_display_name) |
274 for l in output: | 286 for l in output: |
275 logging.debug(' %s', l) | 287 logging.debug(' %s', l) |
276 | 288 |
289 if self._test_instance.CoverageDirectory(): | |
290 device.PullFile(coverage_device_file, coverage_host_file) | |
291 device.RunShellCommand('rm -f %s' % coverage_device_file) | |
mikecase (-- gone --)
2016/05/11 17:39:58
Might* be faster to pull all of the files at the e
BigBossZhiling
2016/05/20 18:38:08
I was thinking of collecting ec files after callin
| |
277 return results | 292 return results |
278 | 293 |
279 #override | 294 #override |
280 def _ShouldShard(self): | 295 def _ShouldShard(self): |
281 return True | 296 return True |
282 | 297 |
283 @classmethod | 298 @classmethod |
284 def _GetTimeoutScaleFromAnnotations(cls, annotations): | 299 def _GetTimeoutScaleFromAnnotations(cls, annotations): |
285 try: | 300 try: |
286 return int(annotations.get('TimeoutScale', 1)) | 301 return int(annotations.get('TimeoutScale', 1)) |
287 except ValueError as e: | 302 except ValueError as e: |
288 logging.warning("Non-integer value of TimeoutScale ignored. (%s)", str(e)) | 303 logging.warning("Non-integer value of TimeoutScale ignored. (%s)", str(e)) |
289 return 1 | 304 return 1 |
290 | 305 |
291 @classmethod | 306 @classmethod |
292 def _GetTimeoutFromAnnotations(cls, annotations, test_name): | 307 def _GetTimeoutFromAnnotations(cls, annotations, test_name): |
293 for k, v in TIMEOUT_ANNOTATIONS: | 308 for k, v in TIMEOUT_ANNOTATIONS: |
294 if k in annotations: | 309 if k in annotations: |
295 timeout = v | 310 timeout = v |
296 break | 311 break |
297 else: | 312 else: |
298 logging.warning('Using default 1 minute timeout for %s', test_name) | 313 logging.warning('Using default 1 minute timeout for %s', test_name) |
299 timeout = 60 | 314 timeout = 60 |
300 | 315 |
301 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) | 316 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) |
302 | 317 |
303 return timeout | 318 return timeout |
304 | 319 |
OLD | NEW |