From fd3bfcd73ee93e356adb716b11feca4bfd860af4 Mon Sep 17 00:00:00 2001 From: Frank Zago Date: Tue, 3 Feb 2015 14:27:54 -0600 Subject: [PATCH] LU-6205 tests: fix bash expansion of fid When calling lfs path2fid, the FID is returned between bracket. When that fid variable is used, it may be expanded by the shell to something else. For instance: $ touch x $ ../utils/lfs fid2path lustre [0x200000be7:0xb:0x0] bad FID format [x], should be [0x1:0x2:0x0] fid2path: error on FID x: Invalid argument This will cause some tests, like 154A or 238, to sometimes fail. Use quotes where the FIDs are used. Replace "$(lfs ..." with "$($LFS ..." and made a couple variables local. Signed-off-by: frank zago Change-Id: I3c1a34585ebaa596d66063f5ada3ccfc4d202ade Reviewed-on: http://review.whamcloud.com/13618 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Jian Yu --- lustre/tests/sanity.sh | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 9ac5f84..d76aa06 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -5028,7 +5028,7 @@ test_56z() { # LU-4824 error "$LFS find did not return an error" # Make a directory unsearchable. This should NOT be the last entry in # directory order. Arbitrarily pick the 6th entry - chmod 700 $(lfs find $DIR/$tdir -type d | sed '6!d') + chmod 700 $($LFS find $DIR/$tdir -type d | sed '6!d') local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l) # The user should be able to see 10 directories and 9 files [ $count == 19 ] || error "$LFS find did not continue after error" @@ -5975,7 +5975,7 @@ test_78() { # bug 10901 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL [[ $F78SIZE -gt 512 ]] && F78SIZE=512 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024)) - SMALLESTOST=$(lfs df $DIR | grep OST | awk '{ print $4 }' | sort -n | + SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n | head -n1) echo "Smallest OST: $SMALLESTOST" [[ $SMALLESTOST -lt 10240 ]] && @@ -6670,14 +6670,14 @@ compare_stripe_info1() { for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do local size=$((STRIPE_SIZE * num)) local file=file"$num-$offset-$count" - stripe_size=$(lfs getstripe -S $PWD/$file) + stripe_size=$($LFS getstripe -S $PWD/$file) [[ $stripe_size -ne $size ]] && error "$file: size $stripe_size != $size" - stripe_count=$(lfs getstripe -c $PWD/$file) + stripe_count=$($LFS getstripe -c $PWD/$file) # allow fewer stripes to be created, ORI-601 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] && error "$file: count $stripe_count != $count" - stripe_index=$(lfs getstripe -i $PWD/$file) + stripe_index=$($LFS getstripe -i $PWD/$file) [[ $stripe_index -ne 0 ]] && stripe_index_all_zero=false done @@ -9703,7 +9703,7 @@ test_154A() { [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID" # check that we get the same pathname back - local FOUND=$($LFS fid2path $MOUNT $FID) + local FOUND=$($LFS fid2path $MOUNT "$FID") [ -z "$FOUND" ] && error "fid2path unable to get $FID path" [ "$FOUND" != "$DIR/$tfile" ] && error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile" @@ -9785,7 +9785,8 @@ test_154c() { N=$((N + 1)) done - $LFS fid2path $MOUNT $FID1 $FID2 $FID3 | while read PATHNAME; do + $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME; + do [ "$PATHNAME" = "$DIR/$tfile.$N" ] || error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:" N=$((N + 1)) @@ -9809,13 +9810,13 @@ test_154d() { rm -f $DIR/$tfile touch $DIR/$tfile - fid=$($LFS path2fid $DIR/$tfile) + local fid=$($LFS path2fid $DIR/$tfile) # Open the file fd=$(free_fd) cmd="exec $fd<$DIR/$tfile" eval $cmd - fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile) - echo $fid_list | grep $fid + local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile) + echo "$fid_list" | grep "$fid" rc=$? cmd="exec $fd>/dev/null" @@ -11907,7 +11908,7 @@ test_220() { #LU-325 local OSTIDX=0 test_mkdir -p $DIR/$tdir - local OST=$(lfs osts | grep ${OSTIDX}": " | \ + local OST=$($LFS osts | grep ${OSTIDX}": " | \ awk '{print $2}' | sed -e 's/_UUID$//') # on the mdt's osc @@ -12804,11 +12805,11 @@ test_238() { ln $DIR/$tfile $DIR/$tfile.lnk touch $DIR/$tfile.new mv $DIR/$tfile.new $DIR/$tfile - local fid1=$(lfs path2fid $DIR/$tfile) - local fid2=$(lfs path2fid $DIR/$tfile.lnk) - local path1=$(lfs fid2path $FSNAME $fid1) + local fid1=$($LFS path2fid $DIR/$tfile) + local fid2=$($LFS path2fid $DIR/$tfile.lnk) + local path1=$($LFS fid2path $FSNAME "$fid1") [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1" - local path2=$(lfs fid2path $FSNAME $fid2) + local path2=$($LFS fid2path $FSNAME "$fid2") [ $tfile.lnk == $path2 ] || error "linkea inconsistent: $tfile.lnk $fid2 $path2!" rm -f $DIR/$tfile* -- 1.8.3.1