[v3,1/8] CI: Do not lose output on bitbake / qemu exit

Message ID 20241011100050.322686-2-amikan@ilbers.de
State Accepted, archived
Headers show
Series Hanging mount fixes | expand

Commit Message

Anton Mikanovich Oct. 11, 2024, 10 a.m. UTC
If bitbake or qemu exit before we completely read their stdout/stderr,
messages are lost. With this change, we read the subprocess output
before terminating ourselves.

Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
 testsuite/cibuilder.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Patch

diff --git a/testsuite/cibuilder.py b/testsuite/cibuilder.py
index 4a605f50..0d0de99e 100755
--- a/testsuite/cibuilder.py
+++ b/testsuite/cibuilder.py
@@ -257,7 +257,7 @@  class CIBuilder(Test):
             poller = select.poll()
             poller.register(p1.stdout, select.POLLIN)
             poller.register(p1.stderr, select.POLLIN)
-            while p1.poll() is None:
+            while True:
                 events = poller.poll(1000)
                 for fd, event in events:
                     if event != select.POLLIN:
@@ -266,6 +266,8 @@  class CIBuilder(Test):
                         self.log.info(p1.stdout.readline().rstrip())
                     if fd == p1.stderr.fileno():
                         app_log.error(p1.stderr.readline().rstrip())
+                if p1.poll() is not None:
+                    break
             p1.wait()
             if p1.returncode:
                 self.fail("Bitbake failed")
@@ -533,7 +535,7 @@  class CIBuilder(Test):
         databuf = bytearray(b'')
         databuf_size = 1024 * 2 + len(login_prompt)
 
-        while time.time() < timeout and p1.poll() is None:
+        while time.time() < timeout:
             events = poller.poll(1000 * (timeout - time.time()))
             for fd, event in events:
                 if event != select.POLLIN:
@@ -547,6 +549,8 @@  class CIBuilder(Test):
                         return 0
                 if fd == p1.stderr.fileno():
                     app_log.error(p1.stderr.readline().rstrip())
+            if p1.poll() is not None:
+                break
 
         self.log.error("Didn't get login prompt")
         return 1