Skip to contentSkip to conversation

master - tests: fix array usage

PATCH Zdenek Kabelac 1 participant 1 message Jul 10, 2017

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f818a83a1dea3d67ad4bc710ed0552a7175b38d7
Commit:        f818a83a1dea3d67ad4bc710ed0552a7175b38d7
Parent:        85e5a8803cee25aa676d30b478e9a3bd02c7d9ca
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Sat Jul 8 22:29:50 2017 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Mon Jul 10 14:23:53 2017 +0200

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(-)
test/shell/lvchange-raid-transient-failures.sh +3 -3
index a478204..2ac14b0 100644
@@ -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
test/shell/lvconvert-raid.sh +8 -7
index b4ba4c9..c5e6159 100644
@@ -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