* [PATCH] testsuite: Improve VM output check for login prompt
@ 2024-03-04 15:04 Uladzimir Bely
2024-03-07 7:21 ` Uladzimir Bely
0 siblings, 1 reply; 2+ messages in thread
From: Uladzimir Bely @ 2024-03-04 15:04 UTC (permalink / raw)
To: isar-users
VM output is read by chunks and " login:" string is looked up in
the every chunk. This may fail in case this string is splitted by
two consecutive chunks.
Improve this by looking up in a bigger data buffer instead of
current chunk.
Signed-off-by: Uladzimir Bely <ubely@ilbers.de>
---
testsuite/cibuilder.py | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/testsuite/cibuilder.py b/testsuite/cibuilder.py
index 002a368b..fa30c2f5 100755
--- a/testsuite/cibuilder.py
+++ b/testsuite/cibuilder.py
@@ -487,17 +487,20 @@ BBPATH .= ":${LAYERDIR}"\
poller.register(p1.stdout, select.POLLIN)
poller.register(p1.stderr, select.POLLIN)
+ # Databuf of size enough to keep two data chunks + checked string
+ databuf = bytearray(b'')
+ databuf_size = 1024 * 2 + len(login_prompt)
+
while time.time() < timeout and p1.poll() is None:
events = poller.poll(1000 * (timeout - time.time()))
for fd, event in events:
if event != select.POLLIN:
continue
if fd == p1.stdout.fileno():
- # Wait for the complete string if it is read in chunks
- # like "i", "sar", " login:"
- time.sleep(0.01)
data = os.read(fd, 1024)
- if login_prompt in data:
+ shift = max(0, len(data) + len(databuf) - databuf_size)
+ databuf = databuf[shift:] + bytearray(data)
+ if login_prompt in databuf:
self.log.info('Got login prompt')
return 0
if fd == p1.stderr.fileno():
--
2.20.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] testsuite: Improve VM output check for login prompt
2024-03-04 15:04 [PATCH] testsuite: Improve VM output check for login prompt Uladzimir Bely
@ 2024-03-07 7:21 ` Uladzimir Bely
0 siblings, 0 replies; 2+ messages in thread
From: Uladzimir Bely @ 2024-03-07 7:21 UTC (permalink / raw)
To: isar-users
On Mon, 2024-03-04 at 16:04 +0100, Uladzimir Bely wrote:
> VM output is read by chunks and " login:" string is looked up in
> the every chunk. This may fail in case this string is splitted by
> two consecutive chunks.
>
> Improve this by looking up in a bigger data buffer instead of
> current chunk.
>
> Signed-off-by: Uladzimir Bely <ubely@ilbers.de>
> ---
> testsuite/cibuilder.py | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
Applied to next.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-03-07 7:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-04 15:04 [PATCH] testsuite: Improve VM output check for login prompt Uladzimir Bely
2024-03-07 7:21 ` Uladzimir Bely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox