summaryrefslogtreecommitdiffstats
path: root/debian/tests/run-qemu
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-03 05:43:00 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-03 05:43:00 +0000
commit6032561e9b12b99fa51b4b38bdeee7f831adcaee (patch)
tree30d9958682cf814635ba3fcfe6457463fed91383 /debian/tests/run-qemu
parentAdding upstream version 0.143. (diff)
downloadinitramfs-tools-debian/0.143.tar.xz
initramfs-tools-debian/0.143.zip
Adding debian version 0.143.debian/0.143debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/tests/run-qemu')
-rwxr-xr-xdebian/tests/run-qemu50
1 files changed, 50 insertions, 0 deletions
diff --git a/debian/tests/run-qemu b/debian/tests/run-qemu
new file mode 100755
index 0000000..d3c3e99
--- /dev/null
+++ b/debian/tests/run-qemu
@@ -0,0 +1,50 @@
+#!/bin/sh
+set -eu
+
+# Run qemu-system for the system architecture
+
+if test "$#" -lt 3; then
+ echo "${0##*/}: Error: Not enough parameters." >&2
+ echo "Usage: ${0##*/} kernel initrd append [extra_args]" >&2
+ exit 1
+fi
+
+kernel="$1"
+initrd="$2"
+append="$3"
+shift 3
+
+ARCHITECTURE=$(dpkg --print-architecture)
+
+case "$ARCHITECTURE" in
+arm64)
+ machine="virt,gic-version=max"
+ cpu="max,pauth-impdef=on"
+ efi_code=/usr/share/AAVMF/AAVMF_CODE.fd
+ efi_vars=/usr/share/AAVMF/AAVMF_VARS.fd
+ ;;
+armhf)
+ machine="virt"
+ efi_code=/usr/share/AAVMF/AAVMF32_CODE.fd
+ efi_vars=/usr/share/AAVMF/AAVMF32_VARS.fd
+ console=ttyAMA0
+ ;;
+ppc64el)
+ machine="cap-ccf-assist=off,cap-cfpc=broken,cap-ibs=broken,cap-sbbc=broken"
+ console=hvc0
+ ;;
+esac
+
+if test -f "${efi_vars-}"; then
+ efi_vars_copy="$(mktemp -t "${efi_vars##*/}.XXXXXXXXXX")"
+ cp "$efi_vars" "$efi_vars_copy"
+fi
+
+set -- ${machine:+-machine "${machine}"} -cpu "${cpu-max}" -m 1G \
+ ${efi_code:+-drive "file=${efi_code},if=pflash,format=raw,read-only=on"} \
+ ${efi_vars:+-drive "file=${efi_vars_copy},if=pflash,format=raw"} \
+ -device virtio-rng-pci,rng=rng0 -object rng-random,filename=/dev/urandom,id=rng0 \
+ -nodefaults -no-reboot -kernel "${kernel}" -initrd "${initrd}" "$@" \
+ -append "console=${console:-ttyS0},115200 ro ${append}"
+echo "${0##*/}: qemu-system-${ARCHITECTURE} $*"
+exec "qemu-system-${ARCHITECTURE}" "$@"