[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 2/8] tests/vm: add console_consume helper
From: |
Alex Bennée |
Subject: |
[PULL 2/8] tests/vm: add console_consume helper |
Date: |
Tue, 12 Nov 2019 14:50:22 +0000 |
From: Gerd Hoffmann <address@hidden>
Helper function to read all console output.
Signed-off-by: Gerd Hoffmann <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Alex Bennée <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Tested-by: Philippe Mathieu-Daudé <address@hidden>
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:
--
2.20.1
- [PULL 0/8] testing and tcg plugin api ver, Alex Bennée, 2019/11/12
- [PULL 2/8] tests/vm: add console_consume helper,
Alex Bennée <=
- [PULL 1/8] tests/vm: netbsd autoinstall, using serial console, Alex Bennée, 2019/11/12
- [PULL 3/8] tests/vm: use console_consume for netbsd, Alex Bennée, 2019/11/12
- [PULL 4/8] tests/vm: update netbsd to version 8.1, Alex Bennée, 2019/11/12
- [PULL 7/8] .travis.yml: don't run make check with multiple jobs, Alex Bennée, 2019/11/12
- [PULL 5/8] tests: only run ipmi-bt-test if CONFIG_LINUX, Alex Bennée, 2019/11/12
- [PULL 6/8] tests/vm: support sites with sha512 checksums, Alex Bennée, 2019/11/12
- [PULL 8/8] tcg plugins: expose an API version concept, Alex Bennée, 2019/11/12
- Re: [PULL 0/8] testing and tcg plugin api ver, Peter Maydell, 2019/11/12