1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

tests: fix array usage

Use bash arrays to pass devs.
This commit is contained in:
Zdenek Kabelac 2017-07-08 22:29:50 +02:00
parent 85e5a8803c
commit f818a83a1d
2 changed files with 11 additions and 10 deletions

View File

@ -32,14 +32,14 @@ function _check_raid
shift shift
local good=$1 local good=$1
shift shift
local devs=$* local devs=( "$@" )
aux wait_for_sync $vg $lv aux wait_for_sync $vg $lv
aux disable_dev --error --silent "$devs" aux disable_dev --error --silent "${devs[@]}"
mkfs.ext4 "$DM_DEV_DIR/$vg/$lv" mkfs.ext4 "$DM_DEV_DIR/$vg/$lv"
fsck.ext4 -fn "$DM_DEV_DIR/$vg/$lv" fsck.ext4 -fn "$DM_DEV_DIR/$vg/$lv"
check raid_leg_status $vg $lv "$fail" check raid_leg_status $vg $lv "$fail"
aux enable_dev --silent "$devs" aux enable_dev --silent "${devs[@]}"
lvs -a -o +devices $vg | tee out lvs -a -o +devices $vg | tee out
not grep unknown out not grep unknown out
lvchange --refresh $vg/$lv lvchange --refresh $vg/$lv

View File

@ -21,10 +21,10 @@ export LVM_TEST_LVMETAD_DEBUG_OPTS=${LVM_TEST_LVMETAD_DEBUG_OPTS-}
get_image_pvs() { get_image_pvs() {
local d local d
local images local images=()
images=$(dmsetup ls | grep "${1}-${2}_.image_.*" | cut -f1 | sed -e s:-:/:) images=( $(dmsetup ls | grep "${1}-${2}_.image_.*" | cut -f1 | sed -e s:-:/:) )
lvs --noheadings -a -o devices "$images" | sed s/\(.\)// lvs --noheadings -a -o devices "${images[@]}" | sed s/\(.\)//
} }
######################################################## ########################################################
@ -296,21 +296,22 @@ for i in {1..3}; do
for j in $(seq $(( i + 1 ))); do # The number of devs to replace at once for j in $(seq $(( i + 1 ))); do # The number of devs to replace at once
for o in $(seq 0 $i); do # The offset into the device list for o in $(seq 0 $i); do # The offset into the device list
replace="" replace=()
devices=( $(get_image_pvs $vg $lv1) ) devices=( $(get_image_pvs $vg $lv1) )
for k in $(seq "$j"); do for k in $(seq "$j"); do
index=$(( ( k + o ) % ( i + 1 ) )) index=$(( ( k + o ) % ( i + 1 ) ))
replace="$replace --replace ${devices[$index]}" replace+=( "--replace" )
replace+=( "${devices[$index]}" )
done done
aux wait_for_sync $vg $lv1 aux wait_for_sync $vg $lv1
if [ "$j" -ge $(( i + 1 )) ]; then if [ "$j" -ge $(( i + 1 )) ]; then
# Can't replace all at once. # Can't replace all at once.
not lvconvert "$replace" $vg/$lv1 not lvconvert "${replace[@]}" $vg/$lv1
else else
lvconvert "$replace" $vg/$lv1 lvconvert "${replace[@]}" $vg/$lv1
fi fi
done done
done done