Import lvm2 from NetBSD
[dragonfly.git] / contrib / lvm2 / dist / test / t-vgchange-usage.sh
1 #!/bin/sh
2 # Copyright (C) 2008 Red Hat, Inc. All rights reserved.
3 #
4 # This copyrighted material is made available to anyone wishing to use,
5 # modify, copy, or redistribute it subject to the terms and conditions
6 # of the GNU General Public License v.2.
7 #
8 # You should have received a copy of the GNU General Public License
9 # along with this program; if not, write to the Free Software Foundation,
10 # Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
11
12 test_description='Exercise some vgchange diagnostics'
13
14 . ./test-utils.sh
15
16 aux prepare_pvs 3
17 pvcreate --metadatacopies 0 $dev1
18 vgcreate $vg $devs
19
20 get_vg_field() {
21         local vg=$1
22         local field=$2
23         local value
24         vgs --noheading -o $field $vg | sed 's/^ *//'
25 }
26
27 vgdisplay $vg
28
29 # vgchange -p MaxPhysicalVolumes (bz202232)
30 aux check_vg_field_ $vg max_pv 0
31 vgchange -p 128 $vg
32 aux check_vg_field_ $vg max_pv 128
33
34 pv_count=$(get_vg_field $vg pv_count)
35 not vgchange -p 2 $vg 2>err
36 grep "MaxPhysicalVolumes is less than the current number $pv_count of PVs for" err
37 aux check_vg_field_ $vg max_pv 128
38
39 # vgchange -l MaxLogicalVolumes
40 aux check_vg_field_ $vg max_lv 0
41 vgchange -l 128 $vg
42 aux check_vg_field_ $vg max_lv 128
43
44 lvcreate -l4 -n$lv1 $vg
45 lvcreate -l4 -n$lv2 $vg
46
47 lv_count=$(get_vg_field $vg lv_count)
48 not vgchange -l 1 $vg 2>err
49 grep "MaxLogicalVolume is less than the current number $lv_count of LVs for"  err
50 aux check_vg_field_ $vg max_lv 128
51