Skip to contentSkip to conversation

master - tests: math drop uncessary $/${}

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=146bfb2417de3e6cd719b5aef900bf927a39a0cd
Commit:        146bfb2417de3e6cd719b5aef900bf927a39a0cd
Parent:        72e82b42a9c07293fdfae7ec0a98dd9fe5a0c868
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Thu Jul 6 19:27:04 2017 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Mon Jul 10 14:23:53 2017 +0200

tests: math drop uncessary $/${}

$/${} is unnecessary on arithmetic variables.

Use $((..)) instead of deprecated $[..]

---
 test/shell/lvchange-raid.sh                 |    6 +-
 test/shell/lvconvert-mirror-basic.sh        |    8 +-
 test/shell/lvconvert-raid.sh                |    4 +-
 test/shell/lvconvert-raid456.sh             |    2 +-
 test/shell/metadata-balance.sh              |   84 +++++++++++++-------------
 test/shell/mirror-vgreduce-removemissing.sh |    2 +-
 test/shell/pvcreate-bootloaderarea.sh       |    4 +-
 test/shell/pvcreate-operation-md.sh         |    2 +-
 test/shell/pvcreate-usage.sh                |    8 +-
 test/shell/pvmove-restart.sh                |    2 +-
 test/shell/read-ahead.sh                    |    2 +-
 test/shell/topology-support.sh              |    2 +-
 test/shell/vgextend-usage.sh                |    4 +-
 13 files changed, 65 insertions(+), 65 deletions(-)
