Blame 0086-test-TEST-99-RPM-fixed-test-suite.patch

Harald Hoyer 414eba
From 00929425314d4a661c441397a56b163bbaab3de4 Mon Sep 17 00:00:00 2001
Harald Hoyer 414eba
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer 414eba
Date: Thu, 9 Jun 2016 18:14:45 +0200
Harald Hoyer 414eba
Subject: [PATCH] test/TEST-99-RPM: fixed test suite
Harald Hoyer 414eba
Harald Hoyer 414eba
- cope with dnf vs yum
Harald Hoyer 414eba
- fixed find arguments
Harald Hoyer 414eba
- make script fail, if command fails
Harald Hoyer 414eba
---
Harald Hoyer 414eba
 test/TEST-99-RPM/test.sh | 25 ++++++++++++++-----------
Harald Hoyer 414eba
 1 file changed, 14 insertions(+), 11 deletions(-)
Harald Hoyer 414eba
Harald Hoyer 414eba
diff --git a/test/TEST-99-RPM/test.sh b/test/TEST-99-RPM/test.sh
Harald Hoyer 414eba
index d0c89e5..31520f1 100755
Harald Hoyer 414eba
--- a/test/TEST-99-RPM/test.sh
Harald Hoyer 414eba
+++ b/test/TEST-99-RPM/test.sh
Harald Hoyer 414eba
@@ -5,6 +5,7 @@ $TESTDIR
Harald Hoyer 414eba
 
Harald Hoyer 414eba
 test_run() {
Harald Hoyer 414eba
     set -x
Harald Hoyer 414eba
+    set -e
Harald Hoyer 414eba
     export rootdir=$TESTDIR/root
Harald Hoyer 414eba
 
Harald Hoyer 414eba
     mkdir -p $rootdir
Harald Hoyer 414eba
@@ -13,15 +14,17 @@ test_run() {
Harald Hoyer 414eba
     mkdir -p "$rootdir/sys"
Harald Hoyer 414eba
     mkdir -p "$rootdir/dev"
Harald Hoyer 414eba
 
Harald Hoyer 414eba
-trap 'ret=$?; [[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umount "$rootdir/dev"; rm -rf -- "$rootdir"; }; exit $ret;' EXIT
Harald Hoyer 414eba
-trap '[[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umount "$rootdir/dev"; rm -rf -- "$rootdir"; }; exit 1;' SIGINT
Harald Hoyer 414eba
+trap 'ret=$?; [[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umount "$rootdir/dev"; rm -rf -- "$rootdir"; } || :; exit $ret;' EXIT
Harald Hoyer 414eba
+trap '[[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umount "$rootdir/dev"; rm -rf -- "$rootdir"; } || :; exit 1;' SIGINT
Harald Hoyer 414eba
 
Harald Hoyer 414eba
     mount --bind /proc "$rootdir/proc"
Harald Hoyer 414eba
     mount --bind /sys "$rootdir/sys"
Harald Hoyer 414eba
     mount -t devtmpfs devtmpfs "$rootdir/dev"
Harald Hoyer 414eba
 
Harald Hoyer 414eba
-    yum --nogpgcheck --releasever=/ --installroot "$rootdir"/ install -y \
Harald Hoyer 414eba
-	yum \
Harald Hoyer 414eba
+    dnf_or_yum=yum
Harald Hoyer 414eba
+    command -v dnf >/dev/null && dnf_or_yum=dnf
Harald Hoyer 414eba
+    $dnf_or_yum --nogpgcheck --installroot "$rootdir"/ install --allowerasing -y \
Harald Hoyer 414eba
+	$dnf_or_yum \
Harald Hoyer 414eba
 	passwd \
Harald Hoyer 414eba
 	rootfiles \
Harald Hoyer 414eba
 	systemd \
Harald Hoyer 414eba
@@ -37,9 +40,9 @@ trap '[[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umou
Harald Hoyer 414eba
 
Harald Hoyer 414eba
     cat >"$rootdir"/test.sh <
Harald Hoyer 414eba
 #!/bin/bash
Harald Hoyer 414eba
-set -x
Harald Hoyer 414eba
+set -xe
Harald Hoyer 414eba
 export LC_MESSAGES=C
Harald Hoyer 414eba
-rpm -Va &> /test.output
Harald Hoyer 414eba
+rpm -Va |& grep -F -v '85-display-manager.preset' &> /test.output
Harald Hoyer 414eba
 find / -xdev -type f -not -path '/var/*' \
Harald Hoyer 414eba
   -not -path '/usr/lib/modules/*/modules.*' \
Harald Hoyer 414eba
   -not -path '/etc/*-' \
Harald Hoyer 414eba
@@ -50,19 +53,19 @@ find / -xdev -type f -not -path '/var/*' \
Harald Hoyer 414eba
   -not -path '/etc/nsswitch.conf.bak' \
Harald Hoyer 414eba
   -not -path '/etc/iscsi/initiatorname.iscsi' \
Harald Hoyer 414eba
   -not -path '/boot/*0-rescue*' \
Harald Hoyer 414eba
-  -not -patch '/usr/share/mime/*' \
Harald Hoyer 414eba
-  -not -patch '/etc/crypto-policies/*' \
Harald Hoyer 414eba
+  -not -path '/usr/share/mime/*' \
Harald Hoyer 414eba
+  -not -path '/etc/crypto-policies/*' \
Harald Hoyer 414eba
   -not -path '/dev/null' \
Harald Hoyer 414eba
   -not -path "/boot/loader/entries/\$(cat /etc/machine-id)-*" \
Harald Hoyer 414eba
   -not -path "/boot/\$(cat /etc/machine-id)/*" \
Harald Hoyer 414eba
   -exec rpm -qf '{}' ';' | \
Harald Hoyer 414eba
-  grep -F 'not owned' &> /test.output
Harald Hoyer 414eba
-exit
Harald Hoyer 414eba
+  grep -F 'not owned' &>> /test.output || :
Harald Hoyer 414eba
+exit 0
Harald Hoyer 414eba
 EOF
Harald Hoyer 414eba
 
Harald Hoyer 414eba
     chmod 0755 "$rootdir/test.sh"
Harald Hoyer 414eba
 
Harald Hoyer 414eba
-    chroot "$rootdir" /test.sh
Harald Hoyer 414eba
+    chroot "$rootdir" /test.sh || :
Harald Hoyer 414eba
 
Harald Hoyer 414eba
     if [[ -s "$rootdir"/test.output ]]; then
Harald Hoyer 414eba
 	failed=1