mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-21 10:09:07 +00:00
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:
parent
0fa440938a
commit
e1920b4f22
35
test/cases/010_platforms/000_qemu/100_container/test.sh
Normal file
35
test/cases/010_platforms/000_qemu/100_container/test.sh
Normal 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
|
16
test/cases/010_platforms/000_qemu/100_container/test.yml
Normal file
16
test/cases/010_platforms/000_qemu/100_container/test.yml
Normal 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
|
Loading…
Reference in New Issue
Block a user