aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2019-10-31 09:53:04 +0100
committerAlex Bennée <alex.bennee@linaro.org>2019-11-12 14:32:55 +0000
commit6c4f0416be5805962a77af240a41fae5eaffda8b (patch)
tree397c546d786c88bdca6a27b8d81b7b91313d66bb /tests
parentaf093bc937ba7813ba3a091ddab64d2f813740ea (diff)
downloadqemu-6c4f0416be5805962a77af240a41fae5eaffda8b.zip
qemu-6c4f0416be5805962a77af240a41fae5eaffda8b.tar.gz
qemu-6c4f0416be5805962a77af240a41fae5eaffda8b.tar.bz2
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>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/vm/basevm.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
index 2929de2..086bfb2 100755
--- a/tests/vm/basevm.py
+++ b/tests/vm/basevm.py
@@ -242,6 +242,25 @@ class BaseVM(object):
return False
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):
vm = self._guest
if self.debug: