1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 02:00:45 +00:00

utils/android: Combine stdout and stderror by combining the strings in adb_shell()

check_output(combined_output=True) does not guarantee that stdout will
come before stderr, but the ordering is needed in case check_exit_code
is True, as we are expecting the exit code at the end of stdout.
Furthermore, the exceptions can't report what is stdout and what is
stderr as they are combined.

Partially revert 77a6de94537b ("utils/android: include stderr in adb_shell
output") and parse output and err independently. Return them combined
from adb_shell() to keep the functionality that 77a6de94537b was
implementing.
This commit is contained in:
Javi Merino 2020-03-27 12:01:58 +00:00 committed by Marc Bonnici
parent 7c79a040b7
commit 7780cfdd5c

View File

@ -509,7 +509,7 @@ def adb_shell(device, command, timeout=None, check_exit_code=False,
logger.debug(' '.join(quote(part) for part in parts))
try:
raw_output, _ = check_output(parts, timeout, shell=False, combined_output=True)
raw_output, error = check_output(parts, timeout, shell=False)
except subprocess.CalledProcessError as e:
raise TargetStableError(str(e))
@ -529,8 +529,8 @@ def adb_shell(device, command, timeout=None, check_exit_code=False,
if exit_code.isdigit():
if int(exit_code):
message = ('Got exit code {}\nfrom target command: {}\n'
'OUTPUT: {}')
raise TargetStableError(message.format(exit_code, command, output))
'OUTPUT: {}\nSTDERR: {}\n')
raise TargetStableError(message.format(exit_code, command, output, error))
elif re_search:
message = 'Could not start activity; got the following:\n{}'
raise TargetStableError(message.format(re_search[0]))
@ -541,10 +541,10 @@ def adb_shell(device, command, timeout=None, check_exit_code=False,
else:
message = 'adb has returned early; did not get an exit code. '\
'Was kill-server invoked?\nOUTPUT:\n-----\n{}\n'\
'-----'
raise TargetTransientError(message.format(raw_output))
'-----\nSTDERR:\n-----\n{}\n-----'
raise TargetTransientError(message.format(raw_output, error))
return output
return output + error
def adb_background_shell(conn, command,