From owner-svn-src-stable-12@freebsd.org Thu Mar 19 18:15:11 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7285B26D1B8; Thu, 19 Mar 2020 18:15:11 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48jw723PLSz4Mcv; Thu, 19 Mar 2020 18:15:10 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 20AAFF073; Thu, 19 Mar 2020 18:15:10 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02JIFAFR078909; Thu, 19 Mar 2020 18:15:10 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02JIF9t3078908; Thu, 19 Mar 2020 18:15:09 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <202003191815.02JIF9t3078908@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Thu, 19 Mar 2020 18:15:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r359149 - stable/12/tools/boot X-SVN-Group: stable-12 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/12/tools/boot X-SVN-Commit-Revision: 359149 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Mar 2020 18:15:11 -0000 Author: emaste Date: Thu Mar 19 18:15:09 2020 New Revision: 359149 URL: https://svnweb.freebsd.org/changeset/base/359149 Log: MFC r346080: Add a smoke test QEMU boot script for CI And followon commits: r346317 (ian): Allow this test script to be run from within src/tools/boot r346329: Install some entropy for QEMU CI smoke test r346330: Put QEMU CI smoke test boot log in /tmp if TMPDIR not set r346748 (bcran): Fix tools/boot/ci-qemu-test.sh and make some improvements r346961: revert QEMU q35 platform use from r346748 r352063: ci-qemu-test: if firmware is not available, hint at pkg to install r358472: CI: print wired page count on boot Sponsored by: The FreeBSD Foundation Added: stable/12/tools/boot/ci-qemu-test.sh - copied, changed from r346080, head/tools/boot/ci-qemu-test.sh Modified: Directory Properties: stable/12/ (props changed) Copied and modified: stable/12/tools/boot/ci-qemu-test.sh (from r346080, head/tools/boot/ci-qemu-test.sh) ============================================================================== --- head/tools/boot/ci-qemu-test.sh Wed Apr 10 13:41:34 2019 (r346080, copy source) +++ stable/12/tools/boot/ci-qemu-test.sh Thu Mar 19 18:15:09 2020 (r359149) @@ -2,62 +2,111 @@ # 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. +# 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 -# Root directory for minimal FreeBSD installation. -ROOTDIR=$(pwd)/fat-root +die() +{ + echo "$*" 1>&2 + exit 1 +} -# 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 +tempdir_cleanup() +{ + trap - EXIT SIGINT SIGHUP SIGTERM SIGQUIT + rm -rf ${ROOTDIR} +} -# 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 +tempdir_setup() +{ + # Create minimal directory structure and populate it. + # Caller must cd ${SRCTOP} before calling this function. -# Put loader in standard EFI location. -mv $ROOTDIR/boot/loader.efi $ROOTDIR/efi/boot/BOOTx64.EFI + for dir in dev bin efi/boot etc lib libexec sbin usr/lib usr/libexec; do + mkdir -p ${ROOTDIR}/${dir} + done -# Configuration files. -cat > $ROOTDIR/boot/loader.conf < ${ROOTDIR}/boot/loader.conf < $ROOTDIR/etc/rc < ${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 -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 + 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