Chromium Code Reviews| 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 6c00b7087dc9f5c44aeabdc2ca2abe8a17c0174c..202f612391565bee0b37a915ad25e5a257d003c7 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 |
| @@ -263,8 +263,13 @@ class LocalDeviceInstrumentationTestRun( |
| check_return=True) |
| time_ms = lambda: int(time.time() * 1e3) |
| start_ms = time_ms() |
| - output = device.StartInstrumentation( |
| - target, raw=True, extras=extras, timeout=timeout, retries=0) |
| + output_file = '/tmp/logcat/%s' % test_name |
|
jbudorick
2016/10/25 22:11:33
Use tempfile.NamedTemporaryFile as a context manag
|
| + with device.GetLogcatMonitor(output_file=output_file) as logmon: |
| + output = device.StartInstrumentation( |
| + target, raw=True, extras=extras, timeout=timeout, retries=0) |
| + logmon.Close() |
| + logcat = open(output_file, 'r').read() |
| + os.remove(output_file) |
| finally: |
| device.RunShellCommand( |
| ['log', '-p', 'i', '-t', _TAG, 'END %s' % test_name], |
| @@ -282,6 +287,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.SetLogcat(logcat) |
| # Update the result name if the test used flags. |
| if flags: |