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

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

Issue 2545653002: (Reland) Insert logcat as part of test result for android instrumentation tests. (Closed)
Patch Set: add more exceptions 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 with logdog_logcat_monitor.LogdogLogcatMonitor(
253 device.adb,
254 'logcat_%s' % test_name.replace('#', '.')) as logmon:
255 output = device.StartInstrumentation(
256 target, raw=True, extras=extras, timeout=timeout, retries=0)
257 logcat_url = logmon.GetLogcatURL()
258 else:
259 output = device.StartInstrumentation(
260 target, raw=True, extras=extras, timeout=timeout, retries=0)
252 finally: 261 finally:
253 device.RunShellCommand( 262 device.RunShellCommand(
254 ['log', '-p', 'i', '-t', _TAG, 'END %s' % test_name], 263 ['log', '-p', 'i', '-t', _TAG, 'END %s' % test_name],
255 check_return=True) 264 check_return=True)
256 duration_ms = time_ms() - start_ms 265 duration_ms = time_ms() - start_ms
257 if flags: 266 if flags:
258 self._flag_changers[str(device)].Restore() 267 self._flag_changers[str(device)].Restore()
259 if test_timeout_scale: 268 if test_timeout_scale:
260 valgrind_tools.SetChromeTimeoutScale( 269 valgrind_tools.SetChromeTimeoutScale(
261 device, self._test_instance.timeout_scale) 270 device, self._test_instance.timeout_scale)
262 271
263 # TODO(jbudorick): Make instrumentation tests output a JSON so this 272 # TODO(jbudorick): Make instrumentation tests output a JSON so this
264 # doesn't have to parse the output. 273 # doesn't have to parse the output.
265 result_code, result_bundle, statuses = ( 274 result_code, result_bundle, statuses = (
266 self._test_instance.ParseAmInstrumentRawOutput(output)) 275 self._test_instance.ParseAmInstrumentRawOutput(output))
267 results = self._test_instance.GenerateTestResults( 276 results = self._test_instance.GenerateTestResults(
268 result_code, result_bundle, statuses, start_ms, duration_ms) 277 result_code, result_bundle, statuses, start_ms, duration_ms)
278 for result in results:
279 result.SetLogcatUrl(logcat_url)
269 280
270 # Update the result name if the test used flags. 281 # Update the result name if the test used flags.
271 if flags: 282 if flags:
272 for r in results: 283 for r in results:
273 if r.GetName() == test_name: 284 if r.GetName() == test_name:
274 r.SetName(test_display_name) 285 r.SetName(test_display_name)
275 286
276 # Add UNKNOWN results for any missing tests. 287 # Add UNKNOWN results for any missing tests.
277 iterable_test = test if isinstance(test, list) else [test] 288 iterable_test = test if isinstance(test, list) else [test]
278 test_names = set(self._GetUniqueTestName(t) for t in iterable_test) 289 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 377 timeout = v
367 break 378 break
368 else: 379 else:
369 logging.warning('Using default 1 minute timeout for %s', test_name) 380 logging.warning('Using default 1 minute timeout for %s', test_name)
370 timeout = 60 381 timeout = 60
371 382
372 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) 383 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations)
373 384
374 return timeout 385 return timeout
375 386
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