tests: Add initial hyperkit tun test

This uses 'expect' instead of 'grep' because hyperkit is
a bit finicky with re-directing the output (it expects a
tty). 'expect' handles this and is installed on macOS by
default.

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
Rolf Neugebauer 2017-05-22 12:02:17 +01:00
parent e62e94a240
commit 822d179a2b
3 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,31 @@
#!/usr/bin/env expect
spawn linuxkit run hyperkit hyperkit-kernel
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,27 @@
#!/bin/sh
# SUMMARY: Check that the kernel+initrd image boots on hyperkit
# LABELS:
# AUTHOR: Rolf Neugebauer <rolf.neugebauer@docker.com>
set -e
set -x
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
NAME=hyperkit-kernel
clean_up() {
echo $(pwd)
# remove any files, containers, images etc
rm -rf "${NAME}"* || true
}
trap clean_up EXIT
moby build -name "${NAME}" test.yml
[ -f "${NAME}-kernel" ] || exit 1
[ -f "${NAME}-initrd.img" ] || exit 1
[ -f "${NAME}-cmdline" ]|| exit 1
./test.exp
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:f71c3b30ac1ba4ef16c160c89610fa4976f9752f
- linuxkit/runc:b0fb122e10dbb7e4e45115177a61a3f8d68c19a9
- linuxkit/containerd:60e2486a74c665ba4df57e561729aec20758daed
onboot:
- name: poweroff
image: "linuxkit/poweroff:a8f1e4ad8d459f1fdaad9e4b007512cb3b504ae8"
command: ["/bin/sh", "/poweroff.sh", "10"]
trust:
image:
- linuxkit/kernel
outputs:
- format: kernel+initrd