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

Side by Side Diff: build/android/pylib/remote/device/remote_device_test_run.py

Issue 1277943002: [Android] Detect when remote service loses contact with device. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months 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 unified diff | Download patch
OLDNEW
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 shutil 11 import shutil
11 import string 12 import string
12 import tempfile 13 import tempfile
13 import time 14 import time
14 import zipfile 15 import zipfile
15 16
16 from pylib.base import test_run 17 from pylib.base import test_run
17 from pylib.remote.device import appurify_constants 18 from pylib.remote.device import appurify_constants
18 from pylib.remote.device import appurify_sanitized 19 from pylib.remote.device import appurify_sanitized
19 from pylib.remote.device import remote_device_helper 20 from pylib.remote.device import remote_device_helper
20 from pylib.utils import zip_utils 21 from pylib.utils import zip_utils
21 22
23 _DEVICE_OFFLINE_RE = re.compile('error: device not found')
24
25
22 class RemoteDeviceTestRun(test_run.TestRun): 26 class RemoteDeviceTestRun(test_run.TestRun):
23 """Run tests on a remote device.""" 27 """Run tests on a remote device."""
24 28
25 _TEST_RUN_KEY = 'test_run' 29 _TEST_RUN_KEY = 'test_run'
26 _TEST_RUN_ID_KEY = 'test_run_id' 30 _TEST_RUN_ID_KEY = 'test_run_id'
27 31
28 WAIT_TIME = 5 32 WAIT_TIME = 5
29 COMPLETE = 'complete' 33 COMPLETE = 'complete'
30 HEARTBEAT_INTERVAL = 300 34 HEARTBEAT_INTERVAL = 300
31 35
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 """ 337 """
334 zip_file = self._DownloadTestResults(None) 338 zip_file = self._DownloadTestResults(None)
335 with zipfile.ZipFile(zip_file) as z: 339 with zipfile.ZipFile(zip_file) as z:
336 try: 340 try:
337 logcat = z.read('appurify_results/logcat.txt') 341 logcat = z.read('appurify_results/logcat.txt')
338 printable_logcat = ''.join(c for c in logcat if c in string.printable) 342 printable_logcat = ''.join(c for c in logcat if c in string.printable)
339 for line in printable_logcat.splitlines(): 343 for line in printable_logcat.splitlines():
340 logging.log(level, line) 344 logging.log(level, line)
341 except KeyError: 345 except KeyError:
342 logging.error('No logcat found.') 346 logging.error('No logcat found.')
347
348 def _LogAdbTraceLog(self):
349 zip_file = self._DownloadTestResults(None)
350 with zipfile.ZipFile(zip_file) as z:
351 adb_trace_log = z.read('adb_trace.log')
352 for line in adb_trace_log.splitlines():
353 logging.critical(line)
354
355 def _DidDeviceGoOffline(self):
356 zip_file = self._DownloadTestResults(None)
357 with zipfile.ZipFile(zip_file) as z:
358 adb_trace_log = z.read('adb_trace.log')
359 if any(_DEVICE_OFFLINE_RE.search(l) for l in adb_trace_log.splitlines()):
360 return True
361 return False
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698