mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-21 17:11:57 -06:00
tests/vm: add console_consume helper
Helper function to read all console output. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-Id: <20191031085306.28888-3-kraxel@redhat.com> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
This commit is contained in:
parent
af093bc937
commit
6c4f0416be
1 changed files with 19 additions and 0 deletions
|
@ -242,6 +242,25 @@ class BaseVM(object):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def console_consume(self):
|
||||||
|
vm = self._guest
|
||||||
|
output = ""
|
||||||
|
vm.console_socket.setblocking(0)
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
chars = vm.console_socket.recv(1)
|
||||||
|
except:
|
||||||
|
break
|
||||||
|
output += chars.decode("latin1")
|
||||||
|
if "\r" in output or "\n" in output:
|
||||||
|
lines = re.split("[\r\n]", output)
|
||||||
|
output = lines.pop()
|
||||||
|
if self.debug:
|
||||||
|
self.console_log("\n".join(lines))
|
||||||
|
if self.debug:
|
||||||
|
self.console_log(output)
|
||||||
|
vm.console_socket.setblocking(1)
|
||||||
|
|
||||||
def console_send(self, command):
|
def console_send(self, command):
|
||||||
vm = self._guest
|
vm = self._guest
|
||||||
if self.debug:
|
if self.debug:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue