diff options
Diffstat (limited to 'tools/boot/ci-qemu-test.sh')
-rwxr-xr-x | tools/boot/ci-qemu-test.sh | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/tools/boot/ci-qemu-test.sh b/tools/boot/ci-qemu-test.sh index e6481c794af5..63f0fc2c64b2 100755 --- a/tools/boot/ci-qemu-test.sh +++ b/tools/boot/ci-qemu-test.sh @@ -8,7 +8,6 @@ # rootgen.sh and related scripts generate much more extensive tests for many # combinations of boot env (ufs, zfs, geli, etc). # -# $FreeBSD$ set -e @@ -21,7 +20,7 @@ die() tempdir_cleanup() { trap - EXIT SIGINT SIGHUP SIGTERM SIGQUIT - rm -rf ${ROOTDIR} + rm -rf ${WORKDIR} } tempdir_setup() @@ -85,7 +84,7 @@ amd64) if [ ! -r "${OVMF}" ]; then die "Cannot read UEFI firmware file ${OVMF}" fi - QEMU="qemu-system-x86_64 -drive if=pflash,format=raw,readonly,file=${OVMF}" + QEMU="qemu-system-x86_64 -drive if=pflash,format=raw,readonly=on,file=${OVMF}" EFIBOOT=BOOTx64.EFI ROOTDEV=ada0s1 ;; @@ -99,22 +98,35 @@ arm64) esac # Create a temp dir to hold the boot image. -ROOTDIR=$(mktemp -d -t ci-qemu-test-fat-root) +WORKDIR=$(mktemp -d -t ci-qemu-test-fat-root) +ROOTDIR=${WORKDIR}/stage-root trap tempdir_cleanup EXIT SIGINT SIGHUP SIGTERM SIGQUIT # Populate the boot image in a temp dir. ( cd ${SRCTOP} && tempdir_setup ) +# Using QEMU's virtual FAT support is much faster than creating a disk image, +# but only supports about 500MB. Fall back to creating a disk image if the +# staged root is too large. +hda="fat:${ROOTDIR}" +rootsize=$(du -skA ${ROOTDIR} | sed 's/[[:space:]].*$//') +if [ $rootsize -gt 512000 ]; then + echo "Root size ${rootsize}K too large for QEMU virtual FAT" >&2 + makefs -t msdos -s 1g $WORKDIR/image.fat $ROOTDIR + mkimg -s mbr -p efi:=$WORKDIR/image.fat -o $WORKDIR/image.mbr + hda="$WORKDIR/image.mbr" +fi + # And, boot in QEMU. : ${BOOTLOG:=${TMPDIR:-/tmp}/ci-qemu-test-boot.log} timeout 300 \ $QEMU -m 256M -nodefaults \ -serial stdio -vga none -nographic -monitor none \ - -snapshot -hda fat:${ROOTDIR} 2>&1 | tee ${BOOTLOG} + -snapshot -hda $hda 2>&1 | tee ${BOOTLOG} # Check whether we succesfully booted... -if grep -q 'Hello world.' ${BOOTLOG}; then - echo "OK" +if grep -q 'Hello world.' ${BOOTLOG} && egrep -q '^Uptime: ' ${BOOTLOG}; then + echo "Boot successful" else die "Did not boot successfully, see ${BOOTLOG}" fi |