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

Side by Side Diff: build/android/pylib/android_commands.py

Issue 25525003: Add new Android test runner command to handle linker tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address marcus' issues. Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 """Provides an interface to communicate with the device via the adb command. 5 """Provides an interface to communicate with the device via the adb command.
6 6
7 Assumes adb binary is currently on system path. 7 Assumes adb binary is currently on system path.
8 """ 8 """
9 9
10 import collections 10 import collections
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 StopRecordingLogcat or SearchLogcatRecord following the tests. 1251 StopRecordingLogcat or SearchLogcatRecord following the tests.
1252 1252
1253 Args: 1253 Args:
1254 clear: True if existing log output should be cleared. 1254 clear: True if existing log output should be cleared.
1255 filters: A list of logcat filters to be used. 1255 filters: A list of logcat filters to be used.
1256 """ 1256 """
1257 if clear: 1257 if clear:
1258 self._adb.SendCommand('logcat -c') 1258 self._adb.SendCommand('logcat -c')
1259 logcat_command = 'adb %s logcat -v threadtime %s' % (self._adb._target_arg, 1259 logcat_command = 'adb %s logcat -v threadtime %s' % (self._adb._target_arg,
1260 ' '.join(filters)) 1260 ' '.join(filters))
1261 self._logcat_tmpoutfile = tempfile.TemporaryFile(bufsize=0) 1261 self._logcat_tmpoutfile = tempfile.NamedTemporaryFile(bufsize=0)
1262 self.logcat_process = subprocess.Popen(logcat_command, shell=True, 1262 self.logcat_process = subprocess.Popen(logcat_command, shell=True,
1263 stdout=self._logcat_tmpoutfile) 1263 stdout=self._logcat_tmpoutfile)
1264 1264
1265 def GetCurrentRecordedLogcat(self):
1266 """Return the current content of the logcat being recorded by
frankf 2013/10/02 18:16:02 nit: first sentence on 1 line.
digit1 2013/10/03 09:16:00 Done.
1267 StartRecordingLogcat(). This can be useful to perform timed
1268 polling/parsing. Do not call after StopRecordingLogcat()."""
frankf 2013/10/02 18:16:02 Add Returns section in docstring and document it c
digit1 2013/10/03 09:16:00 Done.
1269 if not self._logcat_tmpoutfile:
1270 return None
1271
1272 with open(self._logcat_tmpoutfile.name) as f:
1273 return f.read()
1274
1265 def StopRecordingLogcat(self): 1275 def StopRecordingLogcat(self):
1266 """Stops an existing logcat recording subprocess and returns output. 1276 """Stops an existing logcat recording subprocess and returns output.
1267 1277
1268 Returns: 1278 Returns:
1269 The logcat output as a string or an empty string if logcat was not 1279 The logcat output as a string or an empty string if logcat was not
1270 being recorded at the time. 1280 being recorded at the time.
1271 """ 1281 """
1272 if not self.logcat_process: 1282 if not self.logcat_process:
1273 return '' 1283 return ''
1274 # Cannot evaluate directly as 0 is a possible value. 1284 # Cannot evaluate directly as 0 is a possible value.
1275 # Better to read the self.logcat_process.stdout before killing it, 1285 # Better to read the self.logcat_process.stdout before killing it,
1276 # Otherwise the communicate may return incomplete output due to pipe break. 1286 # Otherwise the communicate may return incomplete output due to pipe break.
1277 if self.logcat_process.poll() is None: 1287 if self.logcat_process.poll() is None:
1278 self.logcat_process.kill() 1288 self.logcat_process.kill()
1279 self.logcat_process.wait() 1289 self.logcat_process.wait()
1280 self.logcat_process = None 1290 self.logcat_process = None
1281 self._logcat_tmpoutfile.seek(0) 1291 self._logcat_tmpoutfile.seek(0)
1282 output = self._logcat_tmpoutfile.read() 1292 output = self._logcat_tmpoutfile.read()
1283 self._logcat_tmpoutfile.close() 1293 self._logcat_tmpoutfile.close()
1294 self._logcat_tmpoutfile = None
1284 return output 1295 return output
1285 1296
1286 def SearchLogcatRecord(self, record, message, thread_id=None, proc_id=None, 1297 def SearchLogcatRecord(self, record, message, thread_id=None, proc_id=None,
1287 log_level=None, component=None): 1298 log_level=None, component=None):
1288 """Searches the specified logcat output and returns results. 1299 """Searches the specified logcat output and returns results.
1289 1300
1290 This method searches through the logcat output specified by record for a 1301 This method searches through the logcat output specified by record for a
1291 certain message, narrowing results by matching them against any other 1302 certain message, narrowing results by matching them against any other
1292 specified criteria. It returns all matching lines as described below. 1303 specified criteria. It returns all matching lines as described below.
1293 1304
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
1610 """ 1621 """
1611 def __init__(self, output): 1622 def __init__(self, output):
1612 self._output = output 1623 self._output = output
1613 1624
1614 def write(self, data): 1625 def write(self, data):
1615 data = data.replace('\r\r\n', '\n') 1626 data = data.replace('\r\r\n', '\n')
1616 self._output.write(data) 1627 self._output.write(data)
1617 1628
1618 def flush(self): 1629 def flush(self):
1619 self._output.flush() 1630 self._output.flush()
OLDNEW
« no previous file with comments | « no previous file | build/android/pylib/linker/__init__.py » ('j') | build/android/pylib/linker/setup.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698