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 |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 self._CreateFlagChangerIfNeeded(device) | 256 self._CreateFlagChangerIfNeeded(device) |
| 257 self._flag_changers[str(device)].PushFlags( | 257 self._flag_changers[str(device)].PushFlags( |
| 258 add=flags.add, remove=flags.remove) | 258 add=flags.add, remove=flags.remove) |
| 259 | 259 |
| 260 try: | 260 try: |
| 261 device.RunShellCommand( | 261 device.RunShellCommand( |
| 262 ['log', '-p', 'i', '-t', _TAG, 'START %s' % test_name], | 262 ['log', '-p', 'i', '-t', _TAG, 'START %s' % test_name], |
| 263 check_return=True) | 263 check_return=True) |
| 264 time_ms = lambda: int(time.time() * 1e3) | 264 time_ms = lambda: int(time.time() * 1e3) |
| 265 start_ms = time_ms() | 265 start_ms = time_ms() |
| 266 output = device.StartInstrumentation( | 266 logcat = '' |
| 267 target, raw=True, extras=extras, timeout=timeout, retries=0) | 267 with device.GetLogcatMonitor() as logmon: |
| 268 output = device.StartInstrumentation( | |
| 269 target, raw=True, extras=extras, timeout=timeout, retries=0) | |
| 270 for logstring in logmon.FindAll(r'.*'): | |
|
jbudorick
2016/10/25 02:17:35
There are a couple of better options for dumping t
BigBossZhiling
2016/10/25 22:08:44
Done.
| |
| 271 logcat += logstring.group(0) + '\n' | |
| 272 logmon.Close() | |
| 268 finally: | 273 finally: |
| 269 device.RunShellCommand( | 274 device.RunShellCommand( |
| 270 ['log', '-p', 'i', '-t', _TAG, 'END %s' % test_name], | 275 ['log', '-p', 'i', '-t', _TAG, 'END %s' % test_name], |
| 271 check_return=True) | 276 check_return=True) |
| 272 duration_ms = time_ms() - start_ms | 277 duration_ms = time_ms() - start_ms |
| 273 if flags: | 278 if flags: |
| 274 self._flag_changers[str(device)].Restore() | 279 self._flag_changers[str(device)].Restore() |
| 275 if test_timeout_scale: | 280 if test_timeout_scale: |
| 276 valgrind_tools.SetChromeTimeoutScale( | 281 valgrind_tools.SetChromeTimeoutScale( |
| 277 device, self._test_instance.timeout_scale) | 282 device, self._test_instance.timeout_scale) |
| 278 | 283 |
| 279 # TODO(jbudorick): Make instrumentation tests output a JSON so this | 284 # TODO(jbudorick): Make instrumentation tests output a JSON so this |
| 280 # doesn't have to parse the output. | 285 # doesn't have to parse the output. |
| 281 result_code, result_bundle, statuses = ( | 286 result_code, result_bundle, statuses = ( |
| 282 self._test_instance.ParseAmInstrumentRawOutput(output)) | 287 self._test_instance.ParseAmInstrumentRawOutput(output)) |
| 283 results = self._test_instance.GenerateTestResults( | 288 results = self._test_instance.GenerateTestResults( |
| 284 result_code, result_bundle, statuses, start_ms, duration_ms) | 289 result_code, result_bundle, statuses, start_ms, duration_ms, logcat) |
| 285 | 290 |
| 286 # Update the result name if the test used flags. | 291 # Update the result name if the test used flags. |
| 287 if flags: | 292 if flags: |
| 288 for r in results: | 293 for r in results: |
| 289 if r.GetName() == test_name: | 294 if r.GetName() == test_name: |
| 290 r.SetName(test_display_name) | 295 r.SetName(test_display_name) |
| 291 | 296 |
| 292 # Add UNKNOWN results for any missing tests. | 297 # Add UNKNOWN results for any missing tests. |
| 293 iterable_test = test if isinstance(test, list) else [test] | 298 iterable_test = test if isinstance(test, list) else [test] |
| 294 test_names = set(self._GetUniqueTestName(t) for t in iterable_test) | 299 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 | 385 timeout = v |
| 381 break | 386 break |
| 382 else: | 387 else: |
| 383 logging.warning('Using default 1 minute timeout for %s', test_name) | 388 logging.warning('Using default 1 minute timeout for %s', test_name) |
| 384 timeout = 60 | 389 timeout = 60 |
| 385 | 390 |
| 386 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) | 391 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) |
| 387 | 392 |
| 388 return timeout | 393 return timeout |
| 389 | 394 |
| OLD | NEW |