mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-19 17:26:28 +00:00
Merge pull request #1869 from rneugeba/test
Various improvements to tests
This commit is contained in:
commit
608fbb3f15
@ -14,7 +14,7 @@ NAME=qemu-kernel
|
||||
|
||||
clean_up() {
|
||||
# remove any files, containers, images etc
|
||||
rm -rf "${NAME}*" || true
|
||||
rm -rf ${NAME}* || true
|
||||
}
|
||||
|
||||
trap clean_up EXIT
|
||||
|
@ -13,7 +13,7 @@ set -e
|
||||
NAME=qemu-iso
|
||||
|
||||
clean_up() {
|
||||
rm -rf "${NAME}*" || true
|
||||
rm -rf ${NAME}* || true
|
||||
}
|
||||
|
||||
trap clean_up EXIT
|
||||
|
@ -14,14 +14,14 @@ NAME=qemu-efi
|
||||
|
||||
clean_up() {
|
||||
# remove any files, containers, images etc
|
||||
rm -rf "${NAME}*" || true
|
||||
rm -rf ${NAME}* || true
|
||||
}
|
||||
|
||||
trap clean_up EXIT
|
||||
|
||||
if command -v qemu; then
|
||||
if command -v qemu-system-x86_64; then
|
||||
if [ ! -f /usr/share/ovmf/bios.bin ]; then
|
||||
exit RT_CANCEL
|
||||
exit $RT_CANCEL
|
||||
fi
|
||||
fi
|
||||
|
||||
|
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
|
31
test/cases/010_platforms/010_hyperkit/000_run_kernel/test.exp
Executable file
31
test/cases/010_platforms/010_hyperkit/000_run_kernel/test.exp
Executable 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
|
27
test/cases/010_platforms/010_hyperkit/000_run_kernel/test.sh
Normal file
27
test/cases/010_platforms/010_hyperkit/000_run_kernel/test.sh
Normal 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
|
@ -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
|
@ -0,0 +1,16 @@
|
||||
kernel:
|
||||
image: "linuxkit/kernel:4.4.x"
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:cbd7ae748f0a082516501a3e914fa0c924ee941e
|
||||
- linuxkit/runc:24dfe632ed3ff53a026ee3fac046fd544434e2d6
|
||||
- linuxkit/containerd:f1130450206d4f64f0ddc13d15bb68435aa1ff61
|
||||
onboot:
|
||||
- name: check-kernel-config
|
||||
image: "linuxkit/test-kernel-config:ecff41279ccbc408079a3996a956432651c6eb9c"
|
||||
readonly: true
|
||||
- name: poweroff
|
||||
image: "linuxkit/poweroff:a8f1e4ad8d459f1fdaad9e4b007512cb3b504ae8"
|
||||
command: ["/bin/sh", "/poweroff.sh", "3"]
|
||||
outputs:
|
||||
- format: kernel+initrd
|
@ -5,19 +5,7 @@ init:
|
||||
- linuxkit/init:cbd7ae748f0a082516501a3e914fa0c924ee941e
|
||||
- linuxkit/runc:24dfe632ed3ff53a026ee3fac046fd544434e2d6
|
||||
- linuxkit/containerd:f1130450206d4f64f0ddc13d15bb68435aa1ff61
|
||||
- linuxkit/ca-certificates:4e9a83e890e6477dcd25029fc4f1ced61d0642f4
|
||||
onboot:
|
||||
- name: dhcpcd
|
||||
image: "linuxkit/dhcpcd:cb96c09a33c166eca6530f166f0f79927c3e83b0"
|
||||
binds:
|
||||
- /var:/var
|
||||
- /tmp:/etc
|
||||
capabilities:
|
||||
- CAP_NET_ADMIN
|
||||
- CAP_NET_BIND_SERVICE
|
||||
- CAP_NET_RAW
|
||||
net: host
|
||||
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
|
||||
- name: check-kernel-config
|
||||
image: "linuxkit/test-kernel-config:ecff41279ccbc408079a3996a956432651c6eb9c"
|
||||
readonly: true
|
23
test/cases/020_kernel/001_config_4.9.x/test.sh
Normal file
23
test/cases/020_kernel/001_config_4.9.x/test.sh
Normal file
@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Sanity check on the kernel config file
|
||||
# LABELS:
|
||||
# REPEAT:
|
||||
# AUTHOR: Dave Tucker <dt@docker.com>
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
clean_up() {
|
||||
find . -iname "test-kernel-config*" -not -iname "*.yml" -exec rm -rf {} \;
|
||||
}
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
moby build test-kernel-config
|
||||
RESULT="$(linuxkit run qemu test-kernel-config)"
|
||||
echo "${RESULT}" | grep -q "suite PASSED"
|
||||
|
||||
exit 0
|
@ -0,0 +1,16 @@
|
||||
kernel:
|
||||
image: "linuxkit/kernel:4.10.x"
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:cbd7ae748f0a082516501a3e914fa0c924ee941e
|
||||
- linuxkit/runc:24dfe632ed3ff53a026ee3fac046fd544434e2d6
|
||||
- linuxkit/containerd:f1130450206d4f64f0ddc13d15bb68435aa1ff61
|
||||
onboot:
|
||||
- name: check-kernel-config
|
||||
image: "linuxkit/test-kernel-config:ecff41279ccbc408079a3996a956432651c6eb9c"
|
||||
readonly: true
|
||||
- name: poweroff
|
||||
image: "linuxkit/poweroff:a8f1e4ad8d459f1fdaad9e4b007512cb3b504ae8"
|
||||
command: ["/bin/sh", "/poweroff.sh", "3"]
|
||||
outputs:
|
||||
- format: kernel+initrd
|
23
test/cases/020_kernel/002_config_4.10.x/test.sh
Normal file
23
test/cases/020_kernel/002_config_4.10.x/test.sh
Normal file
@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Sanity check on the kernel config file
|
||||
# LABELS:
|
||||
# REPEAT:
|
||||
# AUTHOR: Dave Tucker <dt@docker.com>
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
clean_up() {
|
||||
find . -iname "test-kernel-config*" -not -iname "*.yml" -exec rm -rf {} \;
|
||||
}
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
moby build test-kernel-config
|
||||
RESULT="$(linuxkit run qemu test-kernel-config)"
|
||||
echo "${RESULT}" | grep -q "suite PASSED"
|
||||
|
||||
exit 0
|
@ -0,0 +1,16 @@
|
||||
kernel:
|
||||
image: "linuxkit/kernel:4.11.x"
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:cbd7ae748f0a082516501a3e914fa0c924ee941e
|
||||
- linuxkit/runc:24dfe632ed3ff53a026ee3fac046fd544434e2d6
|
||||
- linuxkit/containerd:f1130450206d4f64f0ddc13d15bb68435aa1ff61
|
||||
onboot:
|
||||
- name: check-kernel-config
|
||||
image: "linuxkit/test-kernel-config:ecff41279ccbc408079a3996a956432651c6eb9c"
|
||||
readonly: true
|
||||
- name: poweroff
|
||||
image: "linuxkit/poweroff:a8f1e4ad8d459f1fdaad9e4b007512cb3b504ae8"
|
||||
command: ["/bin/sh", "/poweroff.sh", "3"]
|
||||
outputs:
|
||||
- format: kernel+initrd
|
23
test/cases/020_kernel/003_config_4.11.x/test.sh
Normal file
23
test/cases/020_kernel/003_config_4.11.x/test.sh
Normal file
@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Sanity check on the kernel config file
|
||||
# LABELS:
|
||||
# REPEAT:
|
||||
# AUTHOR: Dave Tucker <dt@docker.com>
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
clean_up() {
|
||||
find . -iname "test-kernel-config*" -not -iname "*.yml" -exec rm -rf {} \;
|
||||
}
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
moby build test-kernel-config
|
||||
RESULT="$(linuxkit run qemu test-kernel-config)"
|
||||
echo "${RESULT}" | grep -q "suite PASSED"
|
||||
|
||||
exit 0
|
Loading…
Reference in New Issue
Block a user