svn commit: r346080 - head/tools/boot

Ed Maste emaste at FreeBSD.org
Wed Apr 10 13:41:36 UTC 2019


Author: emaste
Date: Wed Apr 10 13:41:34 2019
New Revision: 346080
URL: https://svnweb.freebsd.org/changeset/base/346080

Log:
  Add a smoke test QEMU boot script for CI
  
  Reviewed by:	imp, lwhsu (earlier)
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D19661

Added:
  head/tools/boot/ci-qemu-test.sh   (contents, props changed)

Added: head/tools/boot/ci-qemu-test.sh
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/boot/ci-qemu-test.sh	Wed Apr 10 13:41:34 2019	(r346080)
@@ -0,0 +1,63 @@
+#!/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.
+#
+# $FreeBSD$
+
+set -e
+
+# Root directory for minimal FreeBSD installation.
+ROOTDIR=$(pwd)/fat-root
+
+# Create minimal directory structure.
+rm -f $ROOTDIR/efi/boot/BOOTx64.EFI
+for dir in dev bin efi/boot etc lib libexec sbin 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; do
+	make -DNO_ROOT DESTDIR=$ROOTDIR INSTALL="install -U" \
+	    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 <<EOF
+vfs.root.mountfrom="msdosfs:/dev/ada0s1"
+autoboot_delay=-1
+boot_verbose=YES
+EOF
+cat > $ROOTDIR/etc/rc <<EOF
+#!/bin/sh
+
+echo "Hello world."
+/sbin/shutdown -p now
+EOF
+
+# Remove unnecessary files to keep FAT filesystem size down.
+rm -rf $ROOTDIR/METALOG $ROOTDIR/usr/lib
+
+# And, boot in QEMU.
+timeout 300 \
+    qemu-system-x86_64 -m 256M -bios OVMF.fd \
+    -serial stdio -vga none -nographic -monitor none \
+    -snapshot -hda fat:$ROOTDIR 2>&1 | tee boot.log
+grep -q 'Hello world.' boot.log
+echo OK


More information about the svn-src-head mailing list