From d449ef6901f037310c1e59797ae600887a2acb1b Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Wed, 7 Jun 2017 15:53:40 +0100 Subject: [PATCH] tests: Run kernel tests on HyperKit when running on OSX With the updated HyperKit go bindings we can redirect the VM output and check for test results. Use this for all kernel tests as this speeds up running the tests on OSX. Also enable 'set -x' so we see the commands being executed and don't fail the test if the cleanup failed. Signed-off-by: Rolf Neugebauer --- test/cases/020_kernel/000_config_4.4.x/test.sh | 4 ++-- test/cases/020_kernel/001_config_4.9.x/test.sh | 4 ++-- test/cases/020_kernel/003_config_4.11.x/test.sh | 4 ++-- test/cases/020_kernel/010_kmod_4.9.x/test.sh | 11 +++++++---- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/test/cases/020_kernel/000_config_4.4.x/test.sh b/test/cases/020_kernel/000_config_4.4.x/test.sh index f05fc86d5..2ecd67ed8 100644 --- a/test/cases/020_kernel/000_config_4.4.x/test.sh +++ b/test/cases/020_kernel/000_config_4.4.x/test.sh @@ -10,13 +10,13 @@ set -e . "${RT_PROJECT_ROOT}/_lib/lib.sh" clean_up() { - find . -iname "test-kernel-config*" -not -iname "*.yml" -exec rm -rf {} \; + find . -iname "test-kernel-config*" -not -iname "*.yml" -exec rm -rf {} \; || true } trap clean_up EXIT # Test code goes here moby build -output kernel+initrd test-kernel-config.yml -RESULT="$(linuxkit run qemu -kernel test-kernel-config)" +RESULT="$(linuxkit run test-kernel-config)" echo "${RESULT}" | grep -q "suite PASSED" exit 0 diff --git a/test/cases/020_kernel/001_config_4.9.x/test.sh b/test/cases/020_kernel/001_config_4.9.x/test.sh index 1c047cae1..2ecd67ed8 100644 --- a/test/cases/020_kernel/001_config_4.9.x/test.sh +++ b/test/cases/020_kernel/001_config_4.9.x/test.sh @@ -10,13 +10,13 @@ set -e . "${RT_PROJECT_ROOT}/_lib/lib.sh" clean_up() { - find . -iname "test-kernel-config*" -not -iname "*.yml" -exec rm -rf {} \; + find . -iname "test-kernel-config*" -not -iname "*.yml" -exec rm -rf {} \; || true } trap clean_up EXIT # Test code goes here moby build -output kernel+initrd test-kernel-config.yml -RESULT="$(linuxkit run qemu test-kernel-config)" +RESULT="$(linuxkit run test-kernel-config)" echo "${RESULT}" | grep -q "suite PASSED" exit 0 diff --git a/test/cases/020_kernel/003_config_4.11.x/test.sh b/test/cases/020_kernel/003_config_4.11.x/test.sh index 1c047cae1..2ecd67ed8 100644 --- a/test/cases/020_kernel/003_config_4.11.x/test.sh +++ b/test/cases/020_kernel/003_config_4.11.x/test.sh @@ -10,13 +10,13 @@ set -e . "${RT_PROJECT_ROOT}/_lib/lib.sh" clean_up() { - find . -iname "test-kernel-config*" -not -iname "*.yml" -exec rm -rf {} \; + find . -iname "test-kernel-config*" -not -iname "*.yml" -exec rm -rf {} \; || true } trap clean_up EXIT # Test code goes here moby build -output kernel+initrd test-kernel-config.yml -RESULT="$(linuxkit run qemu test-kernel-config)" +RESULT="$(linuxkit run test-kernel-config)" echo "${RESULT}" | grep -q "suite PASSED" exit 0 diff --git a/test/cases/020_kernel/010_kmod_4.9.x/test.sh b/test/cases/020_kernel/010_kmod_4.9.x/test.sh index 50f6079ca..9a08df964 100644 --- a/test/cases/020_kernel/010_kmod_4.9.x/test.sh +++ b/test/cases/020_kernel/010_kmod_4.9.x/test.sh @@ -13,7 +13,7 @@ IMAGE_NAME="kmod-test" clean_up() { docker rmi ${IMAGE_NAME} || true - find . -iname "kmod*" -not -iname "*.yml" -exec rm -rf {} \; + find . -iname "kmod*" -not -iname "*.yml" -exec rm -rf {} \; || true } trap clean_up EXIT @@ -21,7 +21,10 @@ trap clean_up EXIT docker pull linuxkit/kernel:4.9.x # Build a package docker build -t ${IMAGE_NAME} . -# Build a LinuxKit image with kernel module (and test script) + +# Build and run a LinuxKit image with kernel module (and test script) moby build -output kernel+initrd kmod.yml -# Run it -linuxkit run qemu kmod | grep -q "Hello LinuxKit" +RESULT="$(linuxkit run kmod)" +echo "${RESULT}" | grep -q "Hello LinuxKit" + +exit 0