diff mbox series

[v7,3/3] support/scripts/boot-qemu-image.py: manage petitboot interface

Message ID 20221118141435.1084565-4-laurent@vivier.eu
State Superseded
Headers show
Series package: add petitboot to use with qemu-system-m68k | expand

Commit Message

Laurent Vivier Nov. 18, 2022, 2:14 p.m. UTC
Petitboot doesn't start a shell but a GUI.
Manage the menu to switch to the shell.
Use "poweroff -f" as we don't have init

Enable the test for qemu_m68K_virt.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 configs/qemu_m68k_virt_petitboot_defconfig |  5 +++++
 support/scripts/boot-qemu-image.py         | 13 ++++++++++---
 2 files changed, 15 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/configs/qemu_m68k_virt_petitboot_defconfig b/configs/qemu_m68k_virt_petitboot_defconfig
index 5ddd9837161f..c83827855f07 100644
--- a/configs/qemu_m68k_virt_petitboot_defconfig
+++ b/configs/qemu_m68k_virt_petitboot_defconfig
@@ -8,6 +8,8 @@  BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y
 BR2_ROOTFS_MERGED_USR=y
 BR2_TARGET_GENERIC_GETTY_PORT="ttyGF0"
 BR2_ROOTFS_OVERLAY="package/petitboot/fs-overlay"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/qemu/post-image.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="$(BR2_DEFCONFIG)"
 BR2_LINUX_KERNEL=y
 BR2_LINUX_KERNEL_CUSTOM_VERSION=y
 BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.19"
@@ -24,3 +26,6 @@  BR2_PACKAGE_RSYNC=y
 BR2_PACKAGE_PETITBOOT=y
 BR2_TARGET_ROOTFS_CPIO=y
 BR2_TARGET_ROOTFS_CPIO_XZ=y
+# host-qemu for gitlab testing
+BR2_PACKAGE_HOST_QEMU=y
+BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y
diff --git a/support/scripts/boot-qemu-image.py b/support/scripts/boot-qemu-image.py
index ba50ea69ee9a..8dd3b4c654e1 100755
--- a/support/scripts/boot-qemu-image.py
+++ b/support/scripts/boot-qemu-image.py
@@ -36,7 +36,7 @@  def main():
     time.sleep(1)
 
     try:
-        child.expect(["buildroot login:"], timeout=600)
+        idx = child.expect(["buildroot login:", "Exit to shell"], timeout=600)
     except pexpect.EOF as e:
         # Some emulations require a fork of qemu-system, which may be
         # missing on the system, and is not provided by Buildroot.
@@ -55,7 +55,11 @@  def main():
         print("System did not boot in time, exiting.")
         sys.exit(1)
 
-    child.sendline("root\r")
+    if idx == 0:
+        child.sendline("root\r")
+    elif idx == 1:
+        time.sleep(1)
+        child.sendline("\r")
 
     try:
         child.expect(["# "], timeout=600)
@@ -66,7 +70,10 @@  def main():
         print("Timeout while waiting for shell")
         sys.exit(1)
 
-    child.sendline("poweroff\r")
+    if idx == 0:
+        child.sendline("poweroff\r")
+    elif idx == 1:
+        child.sendline("poweroff -f\r")
 
     try:
         child.expect(["System halted"], timeout=600)