pkg/kmsg: add simple test case

Signed-off-by: David Scott <dave.scott@docker.com>
This commit is contained in:
David Scott 2018-07-08 11:19:19 +01:00
parent e7fc5b59a3
commit 9344473ba5
3 changed files with 71 additions and 0 deletions

View File

@ -0,0 +1,15 @@
#!/bin/sh
for i in $(seq 1 20); do
# Look for a common kernel log message
if grep "SCSI subsystem initialized" /var/log/kmsg.out 2>/dev/null; then
printf "kmsg test suite PASSED\n" > /dev/console
/sbin/poweroff -f
fi
sleep 1
done
printf "kmsg test suite FAILED\n" > /dev/console
echo "contents of /var/log/kmsg.out:" > /dev/console
cat /var/log/kmsg.out > /dev/console
/sbin/poweroff -f

View File

@ -0,0 +1,24 @@
#!/bin/sh
# SUMMARY: Check that the kmsg package works
# LABELS:
# REPEAT:
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
NAME=kmsg
clean_up() {
rm -rf ${NAME}-*
}
trap clean_up EXIT
# Test code goes here
linuxkit build -disable-content-trust -format kernel+initrd -name "${NAME}" test.yml
RESULT="$(linuxkit run ${NAME})"
echo "${RESULT}"
echo "${RESULT}" | grep -q "suite PASSED"
exit 0

View File

@ -0,0 +1,32 @@
kernel:
image: linuxkit/kernel:4.14.53
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:6cc1442112980c889230b6449df09d5b48de6854
- linuxkit/runc:v0.4
- linuxkit/containerd:f2bc1bda1ab18146967fa1a149800aaf14bee81b
- linuxkit/ca-certificates:v0.4
- linuxkit/memlogd:883f0d46e7d3ae2d787e8acb496da115a4707cbc
services:
- name: kmsg
image: linuxkit/kmsg:3dfa0d5b4027ecc16089f27fbcffa15d6aa5438e
- name: write-and-rotate-logs
image: linuxkit/logwrite:7859c102a963828fd9c5aa3837db9600483220c7
- name: check-the-logs
image: alpine:3.8
binds:
- /check.sh:/check.sh
- /dev/console:/dev/console
- /var/log:/var/log
command: ["sh", "./check.sh"]
pid: host
capabilities:
- CAP_SYS_BOOT
files:
- path: check.sh
source: ./check.sh
trust:
org:
- linuxkit
image:
- alpine:3.8