tests: Add a test for running qemu in a container

The qemu backend defaults to running against a locally installed
qemu but falls back to running in a container if qemu is not
installed. This test explicitly tests that the containerised
qemu backend works only if there is a locally installed qemu.

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
Rolf Neugebauer 2017-05-19 11:34:19 +01:00
parent 0fa440938a
commit e1920b4f22
2 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,35 @@
#!/bin/sh
# SUMMARY: Check that qemu runs containerised
# LABELS:
# AUTHOR: Rolf Neugebauer <rolf.neugebauer@docker.com>
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
NAME=qemu-kernel
clean_up() {
# remove any files, containers, images etc
rm -rf ${NAME}* || true
}
trap clean_up EXIT
# check if qemu is installed locally
QEMU=$(command -v qemu-system-x86_64 || true)
if [ -z "${QEMU}" ]; then
# No qemu installed so don't bother to test as all the other
# qemu tests would have been run containerised
echo "No locally installed qemu"
exit $RT_CANCEL
fi
moby build -name "${NAME}" test.yml
[ -f "${NAME}-kernel" ] || exit 1
[ -f "${NAME}-initrd.img" ] || exit 1
[ -f "${NAME}-cmdline" ]|| exit 1
linuxkit run qemu -containerized "${NAME}" | grep -q "Welcome to LinuxKit"
exit 0

View File

@ -0,0 +1,16 @@
kernel:
image: "linuxkit/kernel:4.9.x"
cmdline: "console=ttyS0 console=tty0 page_poison=1"
init:
- linuxkit/init:cbd7ae748f0a082516501a3e914fa0c924ee941e
- linuxkit/runc:24dfe632ed3ff53a026ee3fac046fd544434e2d6
- linuxkit/containerd:f1130450206d4f64f0ddc13d15bb68435aa1ff61
onboot:
- name: poweroff
image: "linuxkit/poweroff:a8f1e4ad8d459f1fdaad9e4b007512cb3b504ae8"
command: ["/bin/sh", "/poweroff.sh", "3"]
trust:
image:
- linuxkit/kernel
outputs:
- format: kernel+initrd