mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-23 21:35:29 +03:00
Add shell function to trim spaces.
Test values as "$val" to avoid weird results when spaces are in output.
This commit is contained in:
parent
fcf46a9a42
commit
903bfcaf4b
@ -16,6 +16,14 @@ export LVM_SUPPRESS_FD_WARNINGS=1
|
|||||||
ME=$(basename "$0")
|
ME=$(basename "$0")
|
||||||
warn() { echo >&2 "$ME: $@"; }
|
warn() { echo >&2 "$ME: $@"; }
|
||||||
|
|
||||||
|
trim()
|
||||||
|
{
|
||||||
|
trimmed=${1%% }
|
||||||
|
trimmed=${trimmed## }
|
||||||
|
|
||||||
|
echo "$trimmed"
|
||||||
|
}
|
||||||
|
|
||||||
compare_two_fields_()
|
compare_two_fields_()
|
||||||
{
|
{
|
||||||
local cmd1=$1;
|
local cmd1=$1;
|
||||||
@ -33,7 +41,7 @@ if test "$verbose" = "t"
|
|||||||
then
|
then
|
||||||
echo "compare_two_fields_ $obj1($field1): $val1 $obj2($field2): $val2"
|
echo "compare_two_fields_ $obj1($field1): $val1 $obj2($field2): $val2"
|
||||||
fi
|
fi
|
||||||
test $val1 = $val2
|
test "$val1" = "$val2"
|
||||||
}
|
}
|
||||||
|
|
||||||
compare_vg_field_()
|
compare_vg_field_()
|
||||||
@ -50,7 +58,7 @@ if test "$verbose" = "t"
|
|||||||
then
|
then
|
||||||
echo "compare_vg_field_ VG1: $val1 VG2: $val2"
|
echo "compare_vg_field_ VG1: $val1 VG2: $val2"
|
||||||
fi
|
fi
|
||||||
test $val1 = $val2
|
test "$val1" = "$val2"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -82,12 +90,12 @@ check_vg_field_()
|
|||||||
local expected=$3;
|
local expected=$3;
|
||||||
local actual;
|
local actual;
|
||||||
|
|
||||||
actual=$(vgs --noheadings -o $field $vg)
|
actual=$(trim $(vgs --noheadings -o $field $vg))
|
||||||
if test "$verbose" = "t"
|
if test "$verbose" = "t"
|
||||||
then
|
then
|
||||||
echo "check_vg_field_ VG=$vg, field=$field, actual=$actual, expected=$expected"
|
echo "check_vg_field_ VG=$vg, field=$field, actual=$actual, expected=$expected"
|
||||||
fi
|
fi
|
||||||
test $actual = $expected
|
test "$actual" = "$expected"
|
||||||
}
|
}
|
||||||
|
|
||||||
check_pv_field_()
|
check_pv_field_()
|
||||||
@ -97,12 +105,12 @@ check_pv_field_()
|
|||||||
local expected=$3;
|
local expected=$3;
|
||||||
local actual;
|
local actual;
|
||||||
|
|
||||||
actual=$(pvs --noheadings -o $field $pv)
|
actual=$(trim $(pvs --noheadings -o $field $pv))
|
||||||
if test "$verbose" = "t"
|
if test "$verbose" = "t"
|
||||||
then
|
then
|
||||||
echo "check_pv_field_ PV=$pv, field=$field, actual=$actual, expected=$expected"
|
echo "check_pv_field_ PV=$pv, field=$field, actual=$actual, expected=$expected"
|
||||||
fi
|
fi
|
||||||
test $actual = $expected
|
test "$actual" = "$expected"
|
||||||
}
|
}
|
||||||
|
|
||||||
check_lv_field_()
|
check_lv_field_()
|
||||||
@ -112,12 +120,12 @@ check_lv_field_()
|
|||||||
local expected=$3;
|
local expected=$3;
|
||||||
local actual;
|
local actual;
|
||||||
|
|
||||||
actual=$(lvs --noheadings -o $field $lv)
|
actual=$(trim $(lvs --noheadings -o $field $lv))
|
||||||
if test "$verbose" = "t"
|
if test "$verbose" = "t"
|
||||||
then
|
then
|
||||||
echo "check_lv_field_ LV=$lv, field=$field, actual=$actual, expected=$expected"
|
echo "check_lv_field_ LV=$lv, field=$field, actual=$actual, expected=$expected"
|
||||||
fi
|
fi
|
||||||
test $actual = $expected
|
test "$actual" = "$expected"
|
||||||
}
|
}
|
||||||
|
|
||||||
vg_validate_pvlv_counts_()
|
vg_validate_pvlv_counts_()
|
||||||
|
@ -26,7 +26,7 @@ do
|
|||||||
pvchange $dev1 --addtag test$mda
|
pvchange $dev1 --addtag test$mda
|
||||||
check_pv_field_ $dev1 pv_tags test$mda
|
check_pv_field_ $dev1 pv_tags test$mda
|
||||||
pvchange $dev1 --deltag test$mda
|
pvchange $dev1 --deltag test$mda
|
||||||
check_pv_field_ $dev1 pv_tags " "
|
check_pv_field_ $dev1 pv_tags ""
|
||||||
|
|
||||||
# "vgchange disable/enable allocation for pvs with metadatacopies = $mda (bz452982)"
|
# "vgchange disable/enable allocation for pvs with metadatacopies = $mda (bz452982)"
|
||||||
pvchange $dev1 -x n
|
pvchange $dev1 -x n
|
||||||
|
Loading…
Reference in New Issue
Block a user