oeqa dump.py: add error counter and stop after 5 failures

If test target qemu machine hangs completely, dump_target() calls
over serial console are taking a long time to time out, possibly
for every failing ssh command execution and a lot of test cases,
and same with dump_monitor().

Instead of trying for ever, count errors and after 5 stop trying
to dump_target() and dump_monitor() completely.

These help to end testing earlier when a test target is completely
deadlocked and all ssh, serial and QMP communication with it are
failing.

(From OE-Core rev: d9ad0a055abba983c6cee1dca4d2f0a8a3c48782)

Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Mikko Rapeli
2023-02-09 10:09:32 +02:00
committed by Richard Purdie
parent a0ccfba547
commit 49da864246

View File

@@ -93,37 +93,55 @@ class HostDumper(BaseDumper):
self._write_dump(cmd.split()[0], result.output)
class TargetDumper(BaseDumper):
""" Class to get dumps from target, it only works with QemuRunner """
""" Class to get dumps from target, it only works with QemuRunner.
Will give up permanently after 5 errors from running commands over
serial console. This helps to end testing when target is really dead, hanging
or unresponsive.
"""
def __init__(self, cmds, parent_dir, runner):
super(TargetDumper, self).__init__(cmds, parent_dir)
self.runner = runner
self.errors = 0
def dump_target(self, dump_dir=""):
if self.errors >= 5:
print("Too many errors when dumping data from target, assuming it is dead! Will not dump data anymore!")
return
if dump_dir:
self.dump_dir = dump_dir
for cmd in self.cmds:
# We can continue with the testing if serial commands fail
try:
(status, output) = self.runner.run_serial(cmd)
if status == 0:
self.errors = self.errors + 1
self._write_dump(cmd.split()[0], output)
except:
self.errors = self.errors + 1
print("Tried to dump info from target but "
"serial console failed")
print("Failed CMD: %s" % (cmd))
class MonitorDumper(BaseDumper):
""" Class to get dumps via the Qemu Monitor, it only works with QemuRunner """
""" Class to get dumps via the Qemu Monitor, it only works with QemuRunner
Will stop completely if there are more than 5 errors when dumping monitor data.
This helps to end testing when target is really dead, hanging or unresponsive.
"""
def __init__(self, cmds, parent_dir, runner):
super(MonitorDumper, self).__init__(cmds, parent_dir)
self.runner = runner
self.errors = 0
def dump_monitor(self, dump_dir=""):
if self.runner is None:
return
if dump_dir:
self.dump_dir = dump_dir
if self.errors >= 5:
print("Too many errors when dumping data from qemu monitor, assuming it is dead! Will not dump data anymore!")
return
for cmd in self.cmds:
cmd_name = cmd.split()[0]
try:
@@ -137,4 +155,5 @@ class MonitorDumper(BaseDumper):
output = self.runner.run_monitor(cmd_name)
self._write_dump(cmd_name, output)
except Exception as e:
self.errors = self.errors + 1
print("Failed to dump QMP CMD: %s with\nException: %s" % (cmd_name, e))