diff options
author | David Edmondson <dme@dme.org> | 2020-10-29 16:02:39 +0000 |
---|---|---|
committer | David Edmondson <david.edmondson@oracle.com> | 2020-12-08 16:54:19 +0000 |
commit | aaad17f88cb9fd3ddf750e29ed8f7d0155776e9d (patch) | |
tree | 3fef96f7f7cc37544e3dca12a41b053421e945ff | |
parent | 8317f3f19d1a9a749fe80232bf3729325fc4c6f2 (diff) | |
download | vmdb2-aaad17f88cb9fd3ddf750e29ed8f7d0155776e9d.tar.gz |
test: Add arm64 smoke test and corresponding yarn
-rwxr-xr-x | smoke-arm64.sh | 8 | ||||
-rw-r--r-- | smoke-arm64.yarn | 69 | ||||
-rw-r--r-- | smoke-uefi-arm64.vmdb | 76 | ||||
-rw-r--r-- | smoke.yarn | 4 |
4 files changed, 155 insertions, 2 deletions
diff --git a/smoke-arm64.sh b/smoke-arm64.sh new file mode 100755 index 0000000..b9bdefb --- /dev/null +++ b/smoke-arm64.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +set -eu + +tarball="$1" +shift + +yarn smoke-arm64.yarn --log=stderr --env ROOTFS_TARBALL="$tarball" "$@" diff --git a/smoke-arm64.yarn b/smoke-arm64.yarn new file mode 100644 index 0000000..c8296de --- /dev/null +++ b/smoke-arm64.yarn @@ -0,0 +1,69 @@ +# Smoke test vmdb2-built images + +This yarn file builds a basic image, and runs it under Qemu. The image +is configured to have a serial console enabled, and the scenario below +will log in as root (no password), and command the virtual machine to +power off. If this works, the image is at least minimally functional, +so the "smoke test" passes. + +More elaborate testing can be added, but smoke testing is enough for +now. + +To run this yarn file, you need to run it as root (since it needs to +build an image as root), and you need to run on a system where +qemu-system-aarch64 is installed. Additionally, you need to add the +following option to yarn: + + EXAMPLE + --env ROOTFS_TARBALL=/path/to/rootfs/tarball + +This means vmdb2 will use the given tarball when creating an image, +and if the tarball doesn't exist yet, it will create it. This makes +testing multiple time much faster. + + SCENARIO smoke test arm64 UEFI image + WHEN user runs vmdb smoke-uefi-arm64.vmdb --output smoke-uefi-arm64.img + THEN user can UEFI boot smoke-uefi-arm64.img and power it off from root shell + + IMPLEMENTS WHEN user runs vmdb (\S+) --output (\S+) + "$SRCDIR/vmdb2" "$SRCDIR/$MATCH_1" \ + --output "$DATADIR/$MATCH_2" \ + --log "$DATADIR/vmdb.log" \ + --verbose \ + --rootfs-tarball "$ROOTFS_TARBALL" + + IMPLEMENTS THEN user can UEFI boot (\S+) and power it off from root shell + cd "$DATADIR" + img="$MATCH_1" + cat << EOF > run.sh + cp /usr/share/AAVMF/AAVMF_VARS.fd . + qemu-system-aarch64 \ + -machine virt \ + -cpu cortex-a72 \ + -m 1024 \ + -drive if=pflash,format=raw,unit=0,file=/usr/share/AAVMF/AAVMF_CODE.fd,readonly=on \ + -drive if=pflash,format=raw,unit=1,file=AAVMF_VARS.fd \ + -drive format=raw,file="$img" \ + -nographic + EOF + chmod a+rx run.sh + cat << EOF > expect.txt + set timeout 300 + proc abort {} { + puts "ERROR ERROR\n" + exit 1 + } + spawn ./run.sh + expect "login: " + send "root\n" + expect "# " + send "poweroff\r" + set timeout 5 + expect { + "reboot: Power down" {puts poweroffing\n} + eof abort + timeout abort + } + expect eof + EOF + expect -d expect.txt > expect.out diff --git a/smoke-uefi-arm64.vmdb b/smoke-uefi-arm64.vmdb new file mode 100644 index 0000000..95e4c4b --- /dev/null +++ b/smoke-uefi-arm64.vmdb @@ -0,0 +1,76 @@ +steps: + - mkimg: "{{ output }}" + size: 4G + + - mklabel: gpt + device: "{{ output }}" + + - mkpart: primary + device: "{{ output }}" + start: 0% + end: 1G + tag: efifs + + - mkpart: primary + device: "{{ output }}" + start: 1G + end: 100% + tag: rootfs + + - kpartx: "{{ output }}" + + - mkfs: vfat + partition: efifs + + - mkfs: ext4 + partition: rootfs + label: smoke + + - mount: rootfs + + - create-dir: /smoke-dir + perm: 0777 + uid: 1000 + gid: 1000 + + - create-file: /smoke-create-file.txt + contents: No smoke here. + perm: 0777 + uid: 1000 + gid: 1000 + + - copy-file: /smoke-copy-file.txt + src: smoke-copy-file.txt + perm: 0777 + uid: 1000 + gid: 1000 + + - unpack-rootfs: rootfs + + - qemu-debootstrap: buster + arch: arm64 + mirror: http://deb.debian.org/debian + keyring: /usr/share/keyrings/debian-archive-keyring.gpg + target: rootfs + unless: rootfs_unpacked + + - apt: install + packages: + - linux-image-arm64 + tag: rootfs + unless: rootfs_unpacked + + - cache-rootfs: rootfs + unless: rootfs_unpacked + + - chroot: rootfs + shell: | + sed -i '/^root:[^:]*:/s//root::/' /etc/passwd + echo arm64-vmdb2 > /etc/hostname + + - fstab: rootfs + + - grub: uefi + tag: rootfs + efi: efifs + console: serial @@ -11,8 +11,8 @@ now. To run this yarn file, you need to run it as root (since it needs to build an image as root), and you need to run on an amd64 system (and -thus build an amd64 image). Additionally, you need to add the folloing -option to yarn: +thus build an amd64 image). Additionally, you need to add the +following option to yarn: EXAMPLE --env ROOTFS_TARBALL=/path/to/rootfs/tarball |