| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 """Run specific test on specific environment.""" | 5 """Run specific test on specific environment.""" |
| 6 | 6 |
| 7 import json | 7 import json |
| 8 import logging | 8 import logging |
| 9 import os | 9 import os |
| 10 import re | 10 import re |
| 11 import shutil | 11 import shutil |
| 12 import string | 12 import string |
| 13 import tempfile | 13 import tempfile |
| 14 import time | 14 import time |
| 15 import zipfile | 15 import zipfile |
| 16 | 16 |
| 17 | 17 |
| 18 from pylib.base import base_test_result | 18 from pylib.base import base_test_result |
| 19 from pylib.base import test_run | 19 from pylib.base import test_run |
| 20 from pylib.remote.device import appurify_constants | 20 from pylib.remote.device import appurify_constants |
| 21 from pylib.remote.device import appurify_sanitized | 21 from pylib.remote.device import appurify_sanitized |
| 22 from pylib.remote.device import remote_device_helper | 22 from pylib.remote.device import remote_device_helper |
| 23 from pylib.utils import zip_utils | 23 from pylib.utils import zip_utils |
| 24 | 24 |
| 25 _DEVICE_OFFLINE_RE = re.compile('error: device not found') | 25 _DEVICE_OFFLINE_RE = re.compile('error: device not found') |
| 26 _LONG_MSG_RE = re.compile('longMsg=') | 26 _LONG_MSG_RE = re.compile('longMsg=(.*)$') |
| 27 _SHORT_MSG_RE = re.compile('shortMsg=') | 27 _SHORT_MSG_RE = re.compile('shortMsg=(.*)$') |
| 28 | 28 |
| 29 | 29 |
| 30 class RemoteDeviceTestRun(test_run.TestRun): | 30 class RemoteDeviceTestRun(test_run.TestRun): |
| 31 """Run tests on a remote device.""" | 31 """Run tests on a remote device.""" |
| 32 | 32 |
| 33 _TEST_RUN_KEY = 'test_run' | 33 _TEST_RUN_KEY = 'test_run' |
| 34 _TEST_RUN_ID_KEY = 'test_run_id' | 34 _TEST_RUN_ID_KEY = 'test_run_id' |
| 35 | 35 |
| 36 WAIT_TIME = 5 | 36 WAIT_TIME = 5 |
| 37 COMPLETE = 'complete' | 37 COMPLETE = 'complete' |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 def _DidDeviceGoOffline(self): | 359 def _DidDeviceGoOffline(self): |
| 360 zip_file = self._DownloadTestResults(None) | 360 zip_file = self._DownloadTestResults(None) |
| 361 with zipfile.ZipFile(zip_file) as z: | 361 with zipfile.ZipFile(zip_file) as z: |
| 362 adb_trace_log = z.read('adb_trace.log') | 362 adb_trace_log = z.read('adb_trace.log') |
| 363 if any(_DEVICE_OFFLINE_RE.search(l) for l in adb_trace_log.splitlines()): | 363 if any(_DEVICE_OFFLINE_RE.search(l) for l in adb_trace_log.splitlines()): |
| 364 return True | 364 return True |
| 365 return False | 365 return False |
| 366 | 366 |
| 367 def _DetectPlatformErrors(self, results): | 367 def _DetectPlatformErrors(self, results): |
| 368 if not self._results['results']['pass']: | 368 if not self._results['results']['pass']: |
| 369 if any(_SHORT_MSG_RE.search(l) | 369 crash_msg = None |
| 370 for l in self._results['results']['output'].splitlines()): | 370 for line in self._results['results']['output'].splitlines(): |
| 371 m = _LONG_MSG_RE.search(line) |
| 372 if m: |
| 373 crash_msg = m.group(1) |
| 374 break |
| 375 m = _SHORT_MSG_RE.search(line) |
| 376 if m: |
| 377 crash_msg = m.group(1) |
| 378 if crash_msg: |
| 371 self._LogLogcat() | 379 self._LogLogcat() |
| 372 for line in self._results['results']['output'].splitlines(): | 380 results.AddResult(base_test_result.BaseTestResult( |
| 373 if _LONG_MSG_RE.search(line): | 381 crash_msg, base_test_result.ResultType.CRASH)) |
| 374 results.AddResult(base_test_result.BaseTestResult( | |
| 375 line.split('=')[1], base_test_result.ResultType.CRASH)) | |
| 376 break | |
| 377 else: | |
| 378 results.AddResult(base_test_result.BaseTestResult( | |
| 379 'Unknown platform error detected.', | |
| 380 base_test_result.ResultType.UNKNOWN)) | |
| 381 elif self._DidDeviceGoOffline(): | 382 elif self._DidDeviceGoOffline(): |
| 382 self._LogLogcat() | 383 self._LogLogcat() |
| 383 self._LogAdbTraceLog() | 384 self._LogAdbTraceLog() |
| 384 raise remote_device_helper.RemoteDeviceError( | 385 raise remote_device_helper.RemoteDeviceError( |
| 385 'Remote service unable to reach device.', is_infra_error=True) | 386 'Remote service unable to reach device.', is_infra_error=True) |
| 386 else: | 387 else: |
| 387 results.AddResult(base_test_result.BaseTestResult( | 388 # Remote service is reporting a failure, but no failure in results obj. |
| 388 'Remote Service detected error.', | 389 if results.DidRunPass(): |
| 389 base_test_result.ResultType.UNKNOWN)) | 390 results.AddResult(base_test_result.BaseTestResult( |
| 391 'Remote Service detected error.', |
| 392 base_test_result.ResultType.UNKNOWN)) |
| OLD | NEW |