fish: Specify format of disks (RHBZ#642934,CVE-2010-3851).
[libguestfs.git] / regressions / test-lvm-filtering.sh
1 #!/bin/bash -
2 # libguestfs
3 # Copyright (C) 2010 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 LVM device filtering.
20
21 set -e
22
23 rm -f test1.img test2.img
24
25 actual=$(../fish/guestfish <<'EOF'
26 sparse test1.img 1G
27 sparse test2.img 1G
28
29 run
30
31 part-disk /dev/sda mbr
32 part-disk /dev/sdb mbr
33
34 pvcreate /dev/sda1
35 pvcreate /dev/sdb1
36
37 vgcreate VG1 /dev/sda1
38 vgcreate VG2 /dev/sdb1
39
40 # Should see VG1 and VG2
41 vgs
42
43 # Should see just VG1
44 lvm-set-filter /dev/sda
45 vgs
46 lvm-set-filter /dev/sda1
47 vgs
48
49 # Should see just VG2
50 lvm-set-filter /dev/sdb
51 vgs
52 lvm-set-filter /dev/sdb1
53 vgs
54
55 # Should see VG1 and VG2
56 lvm-set-filter "/dev/sda /dev/sdb"
57 vgs
58 lvm-set-filter "/dev/sda1 /dev/sdb1"
59 vgs
60 lvm-set-filter "/dev/sda /dev/sdb1"
61 vgs
62 lvm-set-filter "/dev/sda1 /dev/sdb"
63 vgs
64 lvm-clear-filter
65 vgs
66 EOF
67 )
68
69 expected="VG1
70 VG2
71 VG1
72 VG1
73 VG2
74 VG2
75 VG1
76 VG2
77 VG1
78 VG2
79 VG1
80 VG2
81 VG1
82 VG2
83 VG1
84 VG2"
85
86 rm -f test1.img test2.img
87
88 if [ "$actual" != "$expected" ]; then
89     echo "LVM filter test failed.  Actual output was:"
90     echo "$actual"
91     exit 1
92 fi