diff --git a/test/cases/040_packages/004_dhcpcd/check.sh b/test/cases/040_packages/004_dhcpcd/check.sh new file mode 100755 index 000000000..9d480cc8d --- /dev/null +++ b/test/cases/040_packages/004_dhcpcd/check.sh @@ -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 diff --git a/test/cases/040_packages/004_dhcpcd/test-dhcpcd.yml b/test/cases/040_packages/004_dhcpcd/test-dhcpcd.yml new file mode 100644 index 000000000..a780465b8 --- /dev/null +++ b/test/cases/040_packages/004_dhcpcd/test-dhcpcd.yml @@ -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 diff --git a/test/cases/040_packages/004_dhcpcd/test.sh b/test/cases/040_packages/004_dhcpcd/test.sh new file mode 100644 index 000000000..06c884208 --- /dev/null +++ b/test/cases/040_packages/004_dhcpcd/test.sh @@ -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