From 885e6a7f0af7f69fe2a496ad9ab776c352e7ea51 Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Sun, 28 May 2017 11:44:29 +0100 Subject: [PATCH] tests: Add a test for the binfmt package Signed-off-by: Rolf Neugebauer --- test/cases/040_packages/002_binfmt/check.sh | 12 ++++++++ .../040_packages/002_binfmt/test-binfmt.yml | 28 +++++++++++++++++++ test/cases/040_packages/002_binfmt/test.sh | 24 ++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100755 test/cases/040_packages/002_binfmt/check.sh create mode 100644 test/cases/040_packages/002_binfmt/test-binfmt.yml create mode 100644 test/cases/040_packages/002_binfmt/test.sh diff --git a/test/cases/040_packages/002_binfmt/check.sh b/test/cases/040_packages/002_binfmt/check.sh new file mode 100755 index 000000000..2268a05a1 --- /dev/null +++ b/test/cases/040_packages/002_binfmt/check.sh @@ -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 diff --git a/test/cases/040_packages/002_binfmt/test-binfmt.yml b/test/cases/040_packages/002_binfmt/test-binfmt.yml new file mode 100644 index 000000000..45ca86f4e --- /dev/null +++ b/test/cases/040_packages/002_binfmt/test-binfmt.yml @@ -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 diff --git a/test/cases/040_packages/002_binfmt/test.sh b/test/cases/040_packages/002_binfmt/test.sh new file mode 100644 index 000000000..3d75a4ef7 --- /dev/null +++ b/test/cases/040_packages/002_binfmt/test.sh @@ -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