From 4eafdbdbe8ee3486ae96bdc6b5fa34112064a3ea Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Mon, 9 Jul 2012 16:28:47 +0200 Subject: [PATCH] test: new test TEST-99-RPM This test installs the dracut rpm together with the kernel in an installroot. rpm -Va and rpm -qf are used, to ensure nothing modified files in the real root. --- test/TEST-99-RPM/Makefile | 10 ++++++ test/TEST-99-RPM/test.sh | 83 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 test/TEST-99-RPM/Makefile create mode 100755 test/TEST-99-RPM/test.sh diff --git a/test/TEST-99-RPM/Makefile b/test/TEST-99-RPM/Makefile new file mode 100644 index 0000000..5513c52 --- /dev/null +++ b/test/TEST-99-RPM/Makefile @@ -0,0 +1,10 @@ +all: + @make -s --no-print-directory -C ../.. clean all rpm + @basedir=../.. testdir=../ ./test.sh --all +setup: + @make --no-print-directory -C ../.. clean rpm + @basedir=../.. testdir=../ ./test.sh --setup +clean: + @basedir=../.. testdir=../ ./test.sh --clean +run: + @basedir=../.. testdir=../ ./test.sh --run diff --git a/test/TEST-99-RPM/test.sh b/test/TEST-99-RPM/test.sh new file mode 100755 index 0000000..25c1895 --- /dev/null +++ b/test/TEST-99-RPM/test.sh @@ -0,0 +1,83 @@ +#!/bin/bash +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# ex: ts=8 sw=4 sts=4 et filetype=sh +TEST_DESCRIPTION="rpm integrity after dracut and kernel install" +$TESTDIR + +test_run() { + set -x + export rootdir=$TESTDIR/root + + mkdir -p $rootdir + + mkdir -p "$rootdir/proc" + mkdir -p "$rootdir/sys" + mkdir -p "$rootdir/dev" + + mount --bind /proc "$rootdir/proc" + mount --bind /sys "$rootdir/sys" + mount -t devtmpfs devtmpfs "$rootdir/dev" + + yum --nogpgcheck --releasever=/ --installroot "$rootdir"/ install -y \ + yum \ + passwd \ + rootfiles \ + systemd \ + kernel \ + fedora-release \ + device-mapper-multipath \ + lvm2 \ + mdadm \ + bash \ + iscsi-initiator-utils \ + $basedir/dracut-[0-9]*.$(arch).rpm \ + $basedir/dracut-network-[0-9]*.$(arch).rpm + + cat >"$rootdir"/test.sh < /test.output +find / -xdev -type f -not -path '/var/*' \ + -not -path '/usr/lib/modules/*/modules.*' \ + -not -path '/etc/*-' \ + -not -path '/etc/.pwd.lock' \ + -not -path '/run/mount/utab' \ + -not -path '/test.sh' \ + -not -path '/test.output' \ + -not -path '/etc/nsswitch.conf.bak' \ + -not -path '/etc/iscsi/initiatorname.iscsi' \ + -not -path '/dev/null' \ + -exec rpm -qf '{}' ';' | \ + fgrep 'not owned' &> /test.output +exit +EOF + + chmod 0755 "$rootdir/test.sh" + + chroot "$rootdir" /test.sh + + if [[ -s "$rootdir"/test.output ]]; then + failed=1 + echo TEST Failed >&2 + cat "$rootdir"/test.output >&2 + fi + + umount "$rootdir/proc" + umount "$rootdir/sys" + umount "$rootdir/dev" + + [[ $failed ]] && return 1 + return 0 + +} + +test_setup() { + return 0 +} + +test_cleanup() { + return 0 +} + +. $testdir/test-functions