tests: Add a test case to ensure no ports are open

Signed-off-by: Dave Tucker <dt@docker.com>
This commit is contained in:
Dave Tucker 2017-06-06 10:31:37 +01:00
parent 1598b11375
commit 8763da79c9
3 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,13 @@
#!/bin/sh
set -e
PORTS=$(netstat -lntup)
LINES=$(echo "${PORTS}" | wc -l)
if [ $((LINES > 2)) -ne 0 ]
then
echo "Ports test case FAILED"
echo "${PORTS}"
exit 1
fi
echo "Ports test case PASSED"

View File

@ -0,0 +1,24 @@
#!/bin/sh
# SUMMARY: Check that there are no open ports
# LABELS:
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
NAME=lsof
clean_up() {
# remove any files, containers, images etc
rm -rf ${NAME}* || true
}
trap clean_up EXIT
moby build -output kernel+initrd -name "${NAME}" test.yml
linuxkit run qemu -kernel "${NAME}"
#RESULT=$(linuxkit run qemu -kernel "${NAME}")
#echo "${RESULT}" | grep -q "PASSED"
exit 0

View File

@ -0,0 +1,23 @@
kernel:
image: "linuxkit/kernel:4.9.x"
cmdline: "console=ttyS0 page_poison=1"
init:
- linuxkit/init:1b8a7e394d2ec2f1fdb4d67645829d1b5bdca037
- linuxkit/runc:3a4e6cbf15470f62501b019b55e1caac5ee7689f
- linuxkit/containerd:b50181bc6e0084e5fcd6b6ad3cf433c4f66cae5a
onboot:
- name: test
image: "alpine:3.6"
readonly: true
binds:
- /check.sh:/check.sh
command: ["sh", "./check.sh"]
- name: poweroff
image: "linuxkit/poweroff:7404cf2295df89ccfa2dda41997a28307a90cf28"
command: ["/bin/sh", "/poweroff.sh", "10"]
files:
- path: check.sh
source: ./check.sh
trust:
org:
- linuxkit