]> git.ipfire.org Git - thirdparty/dracut.git/blob - test/TEST-99-RPM/test.sh
use "rm --" to guard against filenames beginning with "-"
[thirdparty/dracut.git] / test / TEST-99-RPM / test.sh
1 #!/bin/bash
2 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3 # ex: ts=8 sw=4 sts=4 et filetype=sh
4 TEST_DESCRIPTION="rpm integrity after dracut and kernel install"
5 $TESTDIR
6
7 test_run() {
8 set -x
9 export rootdir=$TESTDIR/root
10
11 mkdir -p $rootdir
12
13 mkdir -p "$rootdir/proc"
14 mkdir -p "$rootdir/sys"
15 mkdir -p "$rootdir/dev"
16
17 trap 'ret=$?; [[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umount "$rootdir/dev"; rm -rf -- "$rootdir"; }; exit $ret;' EXIT
18 trap '[[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umount "$rootdir/dev"; rm -rf -- "$rootdir"; }; exit 1;' SIGINT
19
20 mount --bind /proc "$rootdir/proc"
21 mount --bind /sys "$rootdir/sys"
22 mount -t devtmpfs devtmpfs "$rootdir/dev"
23
24 yum --nogpgcheck --releasever=/ --installroot "$rootdir"/ install -y \
25 yum \
26 passwd \
27 rootfiles \
28 systemd \
29 kernel \
30 fedora-release \
31 device-mapper-multipath \
32 lvm2 \
33 mdadm \
34 bash \
35 iscsi-initiator-utils \
36 $basedir/dracut-[0-9]*.$(arch).rpm \
37 $basedir/dracut-network-[0-9]*.$(arch).rpm
38
39 cat >"$rootdir"/test.sh <<EOF
40 #!/bin/bash
41 set -x
42 export LC_MESSAGES=C
43 rpm -Va &> /test.output
44 find / -xdev -type f -not -path '/var/*' \
45 -not -path '/usr/lib/modules/*/modules.*' \
46 -not -path '/etc/*-' \
47 -not -path '/etc/.pwd.lock' \
48 -not -path '/run/mount/utab' \
49 -not -path '/test.sh' \
50 -not -path '/test.output' \
51 -not -path '/etc/nsswitch.conf.bak' \
52 -not -path '/etc/iscsi/initiatorname.iscsi' \
53 -not -path '/boot/*0-rescue*' \
54 -not -path '/dev/null' \
55 -not -path "/boot/loader/entries/\$(cat /etc/machine-id)-*" \
56 -not -path "/boot/\$(cat /etc/machine-id)/*" \
57 -exec rpm -qf '{}' ';' | \
58 grep -F 'not owned' &> /test.output
59 exit
60 EOF
61
62 chmod 0755 "$rootdir/test.sh"
63
64 chroot "$rootdir" /test.sh
65
66 if [[ -s "$rootdir"/test.output ]]; then
67 failed=1
68 echo TEST Failed >&2
69 cat "$rootdir"/test.output >&2
70 fi
71
72 umount "$rootdir/proc"
73 umount "$rootdir/sys"
74 umount "$rootdir/dev"
75
76 [[ $failed ]] && return 1
77 return 0
78
79 }
80
81 test_setup() {
82 return 0
83 }
84
85 test_cleanup() {
86 return 0
87 }
88
89 . $testdir/test-functions