Index: stable/12/tools/boot/ci-qemu-test.sh =================================================================== --- stable/12/tools/boot/ci-qemu-test.sh (nonexistent) +++ stable/12/tools/boot/ci-qemu-test.sh (revision 359149) @@ -0,0 +1,112 @@ +#!/bin/sh + +# Install loader, kernel, and enough of userland to boot in QEMU and echo +# "Hello world." from init, as a very quick smoke test for CI. Uses QEMU's +# virtual FAT filesystem to avoid the need to create a disk image. While +# designed for CI automated testing, this script can also be run by hand as +# a quick smoke-test. The rootgen.sh and related scripts generate much more +# extensive tests for many combinations of boot env (ufs, zfs, geli, etc). +# +# $FreeBSD$ + +set -e + +die() +{ + echo "$*" 1>&2 + exit 1 +} + +tempdir_cleanup() +{ + trap - EXIT SIGINT SIGHUP SIGTERM SIGQUIT + rm -rf ${ROOTDIR} +} + +tempdir_setup() +{ + # Create minimal directory structure and populate it. + # Caller must cd ${SRCTOP} before calling this function. + + for dir in dev bin efi/boot etc lib libexec sbin usr/lib usr/libexec; do + mkdir -p ${ROOTDIR}/${dir} + done + + # Install kernel, loader and minimal userland. + + make -DNO_ROOT DESTDIR=${ROOTDIR} \ + MODULES_OVERRIDE= \ + WITHOUT_DEBUG_FILES=yes \ + WITHOUT_KERNEL_SYMBOLS=yes \ + installkernel + for dir in stand \ + lib/libc lib/libedit lib/ncurses \ + libexec/rtld-elf \ + bin/sh sbin/init sbin/shutdown sbin/sysctl; do + make -DNO_ROOT DESTDIR=${ROOTDIR} INSTALL="install -U" \ + WITHOUT_DEBUG_FILES= \ + WITHOUT_MAN= \ + WITHOUT_PROFILE= \ + WITHOUT_TESTS= \ + WITHOUT_TOOLCHAIN= \ + -C ${dir} install + done + + # Put loader in standard EFI location. + mv ${ROOTDIR}/boot/loader.efi ${ROOTDIR}/efi/boot/BOOTx64.EFI + + # Configuration files. + cat > ${ROOTDIR}/boot/loader.conf < ${ROOTDIR}/etc/rc <&2 + die "Cannot read UEFI firmware file ${OVMF}" +fi + +# Create a temp dir to hold the boot image. +ROOTDIR=$(mktemp -d -t ci-qemu-test-fat-root) +trap tempdir_cleanup EXIT SIGINT SIGHUP SIGTERM SIGQUIT + +# Populate the boot image in a temp dir. +( cd ${SRCTOP} && tempdir_setup ) + +# And, boot in QEMU. +: ${BOOTLOG:=${TMPDIR:-/tmp}/ci-qemu-test-boot.log} +timeout 300 \ + qemu-system-x86_64 -m 256M -nodefaults \ + -drive if=pflash,format=raw,readonly,file=${OVMF} \ + -serial stdio -vga none -nographic -monitor none \ + -snapshot -hda fat:${ROOTDIR} 2>&1 | tee ${BOOTLOG} + +# Check whether we succesfully booted... +if grep -q 'Hello world.' ${BOOTLOG}; then + echo "OK" +else + die "Did not boot successfully, see ${BOOTLOG}" +fi Property changes on: stable/12/tools/boot/ci-qemu-test.sh ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/12 =================================================================== --- stable/12 (revision 359148) +++ stable/12 (revision 359149) Property changes on: stable/12 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r346080,346317,346329-346330,346748,346961,352063,358472