tests: Add build/qemu/hyperkit tests for kernel+squashfs

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
Rolf Neugebauer 2018-04-16 18:27:43 +01:00
parent 59df6426e4
commit c1447193b3
11 changed files with 129 additions and 0 deletions

View File

@ -0,0 +1,24 @@
#!/bin/sh
# SUMMARY: Check that kernel+initrd output format is generated
# LABELS:
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
NAME=check
clean_up() {
rm -f ${NAME}*
}
trap clean_up EXIT
linuxkit build -format kernel+squashfs -name "${NAME}" ../test.yml
[ -f "${NAME}-kernel" ] || exit 1
[ -f "${NAME}-squashfs.img" ] || exit 1
[ -f "${NAME}-cmdline" ] || exit 1
exit 0

View File

@ -0,0 +1,24 @@
#!/bin/sh
# SUMMARY: Check that the kernel+squashfs image boots in qemu
# LABELS:
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
NAME=qemu-squashfs
clean_up() {
rm -rf ${NAME}-*
}
trap clean_up EXIT
linuxkit build -format kernel+squashfs -name "${NAME}" test.yml
[ -f "${NAME}-kernel" ] || exit 1
[ -f "${NAME}-squashfs.img" ] || exit 1
[ -f "${NAME}-cmdline" ]|| exit 1
linuxkit run qemu -squashfs "${NAME}" | grep -q "Welcome to LinuxKit"
exit 0

View File

@ -0,0 +1,13 @@
kernel:
image: linuxkit/kernel:4.14.34
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:v0.3
- linuxkit/runc:v0.3
onboot:
- name: poweroff
image: linuxkit/poweroff:5740687bf0a6a0480922c0f59b3a4ca77c866cae
command: ["/bin/sh", "/poweroff.sh", "10"]
trust:
org:
- linuxkit

View File

@ -0,0 +1,31 @@
#!/usr/bin/env expect
spawn linuxkit run hyperkit -squashfs hyperkit-squashfs
set pid [exp_pid]
set timeout 30
expect {
timeout {
puts "FAILED boot"
exec kill -9 $pid
exit 1
}
"Welcome to LinuxKit" {
puts "SUCCESS boot"
}
}
expect {
timeout {
puts "FAILED poweroff"
exec kill -9 $pid
exit 1
}
"Power down" {
puts "SUCCESS poweroff"
}
eof {
puts "SUCCESS poweroff"
}
}
set waitval [wait -i $spawn_id]
set exval [lindex $waitval 3]
exit $exval

View File

@ -0,0 +1,24 @@
#!/bin/sh
# SUMMARY: Check that the kernel+squashfs image boots on hyperkit
# LABELS:
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
NAME=hyperkit-squashfs
clean_up() {
rm -rf ${NAME}-*
}
trap clean_up EXIT
linuxkit build -format kernel+squashfs -name "${NAME}" test.yml
[ -f "${NAME}-kernel" ] || exit 1
[ -f "${NAME}-squashfs.img" ] || exit 1
[ -f "${NAME}-cmdline" ]|| exit 1
./test.exp
exit 0

View File

@ -0,0 +1,13 @@
kernel:
image: linuxkit/kernel:4.14.34
cmdline: "console=ttyS0"
init:
- linuxkit/init:v0.3
- linuxkit/runc:v0.3
onboot:
- name: poweroff
image: linuxkit/poweroff:5740687bf0a6a0480922c0f59b3a4ca77c866cae
command: ["/bin/sh", "/poweroff.sh", "10"]
trust:
org:
- linuxkit