]> www.infradead.org Git - users/dwmw2/qemu.git/commit
tests/functional: rewrite console handling to be bytewise
authorDaniel P. Berrangé <berrange@redhat.com>
Thu, 21 Nov 2024 16:57:42 +0000 (16:57 +0000)
committerAlex Bennée <alex.bennee@linaro.org>
Mon, 25 Nov 2024 10:13:41 +0000 (10:13 +0000)
commitcdad03b74f759857d784e074755f0d96a64d69af
tree44bf705a7dde268f892f452094e2774a648de7e9
parentf03a81897db14bb56109b6adc8699a91774b3389
tests/functional: rewrite console handling to be bytewise

The console interaction that waits for predicted strings uses
readline(), and thus is only capable of waiting for strings
that are followed by a newline.

This is inconvenient when needing to match on some things,
particularly login prompts, or shell prompts, causing tests
to use time.sleep(...) instead, which is unreliable.

Switch to reading the console 1 byte at a time, comparing
against the success/failure messages until we see a match,
regardless of whether a newline is encountered.

The success/failure comparisons are done with the python bytes
type, rather than strings, to avoid the problem of needing to
decode partially received multibyte utf8 characters.

Heavily inspired by a patch proposed by Cédric, but written
again to work in bytes, rather than strings.

Co-developed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20241121154218.1423005-16-berrange@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20241121165806.476008-16-alex.bennee@linaro.org>
tests/functional/qemu_test/cmd.py