test/shell/lvchange-raid.sh +3 -3
index 2fe011a..ce29768 100644
@@ -152,15 +152,15 @@ run_syncaction_check() {
 	device=$(get lv_devices $vg/${lv}_rimage_1)
 
 	size=$(get lv_field $vg/${lv}_rimage_1 size -a --units 1k)
-	size=$((${size%\.00k} / 2))
+	size=$(( ${size%\.00k} / 2 ))
 
 	tmp=$(get pv_field "$device" mda_size --units 1k)
 	seek=${tmp%\.00k} # Jump over MDA
 
 	tmp=$(get lv_field $vg/${lv}_rmeta_1 size -a --units 1k)
-	seek=$(($seek + ${tmp%\.00k}))  # Jump over RAID metadata image
+	seek=$(( seek + ${tmp%\.00k} ))  # Jump over RAID metadata image
 
-	seek=$(($seek + $size)) # Jump halfway through the RAID image
+	seek=$(( seek + size )) # Jump halfway through the RAID image
 
 	check lv_attr_bit health $vg/$lv "-"
 	check lv_field $vg/$lv raid_mismatch_count "0"
test/shell/lvconvert-mirror-basic.sh +4 -4
index 0b73d8c..0959af8 100644
@@ -44,10 +44,10 @@ log_name_to_count() {
 
 test_lvconvert() {
 	local start_count=$1
-	local start_count_p1=$(($start_count + 1))
+	local start_count_p1=$(( start_count + 1 ))
 	local start_log_type=$2
 	local finish_count=$3
-	local finish_count_p1=$(($finish_count + 1))
+	local finish_count_p1=$(( finish_count + 1 ))
 	local finish_log_type=$4
 	local dev_array=( "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" )
 	local start_log_count
@@ -78,7 +78,7 @@ test_lvconvert() {
 
 	if [ $start_count -gt 0 ]; then
 		# Are there extra devices for the log or do we overlap
-		if [ $(($start_count_p1 + $start_log_count)) -gt ${#dev_array[@]} ]; then
+		if [ $(( start_count_p1 + start_log_count )) -gt ${#dev_array[@]} ]; then
 			alloc="--alloc anywhere"
 		fi
 
@@ -94,7 +94,7 @@ test_lvconvert() {
 	test $active || lvchange -an $vg/$lv1
 
 	# Are there extra devices for the log or do we overlap
-	if [ $(($finish_count_p1 + $finish_log_count)) -gt ${#dev_array[@]} ]; then
+	if [ $(( finish_count_p1 +  finish_log_count )) -gt ${#dev_array[@]} ]; then
 		alloc="--alloc anywhere"
 	fi
 
test/shell/lvconvert-raid.sh +2 -2
index a110ac5..8b4ebf4 100644
@@ -65,7 +65,7 @@ for i in 1 2 3; do
 
 			lvcreate -aey -l 2 -n $lv1 $vg
 		else
-			lvcreate --type raid1 -m $(($i - 1)) -l 2 -n $lv1 $vg
+			lvcreate --type raid1 -m $(( i - 1 )) -l 2 -n $lv1 $vg
 			aux wait_for_sync $vg $lv1
 		fi
 
@@ -299,7 +299,7 @@ for i in {1..3}; do
 		devices=( $(get_image_pvs $vg $lv1) )
 
 		for k in $(seq "$j"); do
-			index=$((($k + $o) % ($i + 1)))
+			index=$(( ( k +  o ) % ( i + 1 ) ))
 			replace="$replace --replace ${devices[$index]}"
 		done
 		aux wait_for_sync $vg $lv1
test/shell/lvconvert-raid456.sh +1 -1
index 0e3f378..43fe503 100644
@@ -53,7 +53,7 @@ for i in $levels; do
 		devices=( $(get_image_pvs $vg $lv1) )
 
 		for k in $(seq $j); do
-			index=$((($k + $o) % $dev_cnt))
+			index=$(( ( k + o ) % dev_cnt ))
 			replace="$replace --replace ${devices[$index]}"
 		done
 		aux wait_for_sync $vg $lv1
test/shell/metadata-balance.sh +42 -42

182 lines not on this page · raw message

test/shell/mirror-vgreduce-removemissing.sh +1 -1
index ac7303f..3d9ecd5 100644
@@ -83,7 +83,7 @@ rest_pvs_()
 	local n
 	local dev
 
-	for n in $(seq 1 $(($index - 1))) $(seq $(($index + 1)) $num); do
+	for n in $(seq 1 $(( index - 1 )) ) $(seq $(( index + 1 )) $num); do
 		eval dev=$\dev$n
 		rem="$rem $dev"
 	done
test/shell/pvcreate-bootloaderarea.sh +2 -2
index 258c4cb..1147a3b 100644
@@ -30,7 +30,7 @@ check pv_field "$dev1" pe_start "1048576"
 
 #COMM 'pvcreate with booloader area size - test corner cases'
 dev_size=$(pvs -o pv_size --noheadings "$dev1")
-pv_size=$[dev_size - 1048576] # device size - 1m pe_start = area for data
+pv_size=$(( dev_size - 1048576 )) # device size - 1m pe_start = area for data
 
 # try to use the whole data area for bootloader area, remaining data area is zero then (pe_start = pv_size)
 pvcreate --bootloaderareasize ${pv_size}b --dataalignment 1048576b "$dev1"
@@ -39,7 +39,7 @@ check pv_field "$dev1" ba_start 1048576
 check pv_field "$dev1" ba_size $pv_size
 
 # try to use the whole data area for bootloader area only and add one more byte - this must error out
-not pvcreate --bootloaderareasize $[pv_size + 1] --dataalignment 1048576b "$dev1" 2>err
+not pvcreate --bootloaderareasize $(( pv_size + 1 )) --dataalignment 1048576b "$dev1" 2>err
 grep "Bootloader area with data-aligned start must not exceed device size" err
 
 # restoring the PV should also restore the bootloader area correctly
test/shell/pvcreate-operation-md.sh +1 -1
index 447b15e..d228ada 100644
@@ -96,7 +96,7 @@ EOF
 		alignment_offset=0
 
 	# default alignment is 1M, add alignment_offset
-	pv_align=$((1048576+$alignment_offset))
+	pv_align=$(( 1048576 + alignment_offset ))
 	check pv_field "${pvdev}p1" pe_start $pv_align --units b --nosuffix
 
 	pvremove "${pvdev}p1"
test/shell/pvcreate-usage.sh +4 -4
index 97342ba..f0e6ee6 100644
@@ -15,7 +15,7 @@ SKIP_WITH_LVMLOCKD=1
 SKIP_WITH_LVMPOLLD=1
 PAGESIZE=$(getconf PAGESIZE)
 # MDA_SIZE_MIN defined in lib/format_text/layout.h
-MDA_SIZE_MIN=$((8*$PAGESIZE))
+MDA_SIZE_MIN=$(( 8 * PAGESIZE ))
 
 . lib/inittest
 
@@ -28,7 +28,7 @@ not pvcreate --setphysicalvolumesize -1024 "$dev1"
 not pvcreate --metadatasize -1024 "$dev1"
 
 #COMM 'pvcreate rejects metadatasize that is less than minimum size'
-not pvcreate --dataalignment $((${MDA_SIZE_MIN}/2))b --metadatasize $((${MDA_SIZE_MIN}/2))b "$dev1" 2>err
+not pvcreate --dataalignment $(( MDA_SIZE_MIN / 2 ))b --metadatasize $(( MDA_SIZE_MIN / 2 ))b "$dev1" 2>err
 grep "Metadata area size too small" err
 
 #COMM 'pvcreate accepts metadatasize that is at least the minimum size'
@@ -193,11 +193,11 @@ for ignore in y n; do
 	echo "vgcreate has proper vg_mda_count and vg_mda_used_count"
 	if [ $pv_in_vg = 1 ]; then
 		vgcreate $vg "$dev1" "$dev2"
-		check vg_field $vg vg_mda_count "$(($mdacp * 2))"
+		check vg_field $vg vg_mda_count $(( mdacp * 2 ))
 		if [ $ignore = y ]; then
 			check vg_field $vg vg_mda_used_count "1"
 		else
-			check vg_field $vg vg_mda_used_count "$(($mdacp * 2))"
+			check vg_field $vg vg_mda_used_count "$(( mdacp * 2 ))"
 		fi
 		check vg_field $vg vg_mda_copies "unmanaged"
 		vgremove $vg
test/shell/pvmove-restart.sh +1 -1
index 14806cb..abdcd86 100644
@@ -55,7 +55,7 @@ j=0
 for i in $lv1 pvmove0 pvmove0_mimage_0 pvmove0_mimage_1 ; do
 	while dmsetup status "$vg-$i"; do
 		dmsetup remove "$vg-$i" || {
-			j=$(($j + 1))
+			j=$(( j + 1 ))
 			test $j -le 100 || die "Cannot take down devices."
 			sleep .1;
 		}
test/shell/read-ahead.sh +1 -1
index f21c52c..9045de8 100644
@@ -25,7 +25,7 @@ aux prepare_vg 5
 #COMM "test various read ahead settings (bz450922)"
 lvcreate -l 100%FREE -i5 -I512 -n $lv $vg
 ra=$(get lv_field $vg/$lv lv_kernel_read_ahead --units s --nosuffix)
-test $(( ( $ra / 5 ) * 5 )) -le $ra
+test $(( ( ra / 5 ) * 5 )) -le $ra
 not lvchange -r auto $vg/$lv 2>&1 | grep auto
 check lv_field $vg/$lv lv_read_ahead auto
 lvchange -r 640 $vg/$lv
test/shell/topology-support.sh +1 -1
index 1cb0f49..ffa3fe6 100644
@@ -45,7 +45,7 @@ test_snapshot_mount() {
 
 NUM_DEVS=1
 PER_DEV_SIZE=34
-DEV_SIZE=$(($NUM_DEVS*$PER_DEV_SIZE))
+DEV_SIZE=$(( NUM_DEVS * PER_DEV_SIZE ))
 
 # ---------------------------------------------
 # Create "desktop-class" 4K drive
test/shell/vgextend-usage.sh +2 -2
index a3bfa2a..178df4d 100644
@@ -127,11 +127,11 @@ for ignore in y n; do
 		check pv_field "$dev2" pv_mda_used_count $mdacp
 	fi
 	echo vg has proper vg_mda_count and vg_mda_used_count
-	check vg_field $vg vg_mda_count $(($mdacp * 2 + 1))
+	check vg_field $vg vg_mda_count $(( mdacp * 2 + 1 ))
 	if [ $ignore = y ]; then
 		check vg_field $vg vg_mda_used_count 1
 	else
-		check vg_field $vg vg_mda_used_count $(($mdacp * 2 + 1))
+		check vg_field $vg vg_mda_used_count $(( mdacp * 2 + 1 ))
 	fi
 	check vg_field $vg vg_mda_copies unmanaged
 	vgremove $vg