TEST-50-MULTINIC: fixup test suite
[platform/upstream/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 '/dev/null' \
54   -exec rpm -qf '{}' ';' | \
55   fgrep 'not owned' &> /test.output
56 exit
57 EOF
58
59     chmod 0755 "$rootdir/test.sh"
60
61     chroot "$rootdir" /test.sh
62
63     if [[ -s "$rootdir"/test.output ]]; then
64         failed=1
65         echo TEST Failed >&2
66         cat "$rootdir"/test.output >&2
67     fi
68
69     umount "$rootdir/proc"
70     umount "$rootdir/sys"
71     umount "$rootdir/dev"
72
73     [[ $failed ]] && return 1
74     return 0
75
76 }
77
78 test_setup() {
79     return 0
80 }
81
82 test_cleanup() {
83     return 0
84 }
85
86 . $testdir/test-functions