mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-22 18:41:37 +00:00
Merge pull request #1925 from rneugeba/tests
Tweak package tests and add more
This commit is contained in:
commit
9086dd0435
12
test/cases/040_packages/002_binfmt/check.sh
Executable file
12
test/cases/040_packages/002_binfmt/check.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
function failed {
|
||||
printf "binfmt test suite FAILED\n" >&1
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ -e /binfmt_misc/qemu-aarch64 ] || failed
|
||||
[ -e /binfmt_misc/qemu-arm ] || failed
|
||||
[ -e /binfmt_misc/qemu-ppc64le ] || failed
|
||||
|
||||
printf "binfmt test suite PASSED\n" >&1
|
28
test/cases/040_packages/002_binfmt/test-binfmt.yml
Normal file
28
test/cases/040_packages/002_binfmt/test-binfmt.yml
Normal file
@ -0,0 +1,28 @@
|
||||
kernel:
|
||||
image: "linuxkit/kernel:4.9.x"
|
||||
cmdline: "console=ttyS0 page_poison=1"
|
||||
init:
|
||||
- linuxkit/init:4fc8aa82ab34d62d510575c8fbe0c58b7ba9c480
|
||||
- linuxkit/runc:3a4e6cbf15470f62501b019b55e1caac5ee7689f
|
||||
- linuxkit/containerd:b1766e4c4c09f63ac4925a6e4612852a93f7e73b
|
||||
onboot:
|
||||
- name: binfmt
|
||||
image: "linuxkit/binfmt:eb3977596d5fc9e847eee1d34cb3beb3f574cac9"
|
||||
- name: test
|
||||
image: "alpine:3.6"
|
||||
readonly: true
|
||||
binds:
|
||||
- /check.sh:/check.sh
|
||||
- /proc/sys/fs/binfmt_misc:/binfmt_misc
|
||||
command: ["sh", "./check.sh"]
|
||||
- name: poweroff
|
||||
image: "linuxkit/poweroff:a8f1e4ad8d459f1fdaad9e4b007512cb3b504ae8"
|
||||
command: ["/bin/sh", "/poweroff.sh", "10"]
|
||||
files:
|
||||
- path: check.sh
|
||||
source: ./check.sh
|
||||
trust:
|
||||
org:
|
||||
- linuxkit
|
||||
image:
|
||||
- alpine:3.6
|
24
test/cases/040_packages/002_binfmt/test.sh
Normal file
24
test/cases/040_packages/002_binfmt/test.sh
Normal file
@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Check that the binfmt package works
|
||||
# LABELS:
|
||||
# REPEAT:
|
||||
|
||||
set -e
|
||||
set -v
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
clean_up() {
|
||||
find . -iname "test-binfmt*" -not -iname "*.yml" -exec rm -rf {} \;
|
||||
}
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
moby build -output kernel+initrd test-binfmt
|
||||
RESULT="$(linuxkit run qemu -kernel test-binfmt)"
|
||||
echo "${RESULT}"
|
||||
echo "${RESULT}" | grep -q "suite PASSED"
|
||||
|
||||
exit 0
|
12
test/cases/040_packages/003_ca-certificates/check.sh
Executable file
12
test/cases/040_packages/003_ca-certificates/check.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
function failed {
|
||||
printf "ca-certificates test suite FAILED\n" >&1
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ -d /host-etc/ssl/ ] || failed
|
||||
[ -d /host-etc/ssl/certs ] || failed
|
||||
[ -f /host-etc/ssl/certs/ca-certificates.crt ] || failed
|
||||
|
||||
printf "ca-certificates test suite PASSED\n" >&1
|
@ -0,0 +1,27 @@
|
||||
kernel:
|
||||
image: "linuxkit/kernel:4.9.x"
|
||||
cmdline: "console=ttyS0 page_poison=1"
|
||||
init:
|
||||
- linuxkit/init:4fc8aa82ab34d62d510575c8fbe0c58b7ba9c480
|
||||
- linuxkit/runc:3a4e6cbf15470f62501b019b55e1caac5ee7689f
|
||||
- linuxkit/containerd:b1766e4c4c09f63ac4925a6e4612852a93f7e73b
|
||||
- linuxkit/ca-certificates:75cf419fb58770884c3464eb687ec8dfc704169d
|
||||
onboot:
|
||||
- name: test
|
||||
image: "alpine:3.6"
|
||||
readonly: true
|
||||
binds:
|
||||
- /check.sh:/check.sh
|
||||
- /etc:/host-etc
|
||||
command: ["sh", "./check.sh"]
|
||||
- name: poweroff
|
||||
image: "linuxkit/poweroff:a8f1e4ad8d459f1fdaad9e4b007512cb3b504ae8"
|
||||
command: ["/bin/sh", "/poweroff.sh", "10"]
|
||||
files:
|
||||
- path: check.sh
|
||||
source: ./check.sh
|
||||
trust:
|
||||
org:
|
||||
- linuxkit
|
||||
image:
|
||||
- alpine:3.6
|
24
test/cases/040_packages/003_ca-certificates/test.sh
Normal file
24
test/cases/040_packages/003_ca-certificates/test.sh
Normal file
@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Check that the ca-certificates package works
|
||||
# LABELS:
|
||||
# REPEAT:
|
||||
|
||||
set -e
|
||||
set -v
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
clean_up() {
|
||||
find . -iname "test-ca-certificates*" -not -iname "*.yml" -exec rm -rf {} \;
|
||||
}
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
moby build -output kernel+initrd test-ca-certificates
|
||||
RESULT="$(linuxkit run qemu -kernel test-ca-certificates)"
|
||||
echo "${RESULT}"
|
||||
echo "${RESULT}" | grep -q "suite PASSED"
|
||||
|
||||
exit 0
|
14
test/cases/040_packages/004_dhcpcd/check.sh
Executable file
14
test/cases/040_packages/004_dhcpcd/check.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
function failed {
|
||||
printf "dhcpcd test suite FAILED\n" >&1
|
||||
exit 1
|
||||
}
|
||||
|
||||
LINK=$(iplink | grep eth0 | grep UP)
|
||||
ADDR=$(echo `ifconfig eth0 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://'`)
|
||||
|
||||
[ -z "${LINK}" ] && failed
|
||||
[ -z "${ADDR}" ] && failed
|
||||
|
||||
printf "dhcpcd test suite PASSED\n" >&1
|
29
test/cases/040_packages/004_dhcpcd/test-dhcpcd.yml
Normal file
29
test/cases/040_packages/004_dhcpcd/test-dhcpcd.yml
Normal file
@ -0,0 +1,29 @@
|
||||
kernel:
|
||||
image: "linuxkit/kernel:4.9.x"
|
||||
cmdline: "console=ttyS0 page_poison=1"
|
||||
init:
|
||||
- linuxkit/init:4fc8aa82ab34d62d510575c8fbe0c58b7ba9c480
|
||||
- linuxkit/runc:3a4e6cbf15470f62501b019b55e1caac5ee7689f
|
||||
- linuxkit/containerd:b1766e4c4c09f63ac4925a6e4612852a93f7e73b
|
||||
onboot:
|
||||
- name: dhcpcd
|
||||
image: "linuxkit/dhcpcd:7d2f17a0e5d1ef9a75a527821a9ab0d753b22e7e"
|
||||
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
|
||||
- name: test
|
||||
image: "alpine:3.6"
|
||||
readonly: true
|
||||
net: host
|
||||
binds:
|
||||
- /check.sh:/check.sh
|
||||
command: ["sh", "./check.sh"]
|
||||
- name: poweroff
|
||||
image: "linuxkit/poweroff:a8f1e4ad8d459f1fdaad9e4b007512cb3b504ae8"
|
||||
command: ["/bin/sh", "/poweroff.sh", "10"]
|
||||
files:
|
||||
- path: check.sh
|
||||
source: ./check.sh
|
||||
trust:
|
||||
org:
|
||||
- linuxkit
|
||||
image:
|
||||
- alpine:3.6
|
24
test/cases/040_packages/004_dhcpcd/test.sh
Normal file
24
test/cases/040_packages/004_dhcpcd/test.sh
Normal file
@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Check that the dhcpcd package works
|
||||
# LABELS:
|
||||
# REPEAT:
|
||||
|
||||
set -e
|
||||
set -v
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
clean_up() {
|
||||
find . -iname "test-dhcpcd*" -not -iname "*.yml" -exec rm -rf {} \;
|
||||
}
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
moby build -output kernel+initrd test-dhcpcd
|
||||
RESULT="$(linuxkit run qemu -kernel test-dhcpcd)"
|
||||
echo "${RESULT}"
|
||||
echo "${RESULT}" | grep -q "suite PASSED"
|
||||
|
||||
exit 0
|
@ -8,4 +8,4 @@ function failed {
|
||||
# this is a non default value, so will fail if sysctl failed
|
||||
[ "$(sysctl -n fs.inotify.max_user_watches)" -eq 524288 ] || failed
|
||||
|
||||
printf "Sysctl test suite PASSED\n" >&1
|
||||
printf "sysctl test suite PASSED\n" >&1
|
@ -9,9 +9,22 @@ onboot:
|
||||
- name: sysctl
|
||||
image: "linuxkit/sysctl:b16a483897dd5f71be7e0c04cd090b05f52682e1"
|
||||
- name: test
|
||||
image: "linuxkit/test-sysctl:c4df4c4d692904d6245dcdef1f4a79389bd3d894"
|
||||
image: "alpine:3.6"
|
||||
net: host
|
||||
pid: host
|
||||
ipc: host
|
||||
readonly: true
|
||||
binds:
|
||||
- /check.sh:/check.sh
|
||||
command: ["sh", "./check.sh"]
|
||||
- name: poweroff
|
||||
image: "linuxkit/poweroff:a8f1e4ad8d459f1fdaad9e4b007512cb3b504ae8"
|
||||
command: ["/bin/sh", "/poweroff.sh", "10"]
|
||||
files:
|
||||
- path: check.sh
|
||||
source: ./check.sh
|
||||
trust:
|
||||
org:
|
||||
- linuxkit
|
||||
image:
|
||||
- alpine:3.6
|
@ -4,6 +4,7 @@
|
||||
# REPEAT:
|
||||
|
||||
set -e
|
||||
set -v
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
@ -17,6 +18,7 @@ trap clean_up EXIT
|
||||
# Test code goes here
|
||||
moby build -output kernel+initrd test-sysctl
|
||||
RESULT="$(linuxkit run qemu -kernel test-sysctl)"
|
||||
echo "${RESULT}"
|
||||
echo "${RESULT}" | grep -q "suite PASSED"
|
||||
|
||||
exit 0
|
@ -1,4 +0,0 @@
|
||||
FROM alpine:edge
|
||||
ADD . ./
|
||||
ENTRYPOINT ["/bin/sh", "/check.sh"]
|
||||
LABEL org.mobyproject.config='{"net": "host","pid": "host", "ipc": "host", "readonly": true}'
|
@ -1,29 +0,0 @@
|
||||
.PHONY: tag push
|
||||
|
||||
BASE=alpine:3.5
|
||||
IMAGE=test-sysctl
|
||||
|
||||
default: push
|
||||
|
||||
hash: Dockerfile check.sh
|
||||
DOCKER_CONTENT_TRUST=1 docker pull $(BASE)
|
||||
tar cf - $^ | docker build --no-cache -t $(IMAGE):build -
|
||||
docker run --rm --entrypoint=/bin/sh $(IMAGE):build -c "cat $^ /lib/apk/db/installed | sha1sum" | sed 's/ .*//' > hash
|
||||
|
||||
push: hash
|
||||
DOCKER_CONTENT_TRUST=1 docker pull linuxkit/$(IMAGE):$(shell cat hash) || \
|
||||
(docker tag $(IMAGE):build linuxkit/$(IMAGE):$(shell cat hash) && \
|
||||
DOCKER_CONTENT_TRUST=1 docker push linuxkit/$(IMAGE):$(shell cat hash))
|
||||
docker rmi $(IMAGE):build
|
||||
rm -f hash
|
||||
|
||||
tag: hash
|
||||
docker pull linuxkit/$(IMAGE):$(shell cat hash) || \
|
||||
docker tag $(IMAGE):build linuxkit/$(IMAGE):$(shell cat hash)
|
||||
docker rmi $(IMAGE):build
|
||||
rm -f hash
|
||||
|
||||
clean:
|
||||
rm -f hash
|
||||
|
||||
.DELETE_ON_ERROR:
|
Loading…
Reference in New Issue
Block a user