From 968eb46fce41fc1819afd1f0683a61704e35fe54 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Fri, 11 Nov 2016 14:08:14 +0100 Subject: [PATCH] TEST-99-RPM: speedup test --- Makefile | 2 +- test/TEST-99-RPM/test.sh | 38 +++++++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 18f5a88c..97987377 100644 --- a/Makefile +++ b/Makefile @@ -189,7 +189,7 @@ rpm: dracut-$(VERSION).tar.bz2 syncheck (cd "$$rpmbuild"; rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" \ --define "_specdir $$PWD" --define "_srcrpmdir $$PWD" \ --define "_rpmdir $$PWD" -ba dracut.spec; ) && \ - ( mv "$$rpmbuild"/$$(arch)/*.rpm .; mv "$$rpmbuild"/*.src.rpm .;rm -fr -- "$$rpmbuild"; ls *.rpm ) + ( mv "$$rpmbuild"/$$(arch)/*.rpm $(DESTDIR).; mv "$$rpmbuild"/*.src.rpm $(DESTDIR).;rm -fr -- "$$rpmbuild"; ls $(DESTDIR)*.rpm ) syncheck: @ret=0;for i in dracut-initramfs-restore.sh modules.d/*/*.sh; do \ diff --git a/test/TEST-99-RPM/test.sh b/test/TEST-99-RPM/test.sh index fc682734..17c0bf8d 100755 --- a/test/TEST-99-RPM/test.sh +++ b/test/TEST-99-RPM/test.sh @@ -1,11 +1,14 @@ #!/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_check() { + command -v rpm &>/dev/null && ( command -v yum || command -v dnf ) &>/dev/null +} test_run() { set -x + set -e export rootdir=$TESTDIR/root mkdir -p $rootdir @@ -14,33 +17,34 @@ test_run() { mkdir -p "$rootdir/sys" mkdir -p "$rootdir/dev" -trap 'ret=$?; [[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umount "$rootdir/dev"; rm -rf -- "$rootdir"; }; exit $ret;' EXIT -trap '[[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umount "$rootdir/dev"; rm -rf -- "$rootdir"; }; exit 1;' SIGINT +trap 'ret=$?; [[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umount "$rootdir/dev"; rm -rf -- "$rootdir"; } || :; exit $ret;' EXIT +trap '[[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umount "$rootdir/dev"; rm -rf -- "$rootdir"; } || :; exit 1;' SIGINT mount --bind /proc "$rootdir/proc" mount --bind /sys "$rootdir/sys" mount -t devtmpfs devtmpfs "$rootdir/dev" - yum --nogpgcheck --releasever=/ --installroot "$rootdir"/ install -y \ - yum \ + dnf_or_yum=yum + command -v dnf >/dev/null && dnf_or_yum="dnf --allowerasing" + $dnf_or_yum --releasever=7 --nogpgcheck --installroot "$rootdir"/ install -y \ + $dnf_or_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 + "$TESTDIR"/dracut-[0-9]*.$(arch).rpm \ + "$TESTDIR"/dracut-network-[0-9]*.$(arch).rpm cat >"$rootdir"/test.sh < /test.output +rpm -Va |& grep -F -v '85-display-manager.preset' &> /test.output find / -xdev -type f -not -path '/var/*' \ -not -path '/usr/lib/modules/*/modules.*' \ -not -path '/etc/*-' \ @@ -51,18 +55,20 @@ find / -xdev -type f -not -path '/var/*' \ -not -path '/etc/nsswitch.conf.bak' \ -not -path '/etc/iscsi/initiatorname.iscsi' \ -not -path '/boot/*0-rescue*' \ + -not -path '/usr/share/mime/*' \ + -not -path '/etc/crypto-policies/*' \ -not -path '/dev/null' \ -not -path "/boot/loader/entries/\$(cat /etc/machine-id)-*" \ -not -path "/boot/\$(cat /etc/machine-id)/*" \ -not -path '/etc/openldap/certs/*' \ - -exec rpm -qf '{}' ';' | \ - grep -F 'not owned' &> /test.output -exit + -print0 | xargs -0 rpm -qf | \ + grep -F 'not owned' &>> /test.output +exit 0 EOF chmod 0755 "$rootdir/test.sh" - chroot "$rootdir" /test.sh + chroot "$rootdir" /test.sh || : if [[ -s "$rootdir"/test.output ]]; then failed=1 @@ -80,10 +86,12 @@ EOF } test_setup() { + make -C "$basedir" DESTDIR="$TESTDIR/" rpm return 0 } test_cleanup() { + rm -fr -- "$TESTDIR"/*.rpm return 0 }