зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1516913 - [mozdevice] _get_exitcode should handle the case in where the exitcode marker is not at EOF, r=jmaher.
This commit is contained in:
Родитель
b63ca79965
Коммит
eddb0836f7
|
@ -857,6 +857,7 @@ class ADBDevice(ADBCommand):
|
||||||
"""Get the exitcode from the last line of the file_obj for shell
|
"""Get the exitcode from the last line of the file_obj for shell
|
||||||
commands.
|
commands.
|
||||||
"""
|
"""
|
||||||
|
re_returncode = re.compile(r'adb_returncode=([0-9]+)')
|
||||||
file_obj.seek(0, os.SEEK_END)
|
file_obj.seek(0, os.SEEK_END)
|
||||||
|
|
||||||
line = ''
|
line = ''
|
||||||
|
@ -874,13 +875,28 @@ class ADBDevice(ADBCommand):
|
||||||
break
|
break
|
||||||
offset += 1
|
offset += 1
|
||||||
|
|
||||||
match = re.match(r'rc=([0-9]+)', line)
|
match = re_returncode.match(line)
|
||||||
if match:
|
if match:
|
||||||
exitcode = int(match.group(1))
|
exitcode = int(match.group(1))
|
||||||
|
# Set the position in the file to the position of the
|
||||||
|
# adb_returncode and truncate it from the output.
|
||||||
file_obj.seek(-1, os.SEEK_CUR)
|
file_obj.seek(-1, os.SEEK_CUR)
|
||||||
file_obj.truncate()
|
file_obj.truncate()
|
||||||
else:
|
else:
|
||||||
exitcode = None
|
exitcode = None
|
||||||
|
# We may have a situation where the adb_returncode= is not
|
||||||
|
# at the end of the output. This happens at least in the
|
||||||
|
# failure jit-tests on arm. To work around this
|
||||||
|
# possibility, we can search the entire output for the
|
||||||
|
# appropriate match.
|
||||||
|
file_obj.seek(0, os.SEEK_SET)
|
||||||
|
for line in file_obj:
|
||||||
|
match = re_returncode.search(line)
|
||||||
|
if match:
|
||||||
|
exitcode = int(match.group(1))
|
||||||
|
break
|
||||||
|
# Reset the position in the file to the end.
|
||||||
|
file_obj.seek(0, os.SEEK_END)
|
||||||
|
|
||||||
return exitcode
|
return exitcode
|
||||||
|
|
||||||
|
@ -1308,7 +1324,7 @@ class ADBDevice(ADBCommand):
|
||||||
envstr = '&& '.join(map(lambda x: 'export %s=%s' %
|
envstr = '&& '.join(map(lambda x: 'export %s=%s' %
|
||||||
(x[0], x[1]), env.iteritems()))
|
(x[0], x[1]), env.iteritems()))
|
||||||
cmd = envstr + "&& " + cmd
|
cmd = envstr + "&& " + cmd
|
||||||
cmd += "; echo rc=$?"
|
cmd += "; echo adb_returncode=$?"
|
||||||
|
|
||||||
args = [self._adb_path]
|
args = [self._adb_path]
|
||||||
if self._adb_host:
|
if self._adb_host:
|
||||||
|
|
Загрузка…
Ссылка в новой задаче