3 # Copyright (C) 2011 Red Hat Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 # Test various aspects of core inspection of /etc/fstab.
20 # This also tests: https://bugzilla.redhat.com/668574
25 guestfish=../fish/guestfish
27 rm -f test1.img test.fstab test.output
29 # Start with the regular (good) fedora image, modify /etc/fstab
30 # and then inspect it.
31 cp ../images/fedora.img test1.img
33 cat <<'EOF' > test.fstab
34 /dev/VG/Root / ext2 default 0 0
36 # Xen-style partition names.
37 /dev/xvda1 /boot ext2 default 0 0
39 # Non-existant device.
40 /dev/sdb3 /var ext2 default 0 0
42 # Non-existant mountpoint.
43 /dev/VG/LV1 /nosuchfile ext2 default 0 0
46 $guestfish -a test1.img <<'EOF'
48 mount-options "" /dev/VG/Root /
49 upload test.fstab /etc/fstab
52 # This will give a warning, but should not fail.
53 $guestfish -a test1.img -i <<'EOF' | sort > test.output
54 inspect-get-mountpoints /dev/VG/Root
57 if [ "$(cat test.output)" != "/: /dev/VG/Root
59 /nosuchfile: /dev/VG/LV1
60 /var: /dev/sdb3" ]; then
61 echo "$0: error: unexpected output from inspect-get-mountpoints command"
66 # Test device name hints
68 cat <<'EOF' > test.fstab
69 /dev/VG/Root / ext2 default 0 0
71 # Device name which requires a hint
72 /dev/xvdg1 /boot ext2 default 0 0
75 $guestfish -a test1.img <<'EOF'
77 mount-options "" /dev/VG/Root /
78 upload test.fstab /etc/fstab
81 $guestfish <<'EOF' > test.output
82 add-drive-opts test1.img readonly:true name:xvdg
85 inspect-get-mountpoints /dev/VG/Root
88 if [ "$(cat test.output)" != "/dev/VG/Root
90 /boot: /dev/vda1" ]; then
91 echo "$0: error: unexpected output from inspect-get-mountpoints command"
96 cat <<'EOF' > test.fstab
97 /dev/VG/Root / ext2 default 0 0
99 # cciss device which requires a hint
100 /dev/cciss/c1d3p1 /boot ext2 default 0 0
102 # cciss device, whole disk
103 /dev/cciss/c1d3 /var ext2 default 0 0
106 $guestfish -a test1.img <<'EOF'
108 mount-options "" /dev/VG/Root /
109 upload test.fstab /etc/fstab
112 $guestfish <<'EOF' > test.output
113 add-drive-opts test1.img readonly:true name:cciss/c1d3
116 inspect-get-mountpoints /dev/VG/Root
119 if [ "$(cat test.output)" != "/dev/VG/Root
122 /var: /dev/vda" ]; then
123 echo "$0: error: unexpected output from inspect-get-mountpoints command"