From: "Alex Bennée" <alex.bennee@linaro.org>
To: peter.maydell@linaro.org
Cc: "Fam Zheng" <fam@euphon.net>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
qemu-devel@nongnu.org, "Gerd Hoffmann" <kraxel@redhat.com>
Subject: [PULL 2/8] tests/vm: add console_consume helper
Date: Tue, 12 Nov 2019 14:50:22 +0000 [thread overview]
Message-ID: <20191112145028.26386-3-alex.bennee@linaro.org> (raw)
In-Reply-To: <20191112145028.26386-1-alex.bennee@linaro.org>
From: Gerd Hoffmann <kraxel@redhat.com>
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>
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
next prev parent reply other threads:[~2019-11-12 14:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-12 14:50 [PULL 0/8] testing and tcg plugin api ver Alex Bennée
2019-11-12 14:50 ` [PULL 1/8] tests/vm: netbsd autoinstall, using serial console Alex Bennée
2019-11-12 14:50 ` Alex Bennée [this message]
2019-11-12 14:50 ` [PULL 3/8] tests/vm: use console_consume for netbsd Alex Bennée
2019-11-12 14:50 ` [PULL 4/8] tests/vm: update netbsd to version 8.1 Alex Bennée
2019-11-12 14:50 ` [PULL 5/8] tests: only run ipmi-bt-test if CONFIG_LINUX Alex Bennée
2019-11-12 14:50 ` [PULL 6/8] tests/vm: support sites with sha512 checksums Alex Bennée
2019-11-12 14:50 ` [PULL 7/8] .travis.yml: don't run make check with multiple jobs Alex Bennée
2019-11-12 14:50 ` [PULL 8/8] tcg plugins: expose an API version concept Alex Bennée
2019-11-12 16:01 ` [PULL 0/8] testing and tcg plugin api ver Peter Maydell
2019-11-12 16:22 ` Alex Bennée
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191112145028.26386-3-alex.bennee@linaro.org \
--to=alex.bennee@linaro.org \
--cc=fam@euphon.net \
--cc=kraxel@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).