summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils/qemurunner.py
diff options
context:
space:
mode:
authorMikko Rapeli <mikko.rapeli@linaro.org>2023-05-10 15:59:33 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-05-22 10:53:47 +0100
commit830f4cb0a62e63d378a1cebe29996d7355898917 (patch)
tree9ab0052dfaac5089ed1bdad9228d54bf0e7d0e67 /meta/lib/oeqa/utils/qemurunner.py
parentcf8610beb74377abd2fe37f4a139bc9ca3cf0b46 (diff)
downloadpoky-830f4cb0a62e63d378a1cebe29996d7355898917.tar.gz
qemurunner: support serial console login via qemu stdout
runqemu script works with qemu machines which provide login and serial console to the qemu process stdout. Add the same support to qemurunner so that testing with testimage.bbclass is possible. Default qemu machines provide serial console boot logs and login via socket to qemu process but I don't see a reason why qemu process stdout should not be supported too since they work with runqemu as well. (From OE-Core rev: a3d4b80c5b4cce933c759d023c75b8671c56fe12) Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/utils/qemurunner.py')
-rw-r--r--meta/lib/oeqa/utils/qemurunner.py30
1 files changed, 19 insertions, 11 deletions
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index 6734cee48d..3b7398b872 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -451,7 +451,7 @@ class QemuRunner:
451 self.logger.debug("Waiting at most %d seconds for login banner (%s)" % 451 self.logger.debug("Waiting at most %d seconds for login banner (%s)" %
452 (self.boottime, time.strftime("%D %H:%M:%S"))) 452 (self.boottime, time.strftime("%D %H:%M:%S")))
453 endtime = time.time() + self.boottime 453 endtime = time.time() + self.boottime
454 socklist = [self.server_socket] 454 filelist = [self.server_socket, self.runqemu.stdout]
455 reachedlogin = False 455 reachedlogin = False
456 stopread = False 456 stopread = False
457 qemusock = None 457 qemusock = None
@@ -459,24 +459,32 @@ class QemuRunner:
459 data = b'' 459 data = b''
460 while time.time() < endtime and not stopread: 460 while time.time() < endtime and not stopread:
461 try: 461 try:
462 sread, swrite, serror = select.select(socklist, [], [], 5) 462 sread, swrite, serror = select.select(filelist, [], [], 5)
463 except InterruptedError: 463 except InterruptedError:
464 continue 464 continue
465 for sock in sread: 465 for file in sread:
466 if sock is self.server_socket: 466 if file is self.server_socket:
467 qemusock, addr = self.server_socket.accept() 467 qemusock, addr = self.server_socket.accept()
468 qemusock.setblocking(0) 468 qemusock.setblocking(False)
469 socklist.append(qemusock) 469 filelist.append(qemusock)
470 socklist.remove(self.server_socket) 470 filelist.remove(self.server_socket)
471 self.logger.debug("Connection from %s:%s" % addr) 471 self.logger.debug("Connection from %s:%s" % addr)
472 else: 472 else:
473 # try to avoid reading only a single character at a time 473 # try to avoid reading only a single character at a time
474 time.sleep(0.1) 474 time.sleep(0.1)
475 data = data + sock.recv(1024) 475 if hasattr(file, 'read'):
476 read = file.read(1024)
477 elif hasattr(file, 'recv'):
478 read = file.recv(1024)
479 else:
480 self.logger.error('Invalid file type: %s\n%s' % (file))
481 read = b''
482
483 data = data + read
476 if data: 484 if data:
477 bootlog += data 485 bootlog += data
478 if self.serial_ports < 2: 486 if self.serial_ports < 2:
479 # this socket has mixed console/kernel data, log it to logfile 487 # this file has mixed console/kernel data, log it to logfile
480 self.log(data) 488 self.log(data)
481 489
482 data = b'' 490 data = b''
@@ -493,8 +501,8 @@ class QemuRunner:
493 # no need to check if reachedlogin unless we support multiple connections 501 # no need to check if reachedlogin unless we support multiple connections
494 self.logger.debug("QEMU socket disconnected before login banner reached. (%s)" % 502 self.logger.debug("QEMU socket disconnected before login banner reached. (%s)" %
495 time.strftime("%D %H:%M:%S")) 503 time.strftime("%D %H:%M:%S"))
496 socklist.remove(sock) 504 filelist.remove(file)
497 sock.close() 505 file.close()
498 stopread = True 506 stopread = True
499 507
500 if not reachedlogin: 508 if not reachedlogin: