From: Xiong Zhou Date: Mon, 2 Nov 2015 00:00:51 +0000 (+1100) Subject: generic/312: fix dev_blocks calculation X-Git-Tag: v2022.05.01~2763 X-Git-Url: http://git.apps.os.sepia.ceph.com/?p=xfstests-dev.git;a=commitdiff_plain;h=8deb635098404f31af009d7cf1b12cdce15c6ab2 generic/312: fix dev_blocks calculation Current calculation fails when there are many same type of devices with the testing device, eg sda1 sda2 ... sda10, sda11, sda12 .. $(grep sda1 /proc/partitions) gets multiple numbers. $ grep ram1 /proc/partitions 1 1 10485760 ram1 1 10 10485760 ram10 1 11 10485760 ram11 1 12 10485760 ram12 1 13 10485760 ram13 1 14 10485760 ram14 1 15 10485760 ram15 $ grep -w ram1 /proc/partitions 1 1 10485760 ram1 Fix this by adding the -w option to grep to match the block device exactly. Signed-off-by: Xiong Zhou Reviewed-by: Eryu Guan Signed-off-by: Dave Chinner --- diff --git a/tests/generic/312 b/tests/generic/312 index b0359786..b5708143 100755 --- a/tests/generic/312 +++ b/tests/generic/312 @@ -52,7 +52,7 @@ _require_scratch # 5G in byte fssize=$((2**30 * 5)) required_blocks=$(($fssize / 1024)) -dev_blocks=$(grep $(_short_dev $SCRATCH_DEV) /proc/partitions | $AWK_PROG '{print $3}') +dev_blocks=$(grep -w $(_short_dev $SCRATCH_DEV) /proc/partitions | $AWK_PROG '{print $3}') if [ $required_blocks -gt $dev_blocks ];then _notrun "this test requires \$SCRATCH_DEV has ${fssize}B space" fi