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

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

Issue 2542333002: (Reland) Insert logcat as part of test result for android instrumentation tests. (Closed)
Patch Set: added ignore too broad exception warning Created 4 years 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.android import logdog_logcat_monitor
15 from pylib.base import base_test_result 16 from pylib.base import base_test_result
16 from pylib.instrumentation import instrumentation_test_instance 17 from pylib.instrumentation import instrumentation_test_instance
17 from pylib.local.device import local_device_environment 18 from pylib.local.device import local_device_environment
18 from pylib.local.device import local_device_test_run 19 from pylib.local.device import local_device_test_run
19 import tombstones 20 import tombstones
20 21
21
22 _TAG = 'test_runner_py' 22 _TAG = 'test_runner_py'
23 23
24 TIMEOUT_ANNOTATIONS = [ 24 TIMEOUT_ANNOTATIONS = [
25 ('Manual', 10 * 60 * 60), 25 ('Manual', 10 * 60 * 60),
26 ('IntegrationTest', 30 * 60), 26 ('IntegrationTest', 30 * 60),
27 ('External', 10 * 60), 27 ('External', 10 * 60),
28 ('EnormousTest', 10 * 60), 28 ('EnormousTest', 10 * 60),
29 ('LargeTest', 5 * 60), 29 ('LargeTest', 5 * 60),
30 ('MediumTest', 3 * 60), 30 ('MediumTest', 3 * 60),
31 ('SmallTest', 1 * 60), 31 ('SmallTest', 1 * 60),
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 238
239 if flags: 239 if flags:
240 self._CreateFlagChangerIfNeeded(device) 240 self._CreateFlagChangerIfNeeded(device)
241 self._flag_changers[str(device)].PushFlags( 241 self._flag_changers[str(device)].PushFlags(
242 add=flags.add, remove=flags.remove) 242 add=flags.add, remove=flags.remove)
243 243
244 try: 244 try:
245 device.RunShellCommand( 245 device.RunShellCommand(
246 ['log', '-p', 'i', '-t', _TAG, 'START %s' % test_name], 246 ['log', '-p', 'i', '-t', _TAG, 'START %s' % test_name],
247 check_return=True) 247 check_return=True)
248 logcat_url = None
248 time_ms = lambda: int(time.time() * 1e3) 249 time_ms = lambda: int(time.time() * 1e3)
249 start_ms = time_ms() 250 start_ms = time_ms()
250 output = device.StartInstrumentation( 251 if self._test_instance.should_save_logcat:
251 target, raw=True, extras=extras, timeout=timeout, retries=0) 252 stream_name = 'logcat_%s_%s' % (
jbudorick 2016/12/01 23:42:11 Mentioned offline: include the device serial in th
BigBossZhiling 2016/12/01 23:53:59 Done.
253 test_name.replace('#', '.'),
254 time.strftime('%Y%m%dT%H%M%S', time.localtime()))
255 with logdog_logcat_monitor.LogdogLogcatMonitor(
256 device.adb, stream_name) as logmon:
257 output = device.StartInstrumentation(
258 target, raw=True, extras=extras, timeout=timeout, retries=0)
259 logcat_url = logmon.GetLogcatURL()
260 else:
261 output = device.StartInstrumentation(
262 target, raw=True, extras=extras, timeout=timeout, retries=0)
252 finally: 263 finally:
253 device.RunShellCommand( 264 device.RunShellCommand(
254 ['log', '-p', 'i', '-t', _TAG, 'END %s' % test_name], 265 ['log', '-p', 'i', '-t', _TAG, 'END %s' % test_name],
255 check_return=True) 266 check_return=True)
256 duration_ms = time_ms() - start_ms 267 duration_ms = time_ms() - start_ms
257 if flags: 268 if flags:
258 self._flag_changers[str(device)].Restore() 269 self._flag_changers[str(device)].Restore()
259 if test_timeout_scale: 270 if test_timeout_scale:
260 valgrind_tools.SetChromeTimeoutScale( 271 valgrind_tools.SetChromeTimeoutScale(
261 device, self._test_instance.timeout_scale) 272 device, self._test_instance.timeout_scale)
262 273
263 # TODO(jbudorick): Make instrumentation tests output a JSON so this 274 # TODO(jbudorick): Make instrumentation tests output a JSON so this
264 # doesn't have to parse the output. 275 # doesn't have to parse the output.
265 result_code, result_bundle, statuses = ( 276 result_code, result_bundle, statuses = (
266 self._test_instance.ParseAmInstrumentRawOutput(output)) 277 self._test_instance.ParseAmInstrumentRawOutput(output))
267 results = self._test_instance.GenerateTestResults( 278 results = self._test_instance.GenerateTestResults(
268 result_code, result_bundle, statuses, start_ms, duration_ms) 279 result_code, result_bundle, statuses, start_ms, duration_ms)
280 for result in results:
281 result.SetLogcatUrl(logcat_url)
269 282
270 # Update the result name if the test used flags. 283 # Update the result name if the test used flags.
271 if flags: 284 if flags:
272 for r in results: 285 for r in results:
273 if r.GetName() == test_name: 286 if r.GetName() == test_name:
274 r.SetName(test_display_name) 287 r.SetName(test_display_name)
275 288
276 # Add UNKNOWN results for any missing tests. 289 # Add UNKNOWN results for any missing tests.
277 iterable_test = test if isinstance(test, list) else [test] 290 iterable_test = test if isinstance(test, list) else [test]
278 test_names = set(self._GetUniqueTestName(t) for t in iterable_test) 291 test_names = set(self._GetUniqueTestName(t) for t in iterable_test)
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 timeout = v 379 timeout = v
367 break 380 break
368 else: 381 else:
369 logging.warning('Using default 1 minute timeout for %s', test_name) 382 logging.warning('Using default 1 minute timeout for %s', test_name)
370 timeout = 60 383 timeout = 60
371 384
372 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) 385 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations)
373 386
374 return timeout 387 return timeout
375 388
OLDNEW
« no previous file with comments | « build/android/pylib/instrumentation/instrumentation_test_instance.py ('k') | build/android/pylib/results/json_results.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698