1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
#!/bin/bash -
# libguestfs
# Copyright (C) 2011 Red Hat Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# Test various aspects of core inspection of /etc/fstab.
# This also tests: https://bugzilla.redhat.com/668574
set -e
export LANG=C
guestfish=../../fish/guestfish
rm -f test1.img test.fstab test.output
# Start with the regular (good) fedora image, modify /etc/fstab
# and then inspect it.
cp ../guests/fedora.img test1.img
cat <<'EOF' > test.fstab
/dev/VG/Root / ext2 default 0 0
# Xen-style partition names.
/dev/xvda1 /boot ext2 default 0 0
# Non-existant device.
/dev/sdb3 /var ext2 default 0 0
# Non-existant mountpoint.
/dev/VG/LV1 /nosuchfile ext2 default 0 0
EOF
$guestfish -a test1.img <<'EOF'
run
mount-options "" /dev/VG/Root /
upload test.fstab /etc/fstab
EOF
# This will give a warning, but should not fail.
$guestfish -a test1.img -i <<'EOF' | sort > test.output
inspect-get-mountpoints /dev/VG/Root
EOF
if [ "$(cat test.output)" != "/: /dev/VG/Root
/boot: /dev/vda1
/nosuchfile: /dev/VG/LV1
/var: /dev/sdb3" ]; then
echo "$0: error #1: unexpected output from inspect-get-mountpoints command"
cat test.output
exit 1
fi
# Test device name hints
cat <<'EOF' > test.fstab
/dev/VG/Root / ext2 default 0 0
# Device name which requires a hint
/dev/xvdg1 /boot ext2 default 0 0
EOF
$guestfish -a test1.img <<'EOF'
run
mount-options "" /dev/VG/Root /
upload test.fstab /etc/fstab
EOF
$guestfish <<'EOF' > test.output
add-drive-opts test1.img readonly:true name:xvdg
run
inspect-os
inspect-get-mountpoints /dev/VG/Root
EOF
if [ "$(cat test.output)" != "/dev/VG/Root
/: /dev/VG/Root
/boot: /dev/vda1" ]; then
echo "$0: error #2: unexpected output from inspect-get-mountpoints command"
cat test.output
exit 1
fi
cat <<'EOF' > test.fstab
/dev/VG/Root / ext2 default 0 0
# cciss device which requires a hint
/dev/cciss/c1d3p1 /boot ext2 default 0 0
# cciss device, whole disk
/dev/cciss/c1d3 /var ext2 default 0 0
EOF
$guestfish -a test1.img <<'EOF'
run
mount-options "" /dev/VG/Root /
upload test.fstab /etc/fstab
EOF
$guestfish <<'EOF' > test.output
add-drive-opts test1.img readonly:true name:cciss/c1d3
run
inspect-os
inspect-get-mountpoints /dev/VG/Root
EOF
if [ "$(cat test.output)" != "/dev/VG/Root
/: /dev/VG/Root
/boot: /dev/vda1
/var: /dev/vda" ]; then
echo "$0: error #3: unexpected output from inspect-get-mountpoints command"
cat test.output
exit 1
fi
rm test.fstab
rm test1.img
rm test.output
|