From f818a83a1dea3d67ad4bc710ed0552a7175b38d7 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Sat, 8 Jul 2017 22:29:50 +0200 Subject: [PATCH] tests: fix array usage Use bash arrays to pass devs. --- test/shell/lvchange-raid-transient-failures.sh | 6 +++--- test/shell/lvconvert-raid.sh | 15 ++++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/test/shell/lvchange-raid-transient-failures.sh b/test/shell/lvchange-raid-transient-failures.sh index a478204cd..2ac14b072 100644 --- a/test/shell/lvchange-raid-transient-failures.sh +++ b/test/shell/lvchange-raid-transient-failures.sh @@ -32,14 +32,14 @@ function _check_raid shift local good=$1 shift - local devs=$* + local devs=( "$@" ) 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" fsck.ext4 -fn "$DM_DEV_DIR/$vg/$lv" check raid_leg_status $vg $lv "$fail" - aux enable_dev --silent "$devs" + aux enable_dev --silent "${devs[@]}" lvs -a -o +devices $vg | tee out not grep unknown out lvchange --refresh $vg/$lv diff --git a/test/shell/lvconvert-raid.sh b/test/shell/lvconvert-raid.sh index b4ba4c9a5..c5e61593e 100644 --- a/test/shell/lvconvert-raid.sh +++ b/test/shell/lvconvert-raid.sh @@ -21,10 +21,10 @@ export LVM_TEST_LVMETAD_DEBUG_OPTS=${LVM_TEST_LVMETAD_DEBUG_OPTS-} get_image_pvs() { local d - local images + local images=() - images=$(dmsetup ls | grep "${1}-${2}_.image_.*" | cut -f1 | sed -e s:-:/:) - lvs --noheadings -a -o devices "$images" | sed s/\(.\)// + images=( $(dmsetup ls | grep "${1}-${2}_.image_.*" | cut -f1 | sed -e 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 o in $(seq 0 $i); do # The offset into the device list - replace="" + replace=() devices=( $(get_image_pvs $vg $lv1) ) for k in $(seq "$j"); do index=$(( ( k + o ) % ( i + 1 ) )) - replace="$replace --replace ${devices[$index]}" + replace+=( "--replace" ) + replace+=( "${devices[$index]}" ) done aux wait_for_sync $vg $lv1 if [ "$j" -ge $(( i + 1 )) ]; then # Can't replace all at once. - not lvconvert "$replace" $vg/$lv1 + not lvconvert "${replace[@]}" $vg/$lv1 else - lvconvert "$replace" $vg/$lv1 + lvconvert "${replace[@]}" $vg/$lv1 fi done done