oeqa/qemurunner: Improve handling of run_serial for shutdown commands

When running a shutdown command, the serial port can close without the
command returning. This is seen as the socket being readable but having
no data. Change the way this case is handled in the code to avoid
tracebacks.

(From OE-Core rev: 396a3ba884820d040c91f7592daf20ac28c49b5d)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie
2021-05-09 10:59:44 +01:00
parent 4a3a0e7838
commit b681827f5b

View File

@@ -73,6 +73,8 @@ class QemuRunner:
self.monitorpipe = None
self.logger = logger
# Whether we're expecting an exit and should show related errors
self.canexit = False
# Enable testing other OS's
# Set commands for target communication, and default to Linux ALWAYS
@@ -543,6 +545,7 @@ class QemuRunner:
self.thread.join()
def allowexit(self):
self.canexit = True
if self.thread:
self.thread.allowexit()
@@ -604,7 +607,9 @@ class QemuRunner:
if re.search(self.boot_patterns['search_cmd_finished'], data):
break
else:
raise Exception("No data on serial console socket")
if self.canexit:
return (1, "")
raise Exception("No data on serial console socket, connection closed?")
if data:
if raw: