mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-02-21 20:38:57 +00:00
adb_shell: Fixed checking exit codes on Android N
As of android N '\n' is used as the new line separator not '\r\n'. This fix makes the function detect which is being used by the device.
This commit is contained in:
parent
15ced50640
commit
5abeb7aac2
@ -25,7 +25,7 @@ import subprocess
|
|||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from wlauto.exceptions import DeviceError, ConfigError, HostError
|
from wlauto.exceptions import DeviceError, ConfigError, HostError, WAError
|
||||||
from wlauto.utils.misc import check_output, escape_single_quotes, escape_double_quotes, get_null
|
from wlauto.utils.misc import check_output, escape_single_quotes, escape_double_quotes, get_null
|
||||||
|
|
||||||
|
|
||||||
@ -276,10 +276,17 @@ def adb_shell(device, command, timeout=None, check_exit_code=False, as_root=Fals
|
|||||||
actual_command = "adb {} shell '({}); echo; echo $?'".format(device_string, escape_single_quotes(command))
|
actual_command = "adb {} shell '({}); echo; echo $?'".format(device_string, escape_single_quotes(command))
|
||||||
raw_output, error = check_output(actual_command, timeout, shell=True)
|
raw_output, error = check_output(actual_command, timeout, shell=True)
|
||||||
if raw_output:
|
if raw_output:
|
||||||
|
if raw_output.endswith('\r\n'):
|
||||||
|
newline = '\r\n'
|
||||||
|
elif raw_output.endswith('\n'):
|
||||||
|
newline = '\n'
|
||||||
|
else:
|
||||||
|
raise WAError("Unknown new line separator in: {}".format(raw_output))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
output, exit_code, _ = raw_output.rsplit('\r\n', 2)
|
output, exit_code, _ = raw_output.rsplit(newline, 2)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
exit_code, _ = raw_output.rsplit('\r\n', 1)
|
exit_code, _ = raw_output.rsplit(newline, 1)
|
||||||
output = ''
|
output = ''
|
||||||
else: # raw_output is empty
|
else: # raw_output is empty
|
||||||
exit_code = '969696' # just because
|
exit_code = '969696' # just because
|
||||||
|
Loading…
x
Reference in New Issue
Block a user