11442868fcb7f33a4af12dc0f3f69b6048229781
[libguestfs.git] / regressions / test-list-filesystems.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 guestfish list-mddevices command
20
21 set -e
22
23 # Create 2 disks partitioned as:
24 # sda1: 20M ext3
25 # sda2: 20M MD (md127)
26 #
27 # sdb1: 20M PV (vg0)
28 # sdb2: 20M MD (md127)
29 #
30 # md127 : 20M ext4
31 # vg0 : 16M LV (lv0)
32 # lv0 : 16M vfat
33 output=$(
34 ../fish/guestfish <<EOF
35 # Add 2 empty disks
36 sparse fs-test1.img 50M
37 sparse fs-test2.img 50M
38 run
39
40 part-init /dev/sda mbr
41 part-add /dev/sda p 64 41023
42 part-add /dev/sda p 41024 81983
43 part-init /dev/sdb mbr
44 part-add /dev/sdb p 64 41023
45 part-add /dev/sdb p 41024 81983
46
47 # Create vg0 and lv0 on /dev/sdb1
48 pvcreate /dev/sdb1
49 vgcreate vg0 /dev/sdb1
50 lvcreate lv0 vg0 16
51
52 # Create an md device from sda2 and sdb2
53 mdadm-create test "/dev/sda2 /dev/sdb2" level:raid1
54
55 # Create filesystems
56 mkfs ext3 /dev/sda1
57 mkfs ext4 /dev/md127
58 mkfs vfat /dev/vg0/lv0
59
60 list-filesystems
61 EOF
62 )
63
64 expected="/dev/vda1: ext3
65 /dev/md127: ext4
66 /dev/vg0/lv0: vfat"
67
68 # Check the output of list-filesystems
69 if [ "$output" != "$expected" ]; then
70     echo "$0: error: output of list-filesystems did not match expected output"
71     printf "%s\n" "$output"
72     exit 1;
73 fi
74
75
76 rm -f fs-test1.img fs-test2.img