public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Uladzimir Bely <ubely@ilbers.de>
To: isar-users@googlegroups.com
Subject: [PATCH] testsuite: Improve VM output check for login prompt
Date: Mon,  4 Mar 2024 16:04:03 +0100	[thread overview]
Message-ID: <20240304150403.13016-1-ubely@ilbers.de> (raw)

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


             reply	other threads:[~2024-03-04 15:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-04 15:04 Uladzimir Bely [this message]
2024-03-07  7:21 ` Uladzimir Bely

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=20240304150403.13016-1-ubely@ilbers.de \
    --to=ubely@ilbers.de \
    --cc=isar-users@googlegroups.com \
    /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