mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-18 17:01:07 +00:00
Add a test suite ✅
This adds a test suite to be executed using `linuxkit/rtf`. This is installed in the top-level Makefile The tests are written in shell script and cover the following cases: - Kernel Config is OK! - Kernel Modules can be built and loaded - QEMU can build and run kernel+initrd, iso-bios and iso-uefi - That we can build for all other supported output formats - That all of the examples in `./examples` can be built - The LTP tests can be run (if `-l slow` is provided) The virtsock and docker-bench tests were migrated but no test has been written as yet as AFAICT they are still a WIP Signed-off-by: Dave Tucker <dt@docker.com>
This commit is contained in:
parent
7027dc814c
commit
ce2bdea399
2
.gitignore
vendored
2
.gitignore
vendored
@ -11,6 +11,6 @@ Dockerfile.media
|
||||
*.vhdx
|
||||
*.efi
|
||||
*.qcow2
|
||||
*-kernel
|
||||
*-kernel$
|
||||
*-cmdline
|
||||
artifacts/*
|
||||
|
12
Makefile
12
Makefile
@ -1,5 +1,5 @@
|
||||
.PHONY: default all
|
||||
default: bin/moby bin/linuxkit
|
||||
default: bin/moby bin/linuxkit bin/rtf
|
||||
all: default
|
||||
|
||||
VERSION="0.0" # dummy for now
|
||||
@ -24,6 +24,15 @@ bin/moby: | bin
|
||||
rm tmp_moby_bin.tar
|
||||
touch $@
|
||||
|
||||
RTF_COMMIT=3ced00340aacfc1932e8c03281bf3bfc586c147c
|
||||
RTF_CMD=github.com/linuxkit/rtf/cmd
|
||||
bin/rtf: | bin
|
||||
docker run --rm --log-driver=none $(CROSS) $(GO_COMPILE) --clone-path github.com/linuxkit/rtf --clone https://github.com/linuxkit/rtf.git --commit $(RTF_COMMIT) --package github.com/linuxkit/rtf --ldflags "-X $(RTF_CMD).GitCommit=$(RTF_COMMIT) -X $(RTF_CMD).Version=$(VERSION)" -o $@ > tmp_rtf_bin.tar
|
||||
tar xf tmp_rtf_bin.tar > $@
|
||||
rm tmp_rtf_bin.tar
|
||||
touch $@
|
||||
|
||||
|
||||
LINUXKIT_DEPS=$(wildcard src/cmd/linuxkit/*.go) Makefile vendor.conf
|
||||
bin/linuxkit: $(LINUXKIT_DEPS) | bin
|
||||
tar cf - vendor -C src/cmd/linuxkit . | docker run --rm --net=none --log-driver=none -i $(CROSS) $(GO_COMPILE) --package github.com/linuxkit/linuxkit --ldflags "-X main.GitCommit=$(GIT_COMMIT) -X main.Version=$(VERSION)" -o $@ > tmp_linuxkit_bin.tar
|
||||
@ -66,4 +75,3 @@ ci-pr:
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf bin *.log *-kernel *-cmdline *.img *.iso *.gz *.qcow2 *.vhd *.vmx *.vmdk *.tar
|
||||
$(MAKE) -C test clean
|
||||
|
29
README.md
29
README.md
@ -39,14 +39,39 @@ You can use `linuxkit run <name>` to execute the image you created with `moby bu
|
||||
This will use a suitable backend for your platform or you can choose one, for example VMWare.
|
||||
See `linuxkit run --help`.
|
||||
|
||||
`make test` or `make test-hyperkit` will run the test suite
|
||||
|
||||
Additional, platform specific information is available for:
|
||||
- [macOS](docs/mac.md)
|
||||
- [Google Cloud](docs/gcp.md)
|
||||
|
||||
We'll add more detailed docs for other platforms in the future.
|
||||
|
||||
#### Running the Tests
|
||||
|
||||
The test suite uses [`rtf`](https://github.com/linuxkit/rtf)
|
||||
To install this you should use `make bin/rtf && make install`.
|
||||
|
||||
To run the test suite:
|
||||
|
||||
```
|
||||
cd test
|
||||
rtf -x run
|
||||
```
|
||||
|
||||
This will run the tests and put the results in a the `_results` directory!
|
||||
|
||||
Run control is handled using labels and with pattern matching.
|
||||
To run add a label you may use:
|
||||
|
||||
```
|
||||
rtf -x -l slow run
|
||||
```
|
||||
|
||||
To run tests that match the pattern `linuxkit.examples` you would use the following command:
|
||||
|
||||
```
|
||||
rtf -x run linuxkit.examples
|
||||
```
|
||||
|
||||
## Building your own customised image
|
||||
|
||||
To customise, copy or modify the [`linuxkit.yml`](linuxkit.yml) to your own `file.yml` or use one of the [examples](examples/) and then run `moby build file.yml` to
|
||||
|
2
test/.gitignore
vendored
Normal file
2
test/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
_results
|
||||
cases/_tmp
|
@ -1,11 +1,13 @@
|
||||
.PHONY: default pr all
|
||||
|
||||
default: check-deps kernel-config
|
||||
pr: check-deps kernel-config ../artifacts/test.img.tar.gz
|
||||
all: check-deps kernel-config ltp ../artifacts/test.img.tar.gz ../artifacts/test-ltp.img.tar.gz
|
||||
default: check-deps test
|
||||
pr: check-deps test-pr
|
||||
# TODO: all should point to test-all once ltp is no longer required
|
||||
all: check-deps test-pr ltp
|
||||
|
||||
MOBY:=$(shell command -v moby 2> /dev/null)
|
||||
LINUXKIT:=$(shell command -v linuxkit 2> /dev/null)
|
||||
RTF:=$(shell command -v rtf 2> /dev/null)
|
||||
|
||||
.PHONY: check-deps
|
||||
check-deps:
|
||||
@ -15,54 +17,31 @@ endif
|
||||
ifndef LINUXKIT
|
||||
$(error "linuxkit binary not found. please install it.")
|
||||
endif
|
||||
ifndef RTF
|
||||
$(error "rtf is not available. please install it!")
|
||||
endif
|
||||
|
||||
|
||||
# TODO: Remove this section once we no longer depend on this in CI
|
||||
### -------
|
||||
define check_test_log
|
||||
@cat $1 |grep -q 'test suite PASSED'
|
||||
endef
|
||||
|
||||
../artifacts:
|
||||
mkdir -p $@
|
||||
|
||||
test-kernel-config-initrd.img: $(MOBY) cases/test-kernel-config.yml
|
||||
$(MOBY) build --pull cases/test-kernel-config.yml
|
||||
|
||||
# uses qemu
|
||||
.PHONY: kernel-config
|
||||
kernel-config: $(LINUXKIT) test-kernel-config-initrd.img test-kernel-config-kernel test-kernel-config-cmdline
|
||||
$(LINUXKIT) run qemu test-kernel-config 2>&1 | tee test.log
|
||||
$(call check_test_log, test.log)
|
||||
|
||||
# qemu only at this time
|
||||
.PHONY: qemu-efi
|
||||
efi: $(LINUXKIT) test-kernel-config-efi.iso
|
||||
$(LINUXKIT) run qemu -uefi test-kernel-config | tee test-efi.log
|
||||
$(call check_test_log, test-efi.log)
|
||||
|
||||
# For GCP tests
|
||||
../artifacts/test.img.tar.gz: test-kernel-config.img.tar.gz | ../artifacts
|
||||
mv test-kernel-config.img.tar.gz ../artifacts/test.img.tar.gz
|
||||
|
||||
.PHONY: gcp
|
||||
gcp: export CLOUDSDK_IMAGE_NAME?=test-kernel-config
|
||||
gcp: $(LINUXKIT) ../test.img.tar.gz
|
||||
$(LINUXKIT) push gcp ../artifacts/test.img.tar.gz
|
||||
$(LINUXKIT) run gcp $(CLOUDSDK_IMAGE_NAME) | tee test-gcp.log
|
||||
$(call check_test_log, test-gcp.log)
|
||||
|
||||
# For LTP tests
|
||||
test-ltp.img.tar.gz: $(MOBY) cases/test-ltp.yml
|
||||
$(MOBY) build --pull cases/test-ltp.yml
|
||||
|
||||
../artifacts/test-ltp.img.tar.gz: test-ltp.img.tar.gz | ../artifacts
|
||||
mv test-ltp.img.tar.gz ../artifacts
|
||||
|
||||
.PHONY: ltp
|
||||
ltp: export CLOUDSDK_IMAGE_NAME?=test-ltp
|
||||
ltp: $(LINUXKIT) test-ltp.img.tar.gz
|
||||
$(LINUXKIT) push gcp ../artifacts/test-ltp.img.tar.gz
|
||||
$(MOBY) build --pull cases/020_stress/000_ltp/test-ltp.yml
|
||||
$(LINUXKIT) push gcp test-ltp.img.tar.gz
|
||||
$(LINUXKIT) run gcp -skip-cleanup -machine n1-highcpu-4 $(CLOUDSDK_IMAGE_NAME) | tee test-ltp.log
|
||||
$(call check_test_log, test-ltp.log)
|
||||
### ------
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf bin *.log *-kernel *-cmdline *.img *.iso *.tar.gz *.qcow2 *.vhd *.vmx *.vmdk
|
||||
test:
|
||||
@rtf -l build -x run
|
||||
|
||||
test-pr:
|
||||
@rtf -vvv -l build -x run
|
||||
|
||||
test-all:
|
||||
@rtf -vvv -x -l build,slow run
|
||||
|
19
test/README.md
Normal file
19
test/README.md
Normal file
@ -0,0 +1,19 @@
|
||||
Linuxkit Tests Labels
|
||||
=====================
|
||||
|
||||
## Usage of Artifacts vs Temporary Directory
|
||||
|
||||
As the Build Machines have no secrets they will not be able to test running the build output on any cloud providers.
|
||||
In this instance, the build tests should copy their output to the `LINUXKIT_ARTIFACTS_DIRECTORY`
|
||||
|
||||
## Labels
|
||||
|
||||
The `gcp` label is applied when the system where the tests are being run meets the requirements for using Google Cloud Platform.
|
||||
|
||||
These requirements are:
|
||||
- The system has the necessary `CLOUDSDK_*` environment variables exported
|
||||
- The system has either keys for a GCP service account or is able to use application default credentials
|
||||
|
||||
The `packet.net` label is applied when a system is able to create machines on Packet.net
|
||||
|
||||
The `vmware` label is used when the machine has VMware Workstation or Fusion installed
|
@ -21,7 +21,6 @@ onboot:
|
||||
- name: check-kernel-config
|
||||
image: "linuxkit/test-kernel-config:ecff41279ccbc408079a3996a956432651c6eb9c"
|
||||
readonly: true
|
||||
services:
|
||||
- name: poweroff
|
||||
image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084"
|
||||
pid: host
|
||||
@ -31,6 +30,3 @@ services:
|
||||
readonly: true
|
||||
outputs:
|
||||
- format: kernel+initrd
|
||||
- format: iso-bios
|
||||
- format: iso-efi
|
||||
- format: gcp-img
|
23
test/cases/000_config/000_kernel/test.sh
Normal file
23
test/cases/000_config/000_kernel/test.sh
Normal file
@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Test the kernel configuration is suitable for running Docker
|
||||
# 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
|
@ -13,5 +13,12 @@ onboot:
|
||||
- /lib/modules:/lib/modules
|
||||
capabilities:
|
||||
- all
|
||||
- name: poweroff
|
||||
image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084"
|
||||
pid: host
|
||||
command: ["/bin/sh", "/poweroff.sh", "3"]
|
||||
capabilities:
|
||||
- CAP_SYS_BOOT
|
||||
readonly: true
|
||||
outputs:
|
||||
- format: kernel+initrd
|
28
test/cases/000_config/010_kmod/test.sh
Normal file
28
test/cases/000_config/010_kmod/test.sh
Normal file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Test build and insertion of kernel modules
|
||||
# LABELS:
|
||||
# REPEAT:
|
||||
# AUTHOR: Rolf Neugebauer <rolf.neugebauer@docker.com>
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
IMAGE_NAME="kmod-test"
|
||||
|
||||
clean_up() {
|
||||
docker rmi ${IMAGE_NAME} || true
|
||||
find . -iname "kmod*" -not -iname "*.yml" -exec rm -rf {} \;
|
||||
}
|
||||
trap clean_up EXIT
|
||||
|
||||
# Make sure we have the latest kernel image
|
||||
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)
|
||||
moby build kmod
|
||||
# Run it
|
||||
linuxkit run qemu kmod | grep -q "Hello LinuxKit"
|
37
test/cases/000_config/group.sh
Normal file
37
test/cases/000_config/group.sh
Normal file
@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: LinuxKit configuration tests
|
||||
# LABELS:
|
||||
# For the top level group.sh also specify a 'NAME:' comment
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
#. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
|
||||
group_init() {
|
||||
# Group initialisation code goes here
|
||||
return 0
|
||||
}
|
||||
|
||||
group_deinit() {
|
||||
# Group de-initialisation code goes here
|
||||
return 0
|
||||
}
|
||||
|
||||
CMD=$1
|
||||
case $CMD in
|
||||
init)
|
||||
group_init
|
||||
res=$?
|
||||
;;
|
||||
deinit)
|
||||
group_deinit
|
||||
res=$?
|
||||
;;
|
||||
*)
|
||||
res=1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit $res
|
||||
|
28
test/cases/010_platforms/000_qemu/000_build/test.sh
Normal file
28
test/cases/010_platforms/000_qemu/000_build/test.sh
Normal file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Test building an image for qemu
|
||||
# LABELS: build
|
||||
# AUTHOR: Dave Tucker <dt@docker.com>
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
IMAGE_NAME=test-qemu-build
|
||||
|
||||
clean_up() {
|
||||
# remove any files, containers, images etc
|
||||
find . -iname "${IMAGE_NAME}*" -not -iname "*.yml" -exec rm {} \;
|
||||
}
|
||||
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
moby build -name "${IMAGE_NAME}" test.yml
|
||||
[ -f "${IMAGE_NAME}-kernel" ] || exit 1
|
||||
[ -f "${IMAGE_NAME}-initrd.img" ] || exit 1
|
||||
[ -f "${IMAGE_NAME}-cmdline" ]|| exit 1
|
||||
|
||||
find . -iname "${IMAGE_NAME}-*" -exec cp {} "${LINUXKIT_TMPDIR}/{}" \;
|
||||
exit 0
|
31
test/cases/010_platforms/000_qemu/000_build/test.yml
Normal file
31
test/cases/010_platforms/000_qemu/000_build/test.yml
Normal file
@ -0,0 +1,31 @@
|
||||
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: dhcpcd
|
||||
image: "linuxkit/dhcpcd:8837289b78ecd80f59524883085424e115dd0b3a"
|
||||
binds:
|
||||
- /var:/var
|
||||
- /tmp/etc:/etc
|
||||
capabilities:
|
||||
- CAP_NET_ADMIN
|
||||
- CAP_NET_BIND_SERVICE
|
||||
- CAP_NET_RAW
|
||||
net: host
|
||||
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
|
||||
- name: poweroff
|
||||
image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084"
|
||||
pid: host
|
||||
command: ["/bin/sh", "/poweroff.sh", "10"]
|
||||
capabilities:
|
||||
- CAP_SYS_BOOT
|
||||
readonly: true
|
||||
trust:
|
||||
image:
|
||||
- linuxkit/kernel
|
||||
outputs:
|
||||
- format: kernel+initrd
|
24
test/cases/010_platforms/000_qemu/001_run/test.sh
Normal file
24
test/cases/010_platforms/000_qemu/001_run/test.sh
Normal file
@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Test running an image with qemu
|
||||
# LABELS:
|
||||
# AUTHOR: Dave Tucker <dt@docker.com>
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
IMAGE_NAME=test-qemu-build
|
||||
|
||||
clean_up() {
|
||||
# remove any files, containers, images etc
|
||||
rm -rf "${LINUXKIT_TMPDIR:?}/${IMAGE_NAME:?}*" || true
|
||||
}
|
||||
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
[ -f "${LINUXKIT_TMPDIR}/${IMAGE_NAME}-kernel" ] || exit 1
|
||||
linuxkit run qemu "${LINUXKIT_TMPDIR}/${IMAGE_NAME}" | grep -q "Welcome to LinuxKit"
|
||||
exit 0
|
26
test/cases/010_platforms/000_qemu/010_build_iso/test.sh
Normal file
26
test/cases/010_platforms/000_qemu/010_build_iso/test.sh
Normal file
@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Test building an ISO image for qemu
|
||||
# LABELS: build
|
||||
# AUTHOR: Dave Tucker <dt@docker.com>
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
IMAGE_NAME=test-qemu-build
|
||||
|
||||
clean_up() {
|
||||
# remove any files, containers, images etc
|
||||
find . -iname "${IMAGE_NAME}*" -not -iname "*.yml" -exec rm {} \;
|
||||
}
|
||||
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
moby build -name "${IMAGE_NAME}" test.yml
|
||||
[ -f "${IMAGE_NAME}.iso" ] || exit 1
|
||||
|
||||
cp "${IMAGE_NAME}.iso" "${LINUXKIT_TMPDIR}/"
|
||||
exit 0
|
31
test/cases/010_platforms/000_qemu/010_build_iso/test.yml
Normal file
31
test/cases/010_platforms/000_qemu/010_build_iso/test.yml
Normal file
@ -0,0 +1,31 @@
|
||||
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: dhcpcd
|
||||
image: "linuxkit/dhcpcd:8837289b78ecd80f59524883085424e115dd0b3a"
|
||||
binds:
|
||||
- /var:/var
|
||||
- /tmp/etc:/etc
|
||||
capabilities:
|
||||
- CAP_NET_ADMIN
|
||||
- CAP_NET_BIND_SERVICE
|
||||
- CAP_NET_RAW
|
||||
net: host
|
||||
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
|
||||
- name: poweroff
|
||||
image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084"
|
||||
pid: host
|
||||
command: ["/bin/sh", "/poweroff.sh", "10"]
|
||||
capabilities:
|
||||
- CAP_SYS_BOOT
|
||||
readonly: true
|
||||
trust:
|
||||
image:
|
||||
- linuxkit/kernel
|
||||
outputs:
|
||||
- format: iso-bios
|
24
test/cases/010_platforms/000_qemu/011_run_iso/test.sh
Normal file
24
test/cases/010_platforms/000_qemu/011_run_iso/test.sh
Normal file
@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Test running an ISO image with qemu
|
||||
# LABELS:
|
||||
# AUTHOR: Dave Tucker <dt@docker.com>
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
IMAGE_NAME=test-qemu-build
|
||||
|
||||
clean_up() {
|
||||
# remove any files, containers, images etc
|
||||
rm -rf "${LINUXKIT_TMPDIR:?}/${IMAGE_NAME:?}*" || true
|
||||
}
|
||||
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
[ -f "${LINUXKIT_TMPDIR}/${IMAGE_NAME}.iso" ] || exit 1
|
||||
linuxkit run qemu -iso "${LINUXKIT_TMPDIR}/${IMAGE_NAME}" | grep -q "Welcome to LinuxKit"
|
||||
exit 0
|
25
test/cases/010_platforms/000_qemu/020_build_efi/test.sh
Normal file
25
test/cases/010_platforms/000_qemu/020_build_efi/test.sh
Normal file
@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Test building a UEFI image for qemu
|
||||
# LABELS: build
|
||||
# AUTHOR: Dave Tucker <dt@docker.com>
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
IMAGE_NAME=test-qemu-build
|
||||
|
||||
clean_up() {
|
||||
# remove any files, containers, images etc
|
||||
find . -iname "${IMAGE_NAME}*" -not -iname "*.yml" -exec rm {} \;
|
||||
}
|
||||
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
moby build -name "${IMAGE_NAME}" test.yml
|
||||
[ -f "${IMAGE_NAME}-efi.iso" ] || exit 1
|
||||
cp "${IMAGE_NAME}-efi.iso" "${LINUXKIT_TMPDIR}/"
|
||||
exit 0
|
31
test/cases/010_platforms/000_qemu/020_build_efi/test.yml
Normal file
31
test/cases/010_platforms/000_qemu/020_build_efi/test.yml
Normal file
@ -0,0 +1,31 @@
|
||||
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: dhcpcd
|
||||
image: "linuxkit/dhcpcd:8837289b78ecd80f59524883085424e115dd0b3a"
|
||||
binds:
|
||||
- /var:/var
|
||||
- /tmp/etc:/etc
|
||||
capabilities:
|
||||
- CAP_NET_ADMIN
|
||||
- CAP_NET_BIND_SERVICE
|
||||
- CAP_NET_RAW
|
||||
net: host
|
||||
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
|
||||
- name: poweroff
|
||||
image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084"
|
||||
pid: host
|
||||
command: ["/bin/sh", "/poweroff.sh", "10"]
|
||||
capabilities:
|
||||
- CAP_SYS_BOOT
|
||||
readonly: true
|
||||
trust:
|
||||
image:
|
||||
- linuxkit/kernel
|
||||
outputs:
|
||||
- format: iso-efi
|
31
test/cases/010_platforms/000_qemu/021_run_efi/test.sh
Normal file
31
test/cases/010_platforms/000_qemu/021_run_efi/test.sh
Normal file
@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Test running a UEFI image with qemu
|
||||
# LABELS:
|
||||
# AUTHOR: Dave Tucker <dt@docker.com>
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
IMAGE_NAME=test-qemu-build
|
||||
|
||||
clean_up() {
|
||||
# remove any files, containers, images etc
|
||||
rm -rf "${LINUXKIT_TMPDIR:?}/${IMAGE_NAME:?}*" || true
|
||||
}
|
||||
|
||||
trap clean_up EXIT
|
||||
|
||||
if command -v qemu; then
|
||||
if [ ! -f /usr/share/ovmf/bios.bin ]; then
|
||||
exit RT_CANCEL
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# Test code goes here
|
||||
[ -f "${LINUXKIT_TMPDIR}/${IMAGE_NAME}-efi.iso" ] || exit 1
|
||||
linuxkit run qemu -uefi "${LINUXKIT_TMPDIR}/${IMAGE_NAME}" | grep -q "Welcome to LinuxKit"
|
||||
exit 0
|
35
test/cases/010_platforms/000_qemu/group.sh
Normal file
35
test/cases/010_platforms/000_qemu/group.sh
Normal file
@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Linuxkit Qemu Tests
|
||||
# LABELS:
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
#. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
group_init() {
|
||||
# Group initialisation code goes here
|
||||
return 0
|
||||
}
|
||||
|
||||
group_deinit() {
|
||||
# Group de-initialisation code goes here
|
||||
return 0
|
||||
}
|
||||
|
||||
CMD=$1
|
||||
case $CMD in
|
||||
init)
|
||||
group_init
|
||||
res=$?
|
||||
;;
|
||||
deinit)
|
||||
group_deinit
|
||||
res=$?
|
||||
;;
|
||||
*)
|
||||
res=1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit $res
|
||||
|
37
test/cases/010_platforms/001_hyperkit/group.sh
Normal file
37
test/cases/010_platforms/001_hyperkit/group.sh
Normal file
@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: LinuxKit Hyperkit tests
|
||||
# LABELS: darwin
|
||||
# For the top level group.sh also specify a 'NAME:' comment
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
#. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
|
||||
group_init() {
|
||||
# Group initialisation code goes here
|
||||
return 0
|
||||
}
|
||||
|
||||
group_deinit() {
|
||||
# Group de-initialisation code goes here
|
||||
return 0
|
||||
}
|
||||
|
||||
CMD=$1
|
||||
case $CMD in
|
||||
init)
|
||||
group_init
|
||||
res=$?
|
||||
;;
|
||||
deinit)
|
||||
group_deinit
|
||||
res=$?
|
||||
;;
|
||||
*)
|
||||
res=1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit $res
|
||||
|
27
test/cases/010_platforms/010_gcp/000_build/test.sh
Normal file
27
test/cases/010_platforms/010_gcp/000_build/test.sh
Normal file
@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Test building an image for GCP
|
||||
# LABELS: build
|
||||
# AUTHOR: Dave Tucker <dt@docker.com>
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
IMAGE_NAME=gcp
|
||||
|
||||
clean_up() {
|
||||
# remove any files, containers, images etc
|
||||
rm -rf ${IMAGE_NAME}*
|
||||
}
|
||||
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
moby build -name "${IMAGE_NAME}" test.yml
|
||||
[ -f "${IMAGE_NAME}.img.tar.gz" ] || exit 1
|
||||
# As build and run on different machines, copy to the artifacts directory
|
||||
cp -f "${IMAGE_NAME}.img.tar.gz" "${LINUXKIT_ARTIFACTS_DIR}/test.img.tar.gz"
|
||||
|
||||
exit 0
|
34
test/cases/010_platforms/010_gcp/000_build/test.yml
Normal file
34
test/cases/010_platforms/010_gcp/000_build/test.yml
Normal file
@ -0,0 +1,34 @@
|
||||
# FIXME: This should use the minimal example
|
||||
# We continue to use the kernel-config-test as CI is currently expecting to see a success message
|
||||
kernel:
|
||||
image: "linuxkit/kernel:4.9.x"
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:deea956a9ab07bf262083e93a86930bdc610cc2f
|
||||
- linuxkit/runc:2649198589ef0020d99f613adaeda45ce0093a38
|
||||
- linuxkit/containerd:cf2614f5a96c569a0bd4bd54e054a65ba17d167f
|
||||
- linuxkit/ca-certificates:3344cdca1bc59fdfa17bd7f0fcbf491b9dbaa288
|
||||
onboot:
|
||||
- name: dhcpcd
|
||||
image: "linuxkit/dhcpcd:2def74ab3f9233b4c09ebb196ba47c27c08b0ed8"
|
||||
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
|
||||
- name: poweroff
|
||||
image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084"
|
||||
pid: host
|
||||
command: ["/bin/sh", "/poweroff.sh", "3"]
|
||||
capabilities:
|
||||
- CAP_SYS_BOOT
|
||||
readonly: true
|
||||
outputs:
|
||||
- format: gcp-img
|
24
test/cases/010_platforms/010_gcp/001_run/test.sh
Normal file
24
test/cases/010_platforms/010_gcp/001_run/test.sh
Normal file
@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Test running an image with qemu
|
||||
# LABELS: gcp
|
||||
# AUTHOR: Dave Tucker <dt@docker.com>
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
IMAGE_NAME=test
|
||||
|
||||
clean_up() {
|
||||
# remove any files, containers, images etc
|
||||
echo "Nothing to cleanup..."
|
||||
}
|
||||
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
[ -f "${LINUXKIT_ARTIFACTS_DIR}/${IMAGE_NAME}.img.tar.gz" ] || exit 1
|
||||
linuxkit run gcp "${LINUXKIT_ARTIFACTS_DIR}/${IMAGE_NAME}" | grep -q "Welcome to LinuxKit"
|
||||
exit 0
|
37
test/cases/010_platforms/010_gcp/group.sh
Normal file
37
test/cases/010_platforms/010_gcp/group.sh
Normal file
@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: LinuxKit configuration tests
|
||||
# LABELS:
|
||||
# For the top level group.sh also specify a 'NAME:' comment
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
#. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
|
||||
group_init() {
|
||||
# Group initialisation code goes here
|
||||
return 0
|
||||
}
|
||||
|
||||
group_deinit() {
|
||||
# Group de-initialisation code goes here
|
||||
return 0
|
||||
}
|
||||
|
||||
CMD=$1
|
||||
case $CMD in
|
||||
init)
|
||||
group_init
|
||||
res=$?
|
||||
;;
|
||||
deinit)
|
||||
group_deinit
|
||||
res=$?
|
||||
;;
|
||||
*)
|
||||
res=1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit $res
|
||||
|
27
test/cases/010_platforms/020_packet/000_build/test.sh
Normal file
27
test/cases/010_platforms/020_packet/000_build/test.sh
Normal file
@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Test building an image for packet.net
|
||||
# LABELS: build
|
||||
# AUTHOR: Dave Tucker <dt@docker.com>
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
IMAGE_NAME=packet
|
||||
|
||||
clean_up() {
|
||||
# remove any files, containers, images etc
|
||||
rm -rf ${IMAGE_NAME}*
|
||||
}
|
||||
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
moby build --name "${IMAGE_NAME}" test.yml
|
||||
[ -f "${IMAGE_NAME}-kernel" ] || exit 1
|
||||
|
||||
# As build and run on different machines, copy to the artifacts directory
|
||||
find . -iname "${IMAGE_NAME}-*" -exec cp {} "${LINUXKIT_ARTFACTS_DIR}/{}" \;
|
||||
exit 0
|
31
test/cases/010_platforms/020_packet/000_build/test.yml
Normal file
31
test/cases/010_platforms/020_packet/000_build/test.yml
Normal file
@ -0,0 +1,31 @@
|
||||
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: dhcpcd
|
||||
image: "linuxkit/dhcpcd:8837289b78ecd80f59524883085424e115dd0b3a"
|
||||
binds:
|
||||
- /var:/var
|
||||
- /tmp/etc:/etc
|
||||
capabilities:
|
||||
- CAP_NET_ADMIN
|
||||
- CAP_NET_BIND_SERVICE
|
||||
- CAP_NET_RAW
|
||||
net: host
|
||||
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
|
||||
- name: poweroff
|
||||
image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084"
|
||||
pid: host
|
||||
command: ["/bin/sh", "/poweroff.sh", "10"]
|
||||
capabilities:
|
||||
- CAP_SYS_BOOT
|
||||
readonly: true
|
||||
trust:
|
||||
image:
|
||||
- linuxkit/kernel
|
||||
outputs:
|
||||
- format: kernel+initrd
|
37
test/cases/010_platforms/020_packet/group.sh
Normal file
37
test/cases/010_platforms/020_packet/group.sh
Normal file
@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: LinuxKit configuration tests
|
||||
# LABELS:
|
||||
# For the top level group.sh also specify a 'NAME:' comment
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
#. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
|
||||
group_init() {
|
||||
# Group initialisation code goes here
|
||||
return 0
|
||||
}
|
||||
|
||||
group_deinit() {
|
||||
# Group de-initialisation code goes here
|
||||
return 0
|
||||
}
|
||||
|
||||
CMD=$1
|
||||
case $CMD in
|
||||
init)
|
||||
group_init
|
||||
res=$?
|
||||
;;
|
||||
deinit)
|
||||
group_deinit
|
||||
res=$?
|
||||
;;
|
||||
*)
|
||||
res=1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit $res
|
||||
|
27
test/cases/010_platforms/030_vmware/000_build/test.sh
Normal file
27
test/cases/010_platforms/030_vmware/000_build/test.sh
Normal file
@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Test building an image for VMware
|
||||
# LABELS: build
|
||||
# AUTHOR: Dave Tucker <dt@docker.com>
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
IMAGE_NAME=vmware
|
||||
|
||||
clean_up() {
|
||||
# remove any files, containers, images etc
|
||||
rm -rf ${IMAGE_NAME}*
|
||||
}
|
||||
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
moby build --name "${IMAGE_NAME}" test.yml
|
||||
[ -f "${IMAGE_NAME}.vmdk" ] || exit 1
|
||||
# As build and run on different machines, copy to the artifacts directory
|
||||
cp "${IMAGE_NAME}.vmdk" "${LINUXKIT_ARTIFACTS_DIR}/"
|
||||
exit 0
|
||||
|
31
test/cases/010_platforms/030_vmware/000_build/test.yml
Normal file
31
test/cases/010_platforms/030_vmware/000_build/test.yml
Normal file
@ -0,0 +1,31 @@
|
||||
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: dhcpcd
|
||||
image: "linuxkit/dhcpcd:8837289b78ecd80f59524883085424e115dd0b3a"
|
||||
binds:
|
||||
- /var:/var
|
||||
- /tmp/etc:/etc
|
||||
capabilities:
|
||||
- CAP_NET_ADMIN
|
||||
- CAP_NET_BIND_SERVICE
|
||||
- CAP_NET_RAW
|
||||
net: host
|
||||
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
|
||||
- name: poweroff
|
||||
image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084"
|
||||
pid: host
|
||||
command: ["/bin/sh", "/poweroff.sh", "10"]
|
||||
capabilities:
|
||||
- CAP_SYS_BOOT
|
||||
readonly: true
|
||||
trust:
|
||||
image:
|
||||
- linuxkit/kernel
|
||||
outputs:
|
||||
- format: vmdk
|
37
test/cases/010_platforms/group.sh
Normal file
37
test/cases/010_platforms/group.sh
Normal file
@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: LinuxKit platform tests
|
||||
# LABELS:
|
||||
# For the top level group.sh also specify a 'NAME:' comment
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
#. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
|
||||
group_init() {
|
||||
# Group initialisation code goes here
|
||||
return 0
|
||||
}
|
||||
|
||||
group_deinit() {
|
||||
# Group de-initialisation code goes here
|
||||
return 0
|
||||
}
|
||||
|
||||
CMD=$1
|
||||
case $CMD in
|
||||
init)
|
||||
group_init
|
||||
res=$?
|
||||
;;
|
||||
deinit)
|
||||
group_deinit
|
||||
res=$?
|
||||
;;
|
||||
*)
|
||||
res=1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit $res
|
||||
|
@ -15,7 +15,6 @@ onboot:
|
||||
- /etc/ltp/baseline:/etc/ltp/baseline
|
||||
capabilities:
|
||||
- all
|
||||
services:
|
||||
- name: poweroff
|
||||
image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084"
|
||||
pid: host
|
||||
@ -26,7 +25,4 @@ files:
|
||||
- path: /etc/ltp/baseline
|
||||
contents: "100"
|
||||
outputs:
|
||||
- format: kernel+initrd
|
||||
- format: iso-bios
|
||||
- format: iso-efi
|
||||
- format: gcp-img
|
24
test/cases/020_stress/000_ltp/test.sh
Normal file
24
test/cases/020_stress/000_ltp/test.sh
Normal file
@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Run the Linux Testing Project tests
|
||||
# LABELS: slow, gcp
|
||||
# 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-ltp*" -not -iname "*.yml" -exec rm -rf {} \;
|
||||
}
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
moby build test-ltp
|
||||
linuxkit push test-ltp.img.tar.gz
|
||||
RESULT="$(linuxkit run gcp -skip-cleanup -machine n1-highcpu-4 test-ltp)"
|
||||
echo "${RESULT}" | grep -q "suite has passed"
|
||||
|
||||
exit 0
|
4
test/cases/020_stress/010_virtsock/test.sh
Normal file
4
test/cases/020_stress/010_virtsock/test.sh
Normal file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
# LABELS: windows, skip
|
||||
|
||||
# FIXME: Write this test!!!
|
37
test/cases/020_stress/group.sh
Normal file
37
test/cases/020_stress/group.sh
Normal file
@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: LinuxKit stress tests
|
||||
# LABELS:
|
||||
# For the top level group.sh also specify a 'NAME:' comment
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
#. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
|
||||
group_init() {
|
||||
# Group initialisation code goes here
|
||||
return 0
|
||||
}
|
||||
|
||||
group_deinit() {
|
||||
# Group de-initialisation code goes here
|
||||
return 0
|
||||
}
|
||||
|
||||
CMD=$1
|
||||
case $CMD in
|
||||
init)
|
||||
group_init
|
||||
res=$?
|
||||
;;
|
||||
deinit)
|
||||
group_deinit
|
||||
res=$?
|
||||
;;
|
||||
*)
|
||||
res=1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit $res
|
||||
|
4
test/cases/030_security/000_docker-bench/test.sh
Normal file
4
test/cases/030_security/000_docker-bench/test.sh
Normal file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
# LABELS: skip
|
||||
|
||||
# FIXME: Write this test!!!
|
37
test/cases/030_security/group.sh
Normal file
37
test/cases/030_security/group.sh
Normal file
@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: LinuxKit security tests
|
||||
# LABELS:
|
||||
# For the top level group.sh also specify a 'NAME:' comment
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
#. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
|
||||
group_init() {
|
||||
# Group initialisation code goes here
|
||||
return 0
|
||||
}
|
||||
|
||||
group_deinit() {
|
||||
# Group de-initialisation code goes here
|
||||
return 0
|
||||
}
|
||||
|
||||
CMD=$1
|
||||
case $CMD in
|
||||
init)
|
||||
group_init
|
||||
res=$?
|
||||
;;
|
||||
deinit)
|
||||
group_deinit
|
||||
res=$?
|
||||
;;
|
||||
*)
|
||||
res=1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit $res
|
||||
|
25
test/cases/100_examples/000_minimal/test.sh
Normal file
25
test/cases/100_examples/000_minimal/test.sh
Normal file
@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Test the minimal example
|
||||
# LABELS:
|
||||
# AUTHOR: Dave Tucker <dt@docker.com>
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
IMAGE_NAME=minimal
|
||||
|
||||
clean_up() {
|
||||
# remove any files, containers, images etc
|
||||
rm -rf ${IMAGE_NAME}*
|
||||
}
|
||||
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
moby build "${LINUXKIT_EXAMPLES_DIR}/${IMAGE_NAME}.yml"
|
||||
|
||||
exit 0
|
||||
|
25
test/cases/100_examples/010_docker/test.sh
Normal file
25
test/cases/100_examples/010_docker/test.sh
Normal file
@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Test the docker example
|
||||
# LABELS:
|
||||
# AUTHOR: Dave Tucker <dt@docker.com>
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
IMAGE_NAME=docker
|
||||
|
||||
clean_up() {
|
||||
# remove any files, containers, images etc
|
||||
rm -rf ${IMAGE_NAME}*
|
||||
}
|
||||
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
moby build "${LINUXKIT_EXAMPLES_DIR}/${IMAGE_NAME}.yml"
|
||||
|
||||
exit 0
|
||||
|
25
test/cases/100_examples/020_sshd/test.sh
Normal file
25
test/cases/100_examples/020_sshd/test.sh
Normal file
@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Test the sshd example
|
||||
# LABELS:
|
||||
# AUTHOR: Dave Tucker <dt@docker.com>
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
IMAGE_NAME=sshd
|
||||
|
||||
clean_up() {
|
||||
# remove any files, containers, images etc
|
||||
rm -rf ${IMAGE_NAME}*
|
||||
}
|
||||
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
moby build "${LINUXKIT_EXAMPLES_DIR}/${IMAGE_NAME}.yml"
|
||||
|
||||
exit 0
|
||||
|
25
test/cases/100_examples/030_redis/test.sh
Normal file
25
test/cases/100_examples/030_redis/test.sh
Normal file
@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Test the redis-os example
|
||||
# LABELS:
|
||||
# AUTHOR: Dave Tucker <dt@docker.com>
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
IMAGE_NAME=redis-os
|
||||
|
||||
clean_up() {
|
||||
# remove any files, containers, images etc
|
||||
rm -rf ${IMAGE_NAME}*
|
||||
}
|
||||
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
moby build "${LINUXKIT_EXAMPLES_DIR}/${IMAGE_NAME}.yml"
|
||||
|
||||
exit 0
|
||||
|
25
test/cases/100_examples/040_swap/test.sh
Normal file
25
test/cases/100_examples/040_swap/test.sh
Normal file
@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Test the swap example
|
||||
# LABELS:
|
||||
# AUTHOR: Dave Tucker <dt@docker.com>
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
IMAGE_NAME=swap
|
||||
|
||||
clean_up() {
|
||||
# remove any files, containers, images etc
|
||||
rm -rf ${IMAGE_NAME}*
|
||||
}
|
||||
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
moby build "${LINUXKIT_EXAMPLES_DIR}/${IMAGE_NAME}.yml"
|
||||
|
||||
exit 0
|
||||
|
25
test/cases/100_examples/050_node_exporter/test.sh
Normal file
25
test/cases/100_examples/050_node_exporter/test.sh
Normal file
@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Test the node_exporter example
|
||||
# LABELS:
|
||||
# AUTHOR: Dave Tucker <dt@docker.com>
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
IMAGE_NAME=node_exporter
|
||||
|
||||
clean_up() {
|
||||
# remove any files, containers, images etc
|
||||
rm -rf ${IMAGE_NAME}*
|
||||
}
|
||||
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
moby build "${LINUXKIT_EXAMPLES_DIR}/${IMAGE_NAME}.yml"
|
||||
|
||||
exit 0
|
||||
|
15
test/cases/_lib/lib.sh
Normal file
15
test/cases/_lib/lib.sh
Normal file
@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Source the main regression test library if present
|
||||
[ -f "${RT_LIB}" ] && . "${RT_LIB}"
|
||||
|
||||
# Temporary directory for tests to use.
|
||||
LINUXKIT_TMPDIR="${RT_PROJECT_ROOT}/_tmp"
|
||||
LINUXKIT_ARTIFACTS_DIR="${RT_PROJECT_ROOT}/../../artifacts"
|
||||
|
||||
# The top-level group.sh of the project creates a env.sh file
|
||||
# containing environment variables for tests. Source it if present.
|
||||
[ -f "${LINUXKIT_TMPDIR}/env.sh" ] && . "${LINUXKIT_TMPDIR}/env.sh"
|
||||
|
||||
# FIXME: Should source the rtf/lib/lib.sh instead
|
||||
RT_CANCEL=253
|
41
test/cases/group.sh
Normal file
41
test/cases/group.sh
Normal file
@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
# NAME: linuxkit
|
||||
# SUMMARY: LinuxKit Regression Tests
|
||||
# LABELS:
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
# . "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
group_init() {
|
||||
# Group initialisation code goes here
|
||||
[ -r "${LINUXKIT_TMPDIR}" ] && rm -rf "${LINUXKIT_TMPDIR}"
|
||||
mkdir "${LINUXKIT_TMPDIR}"
|
||||
[ -r "${LINUXKIT_ARTIFACTS_DIR}" ] && rm -rf "${LINUXKIT_ARTIFACTS_DIR}"
|
||||
mkdir "${LINUXKIT_ARTIFACTS_DIR}"
|
||||
echo "export LINUXKIT_EXAMPLES_DIR=${RT_PROJECT_ROOT}/../../examples" >> "${LINUXKIT_TMPDIR}/env.sh"
|
||||
return 0
|
||||
}
|
||||
|
||||
group_deinit() {
|
||||
# Group de-initialisation code goes here
|
||||
return 0
|
||||
}
|
||||
|
||||
CMD=$1
|
||||
case $CMD in
|
||||
init)
|
||||
group_init
|
||||
res=$?
|
||||
;;
|
||||
deinit)
|
||||
group_deinit
|
||||
res=$?
|
||||
;;
|
||||
*)
|
||||
res=1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit $res
|
||||
|
@ -1,10 +0,0 @@
|
||||
#! /bin/sh
|
||||
|
||||
# Make sure we have the latest kernel image
|
||||
docker pull linuxkit/kernel:4.9.x
|
||||
# Build a package
|
||||
docker build -t kmod-test .
|
||||
# Build a LinuxKit image with kernel module (and test script)
|
||||
moby build kmod
|
||||
# Run it
|
||||
linuxkit run kmod
|
Loading…
Reference in New Issue
Block a user