qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v1 2/6] tests/vm: add console_consume helper


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v1 2/6] tests/vm: add console_consume helper
Date: Mon, 4 Nov 2019 19:44:29 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1

On 11/4/19 6:36 PM, Alex Bennée wrote:
From: Gerd Hoffmann <address@hidden>

Helper function to read all console output.

Signed-off-by: Gerd Hoffmann <address@hidden>

Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Tested-by: Philippe Mathieu-Daudé <address@hidden>

Message-Id: <address@hidden>
Signed-off-by: Alex Bennée <address@hidden>
---
  tests/vm/basevm.py | 19 +++++++++++++++++++
  1 file changed, 19 insertions(+)

diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
index 2929de23aa7..086bfb2c66d 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:




reply via email to

[Prev in Thread] Current Thread [Next in Thread]