Chromium Code Reviews| 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 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 import logcat_monitor_using_logdog | |
| 15 from pylib.base import base_test_result | 16 from pylib.base import base_test_result |
| 16 from pylib.local.device import local_device_environment | 17 from pylib.local.device import local_device_environment |
| 17 from pylib.local.device import local_device_test_run | 18 from pylib.local.device import local_device_test_run |
| 18 import tombstones | 19 import tombstones |
| 19 | 20 |
| 20 | 21 |
| 21 _TAG = 'test_runner_py' | 22 _TAG = 'test_runner_py' |
| 22 | 23 |
| 23 TIMEOUT_ANNOTATIONS = [ | 24 TIMEOUT_ANNOTATIONS = [ |
| 24 ('Manual', 10 * 60 * 60), | 25 ('Manual', 10 * 60 * 60), |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 | 255 |
| 255 if flags: | 256 if flags: |
| 256 self._CreateFlagChangerIfNeeded(device) | 257 self._CreateFlagChangerIfNeeded(device) |
| 257 self._flag_changers[str(device)].PushFlags( | 258 self._flag_changers[str(device)].PushFlags( |
| 258 add=flags.add, remove=flags.remove) | 259 add=flags.add, remove=flags.remove) |
| 259 | 260 |
| 260 try: | 261 try: |
| 261 device.RunShellCommand( | 262 device.RunShellCommand( |
| 262 ['log', '-p', 'i', '-t', _TAG, 'START %s' % test_name], | 263 ['log', '-p', 'i', '-t', _TAG, 'START %s' % test_name], |
| 263 check_return=True) | 264 check_return=True) |
| 265 logcat = None | |
| 264 time_ms = lambda: int(time.time() * 1e3) | 266 time_ms = lambda: int(time.time() * 1e3) |
| 265 start_ms = time_ms() | 267 start_ms = time_ms() |
| 266 output = device.StartInstrumentation( | 268 with logcat_monitor_using_logdog.LogcatMonitorUsingLogdog(device.adb, |
|
jbudorick
2016/11/18 02:31:42
This should totally be something like "LogcatdogMo
BigBossZhiling
2016/11/22 02:54:37
Done.
| |
| 267 target, raw=True, extras=extras, timeout=timeout, retries=0) | 269 'logcat_%s' % test_name.replace('#', '.')) as logmon: |
| 270 output = device.StartInstrumentation( | |
| 271 target, raw=True, extras=extras, timeout=timeout, retries=0) | |
| 272 logcat = logmon.GetLogcatURL() | |
| 273 logmon.Close() | |
| 268 finally: | 274 finally: |
| 269 device.RunShellCommand( | 275 device.RunShellCommand( |
| 270 ['log', '-p', 'i', '-t', _TAG, 'END %s' % test_name], | 276 ['log', '-p', 'i', '-t', _TAG, 'END %s' % test_name], |
| 271 check_return=True) | 277 check_return=True) |
| 272 duration_ms = time_ms() - start_ms | 278 duration_ms = time_ms() - start_ms |
| 273 if flags: | 279 if flags: |
| 274 self._flag_changers[str(device)].Restore() | 280 self._flag_changers[str(device)].Restore() |
| 275 if test_timeout_scale: | 281 if test_timeout_scale: |
| 276 valgrind_tools.SetChromeTimeoutScale( | 282 valgrind_tools.SetChromeTimeoutScale( |
| 277 device, self._test_instance.timeout_scale) | 283 device, self._test_instance.timeout_scale) |
| 278 | 284 |
| 279 # TODO(jbudorick): Make instrumentation tests output a JSON so this | 285 # TODO(jbudorick): Make instrumentation tests output a JSON so this |
| 280 # doesn't have to parse the output. | 286 # doesn't have to parse the output. |
| 281 result_code, result_bundle, statuses = ( | 287 result_code, result_bundle, statuses = ( |
| 282 self._test_instance.ParseAmInstrumentRawOutput(output)) | 288 self._test_instance.ParseAmInstrumentRawOutput(output)) |
| 283 results = self._test_instance.GenerateTestResults( | 289 results = self._test_instance.GenerateTestResults( |
| 284 result_code, result_bundle, statuses, start_ms, duration_ms) | 290 result_code, result_bundle, statuses, start_ms, duration_ms) |
| 291 for result in results: | |
| 292 result.SetLogcat(logcat) | |
| 285 | 293 |
| 286 # Update the result name if the test used flags. | 294 # Update the result name if the test used flags. |
| 287 if flags: | 295 if flags: |
| 288 for r in results: | 296 for r in results: |
| 289 if r.GetName() == test_name: | 297 if r.GetName() == test_name: |
| 290 r.SetName(test_display_name) | 298 r.SetName(test_display_name) |
| 291 | 299 |
| 292 # Add UNKNOWN results for any missing tests. | 300 # Add UNKNOWN results for any missing tests. |
| 293 iterable_test = test if isinstance(test, list) else [test] | 301 iterable_test = test if isinstance(test, list) else [test] |
| 294 test_names = set(self._GetUniqueTestName(t) for t in iterable_test) | 302 test_names = set(self._GetUniqueTestName(t) for t in iterable_test) |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 timeout = v | 388 timeout = v |
| 381 break | 389 break |
| 382 else: | 390 else: |
| 383 logging.warning('Using default 1 minute timeout for %s', test_name) | 391 logging.warning('Using default 1 minute timeout for %s', test_name) |
| 384 timeout = 60 | 392 timeout = 60 |
| 385 | 393 |
| 386 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) | 394 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) |
| 387 | 395 |
| 388 return timeout | 396 return timeout |
| 389 | 397 |
| OLD | NEW |