]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
test/TEST-99-RPM: fixed test suite
authorHarald Hoyer <harald@redhat.com>
Thu, 9 Jun 2016 16:14:45 +0000 (18:14 +0200)
committerHarald Hoyer <harald@redhat.com>
Thu, 9 Jun 2016 16:15:48 +0000 (18:15 +0200)
- cope with dnf vs yum
- fixed find arguments
- make script fail, if command fails

test/TEST-99-RPM/test.sh

index d0c89e5f0273e5aeb0a979d27d7c8a38f351479d..31520f1465b58297cf4a7d5ba5656757262aab9d 100755 (executable)
@@ -5,6 +5,7 @@ $TESTDIR
 
 test_run() {
     set -x
+    set -e
     export rootdir=$TESTDIR/root
 
     mkdir -p $rootdir
@@ -13,15 +14,17 @@ 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
+    $dnf_or_yum --nogpgcheck --installroot "$rootdir"/ install --allowerasing -y \
+       $dnf_or_yum \
        passwd \
        rootfiles \
        systemd \
@@ -37,9 +40,9 @@ trap '[[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umou
 
     cat >"$rootdir"/test.sh <<EOF
 #!/bin/bash
-set -x
+set -xe
 export LC_MESSAGES=C
-rpm -Va &> /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/*-' \
@@ -50,19 +53,19 @@ 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 -patch '/usr/share/mime/*' \
-  -not -patch '/etc/crypto-policies/*' \
+  -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)/*" \
   -exec rpm -qf '{}' ';' | \
-  grep -F 'not owned' &> /test.output
-exit
+  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