fish: Don't fail if some mountpoints in /etc/fstab are bogus (RHBZ#668574).
[libguestfs.git] / regressions / test-inspect-fstab.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., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 # Test various aspects of core inspection of /etc/fstab.
20 # This also tests: https://bugzilla.redhat.com/668574
21
22 set -e
23 export LANG=C
24
25 guestfish=../fish/guestfish
26
27 rm -f test1.img test.fstab test.output
28
29 # Start with the regular (good) fedora image, modify /etc/fstab
30 # and then inspect it.
31 cp ../images/fedora.img test1.img
32
33 cat <<'EOF' > test.fstab
34 /dev/VG/Root / ext2 default 0 0
35
36 # Xen-style partition names.
37 /dev/xvda1 /boot ext2 default 0 0
38
39 # Non-existant device.
40 /dev/sdb3 /var ext2 default 0 0
41
42 # Non-existant mountpoint.
43 /dev/VG/LV1 /nosuchfile ext2 default 0 0
44 EOF
45
46 $guestfish -a test1.img <<'EOF'
47   run
48   mount-options "" /dev/VG/Root /
49   upload test.fstab /etc/fstab
50 EOF
51
52 rm test.fstab
53
54 # This will give a warning, but should not fail.
55 $guestfish -a test1.img -i <<'EOF' | sort > test.output
56   inspect-get-mountpoints /dev/VG/Root
57 EOF
58
59 rm test1.img
60
61 if [ "$(cat test.output)" != "/: /dev/VG/Root
62 /boot: /dev/vda1
63 /nosuchfile: /dev/VG/LV1
64 /var: /dev/sdb3" ]; then
65     echo "$0: error: unexpected output from inspect-get-mountpoints command"
66     cat test.output
67     exit 1
68 fi
69
70 rm test.output