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

Unified Diff: build/android/pylib/local/device/local_device_instrumentation_test_run.py

Issue 2451523002: Insert logcat as part of test result for android instrumentation tests. (Closed)
Patch Set: added the newly added file 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 side-by-side diff with in-line comments
Download patch
Index: build/android/pylib/local/device/local_device_instrumentation_test_run.py
diff --git a/build/android/pylib/local/device/local_device_instrumentation_test_run.py b/build/android/pylib/local/device/local_device_instrumentation_test_run.py
index a203ce069e5bc4760c2a84be3808e1aae3fb94f6..fdf2051841a7d895582aebfa3091adb4d3e1098f 100644
--- a/build/android/pylib/local/device/local_device_instrumentation_test_run.py
+++ b/build/android/pylib/local/device/local_device_instrumentation_test_run.py
@@ -6,11 +6,13 @@ import logging
import os
import posixpath
import re
+import sys
import time
from devil.android import device_errors
from devil.android import flag_changer
from devil.utils import reraiser_thread
+from pylib import constants
from pylib import valgrind_tools
from pylib.base import base_test_result
from pylib.instrumentation import instrumentation_test_instance
@@ -19,6 +21,10 @@ from pylib.local.device import local_device_test_run
import tombstones
+sys.path.append(os.path.abspath(os.path.join(
+ constants.DIR_SOURCE_ROOT, 'build', 'android', 'pylib', 'android')))
jbudorick 2016/11/22 14:40:15 You shouldn't need to do this.
BigBossZhiling 2016/11/23 00:28:07 Done.
+import logcat_monitor_with_logdog
jbudorick 2016/11/22 14:40:14 You should be able to import this as from pylib
BigBossZhiling 2016/11/23 00:28:07 Done.
+
_TAG = 'test_runner_py'
TIMEOUT_ANNOTATIONS = [
@@ -245,10 +251,16 @@ class LocalDeviceInstrumentationTestRun(
device.RunShellCommand(
['log', '-p', 'i', '-t', _TAG, 'START %s' % test_name],
check_return=True)
+ logcat_url = None
time_ms = lambda: int(time.time() * 1e3)
start_ms = time_ms()
- output = device.StartInstrumentation(
- target, raw=True, extras=extras, timeout=timeout, retries=0)
+ with logcat_monitor_with_logdog.LogcatMonitorWithLogdog(
jbudorick 2016/11/22 14:40:14 I'm concerned about always doing this, particularl
BigBossZhiling 2016/11/23 00:28:07 Done.
+ device.adb,
+ 'logcat_%s' % test_name.replace('#', '.')) as logmon:
+ output = device.StartInstrumentation(
+ target, raw=True, extras=extras, timeout=timeout, retries=0)
+ logcat_url = logmon.GetLogcatURL()
+ logmon.Close()
finally:
device.RunShellCommand(
['log', '-p', 'i', '-t', _TAG, 'END %s' % test_name],
@@ -266,6 +278,8 @@ class LocalDeviceInstrumentationTestRun(
self._test_instance.ParseAmInstrumentRawOutput(output))
results = self._test_instance.GenerateTestResults(
result_code, result_bundle, statuses, start_ms, duration_ms)
+ for result in results:
+ result.SetLogcatUrl(logcat_url)
# Update the result name if the test used flags.
if flags:

Powered by Google App Engine
This is Rietveld 408576698