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

Unified Diff: build/android/pylib/android_commands.py

Issue 13799010: [Android] Reduce test logging verbosity. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: build/android/pylib/android_commands.py
diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py
index f370efee13d67f7df8d7366a760f6f29662ed1d9..c0ded2f745f4704b1acc856d71fe2e7f89c2a9c6 100644
--- a/build/android/pylib/android_commands.py
+++ b/build/android/pylib/android_commands.py
@@ -109,9 +109,11 @@ def GetAttachedDevices():
devices.insert(0, preferred_device)
return devices
+
def IsDeviceAttached(device):
return device in GetAttachedDevices()
+
def _GetFilesFromRecursiveLsOutput(path, ls_output, re_file, utc_offset=None):
"""Gets a list of files from `ls` command output.
@@ -164,10 +166,12 @@ def _GetFilesFromRecursiveLsOutput(path, ls_output, re_file, utc_offset=None):
files[filename] = (int(file_match.group('size')), lastmod)
return files
+
def _ComputeFileListHash(md5sum_output):
"""Returns a list of MD5 strings from the provided md5sum output."""
return [line.split(' ')[0] for line in md5sum_output]
+
def _HasAdbPushSucceeded(command_output):
"""Returns whether adb push has succeeded from the provided output."""
if not command_output:
@@ -179,6 +183,7 @@ def _HasAdbPushSucceeded(command_output):
return False
return True
+
def GetLogTimestamp(log_line, year):
"""Returns the timestamp of the given |log_line| in the given year."""
try:
@@ -189,6 +194,11 @@ def GetLogTimestamp(log_line, year):
return None
+def _LogShell(cmd):
+ """Logs the adb shell command."""
+ logging.info('[device]> %s', cmd)
Isaac (away) 2013/04/10 19:12:53 It'd be great to include device serial number here
craigdh 2013/04/10 20:39:49 The logging format was just recently changed to in
frankf 2013/04/10 21:29:42 I added this anyways in case we do something on on
+
+
class AndroidCommands(object):
"""Helper class for communicating with Android device via adb.
@@ -317,7 +327,7 @@ class AndroidCommands(object):
"""
uninstall_command = 'uninstall %s' % package
- logging.info('>>> $' + uninstall_command)
+ _LogShell(uninstall_command)
return self._adb.SendCommand(uninstall_command, timeout_time=60)
def Install(self, package_file_path, reinstall=False):
@@ -341,7 +351,7 @@ class AndroidCommands(object):
install_cmd.append(package_file_path)
install_cmd = ' '.join(install_cmd)
- logging.info('>>> $' + install_cmd)
+ _LogShell(install_cmd)
return self._adb.SendCommand(install_cmd,
timeout_time=2 * 60,
retry_count=0)
@@ -472,14 +482,14 @@ class AndroidCommands(object):
Returns:
list containing the lines of output received from running the command
"""
- logging.info('>>> $' + command)
+ _LogShell(command)
if "'" in command: logging.warning(command + " contains ' quotes")
result = self._adb.SendShellCommand(
"'%s'" % command, timeout_time).splitlines()
if ['error: device not found'] == result:
raise errors.DeviceUnresponsiveError('device not found')
if log_result:
- logging.info('\n>>> '.join(result))
+ _LogShell('\n'.join(result))
return result
def GetShellCommandStatusAndOutput(self, command, timeout_time=20,
@@ -697,7 +707,7 @@ class AndroidCommands(object):
# NOTE: We can't use adb_interface.Push() because it hardcodes a timeout of
# 60 seconds which isn't sufficient for a lot of users of this method.
push_command = 'push %s %s' % (local_path, device_path)
- logging.info('>>> $' + push_command)
+ _LogShell(push_command)
output = self._adb.SendCommand(push_command, timeout_time=30 * 60)
assert _HasAdbPushSucceeded(output)
@@ -1253,7 +1263,7 @@ class AndroidCommands(object):
An instance of am_instrument_parser.TestResult object.
"""
cmd = 'uiautomator runtest %s -e class %s' % (test_package, test)
- logging.info('>>> $' + cmd)
+ _LogShell(cmd)
output = self._adb.SendShellCommand(cmd, timeout_time=timeout)
# uiautomator doesn't fully conform to the instrumenation test runner
# convention and doesn't terminate with INSTRUMENTATION_CODE.

Powered by Google App Engine
This is Rietveld 408576698