1 # Put lvm-related utilities here.
2 # This file is sourced from test-lib.sh.
4 # Copyright (C) 2007, 2008 Red Hat, Inc. All rights reserved.
6 # This copyrighted material is made available to anyone wishing to use,
7 # modify, copy, or redistribute it subject to the terms and conditions
8 # of the GNU General Public License v.2.
10 # You should have received a copy of the GNU General Public License
11 # along with this program; if not, write to the Free Software Foundation,
12 # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14 export LVM_SUPPRESS_FD_WARNINGS=1
17 warn() { echo >&2 "$ME: $@"; }
38 val1=$($cmd1 --noheadings -o $field1 $obj1)
39 val2=$($cmd2 --noheadings -o $field2 $obj2)
40 if test "$verbose" = "t"
42 echo "compare_two_fields_ $obj1($field1): $val1 $obj2($field2): $val2"
44 test "$val1" = "$val2"
55 val1=$(vgs --noheadings -o $field $vg1)
56 val2=$(vgs --noheadings -o $field $vg2)
57 if test "$verbose" = "t"
59 echo "compare_vg_field_ VG1: $val1 VG2: $val2"
61 test "$val1" = "$val2"
69 pvs --noheading -o $field $pv | sed 's/^ *//'
76 vgs --noheading -o $field $vg | sed 's/^ *//'
83 lvs --noheading -o $field $lv | sed 's/^ *//'
93 actual=$(trim $(vgs --noheadings -o $field $vg))
94 if test "$verbose" = "t"
96 echo "check_vg_field_ VG=$vg, field=$field, actual=$actual, expected=$expected"
98 test "$actual" = "$expected"
106 local pvs_args=$4; # optional
109 actual=$(trim $(pvs --noheadings $pvs_args -o $field $pv))
110 if test "$verbose" = "t"
112 echo "check_pv_field_ PV=$pv, field=$field, actual=$actual, expected=$expected"
114 test "$actual" = "$expected"
124 actual=$(trim $(lvs --noheadings -o $field $lv))
125 if test "$verbose" = "t"
127 echo "check_lv_field_ LV=$lv, field=$field, actual=$actual, expected=$expected"
129 test "$actual" = "$expected"
132 vg_validate_pvlv_counts_()
139 lvs -a -o+devices $local_vg
141 check_vg_field_ $local_vg pv_count $num_pvs && \
142 check_vg_field_ $local_vg lv_count $num_lvs && \
143 check_vg_field_ $local_vg snap_count $num_snaps
146 dmsetup_has_dm_devdir_support_()
148 # Detect support for the envvar. If it's supported, the
149 # following command will fail with the expected diagnostic.
150 out=$(DM_DEV_DIR=j dmsetup version 2>&1)
151 test "$?:$out" = "1:Invalid DM_DEV_DIR envvar value." -o \
152 "$?:$out" = "1:Invalid DM_DEV_DIR environment variable value."