2a6cb6a920b18aa76c8b14d02f8b16eeb65cf429
[libguestfs.git] / tests / md / test-inspect-fstab-md.sh
1 #!/bin/bash -
2 # libguestfs
3 # Copyright (C) 2011 Red Hat Inc.
4 #
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.
9 #
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.
14 #
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.
18
19 # Test the handling of MD devices specified in /etc/fstab
20
21 set -e
22 export LANG=C
23
24 # The first test requires a new Augeas lens for parsing mdadm.conf.
25 # If this is not present in the appliance or on the host, skip the
26 # test.
27 f=$(grep mdadm_conf.aug ../../appliance/supermin.d/hostfiles | head -1)
28 if [ -z "$f" -o ! -f "$f" ]; then
29     echo "$0: test skipped because Augeas mdadm.conf lens is not available."
30     exit 0
31 fi
32
33 guestfish=../../fish/guestfish
34
35 rm -f test1.img test.fstab test.output
36
37 # First, test the regular fedora image, which specifies /boot as /dev/md0
38 cp ../../images/fedora-md1.img test1.img
39 cp ../../images/fedora-md2.img test2.img
40
41 $guestfish -i test[12].img <<'EOF' | sort > test.output
42   exists /boot/grub/grub.conf
43 EOF
44
45 if [ "$(cat test.output)" != "true" ]; then
46     echo "$0: /boot not correctly mounted (/dev/md0)"
47     exit 1
48 fi
49
50 # Test inspection when /boot is specfied as /dev/md/boot
51 cat <<'EOF' > test.fstab
52 /dev/VG/Root / ext2 default 0 0
53 /dev/md/boot /boot ext2 default 0 0
54 EOF
55
56 $guestfish -a test1.img -a test2.img <<'EOF'
57   run
58   mount-options "" /dev/VG/Root /
59   upload test.fstab /etc/fstab
60 EOF
61
62 $guestfish -i test[12].img <<'EOF' | sort > test.output
63   exists /boot/grub/grub.conf
64 EOF
65
66 if [ "$(cat test.output)" != "true" ]; then
67     echo "$0: error: /boot not correctly mounted (/dev/md/boot)"
68     cat test.output
69     exit 1
70 fi
71
72 rm test.fstab
73 rm test[12].img
74 rm test.output