diff mbox

[V2,3/3] xfstests: fix wrong number of the required devices and wrong deletable device check method for case 265

Message ID 50373668.3000804@cn.fujitsu.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Miao Xie Aug. 24, 2012, 8:08 a.m. UTC
Case 265 need 4 devices to test RAID10, so we need 4 or more devices not 2.
And the deletable device check method is also wrong, the virtual devices in
the VMs which are drived by virtio are also not deletable(no delete entry
point), but it is not managed in the virtual directory in sysfs, so the current
method will make a mistake and thinks they are deletable. Fix it by check
the delete entry point. This fix method can also avoid the users use
partitions to run case 265.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
---
Changelog v1 -> v2:
- drop the independent device check
- modify the deletable device check
- do not modify README
---
 265       |    2 +-
 common.rc |   18 ++++++++++--------
 2 files changed, 11 insertions(+), 9 deletions(-)
diff mbox

Patch

diff --git a/265 b/265
index ec8410c..0687b62 100755
--- a/265
+++ b/265
@@ -50,7 +50,7 @@  _need_to_be_root
 _supported_fs btrfs
 _supported_os Linux
 _require_scratch
-_require_scratch_dev_pool
+_require_scratch_dev_pool 4
 _require_deletable_scratch_dev_pool
 
 # Test cases related to raid in btrfs
diff --git a/common.rc b/common.rc
index 602513a..a254e0e 100644
--- a/common.rc
+++ b/common.rc
@@ -1695,16 +1695,20 @@  _test_inode_extsz()
 _require_scratch_dev_pool()
 {
 	local i
+	local ndevs=$1
 	if [ -z "$SCRATCH_DEV_POOL" ]; then
 		_notrun "this test requires a valid \$SCRATCH_DEV_POOL"
 	fi
 
-	# btrfs test case needs 2 or more scratch_dev_pool; other FS not sure
+	# btrfs test case needs scratch_dev_pool; other FS not sure
 	# so fail it
 	case $FSTYP in
 	btrfs)
-		if [ "`echo $SCRATCH_DEV_POOL|wc -w`" -lt 2 ]; then
-			_notrun "btrfs and this test needs 2 or more disks in SCRATCH_DEV_POOL"
+		# We have moved a device from SCRATCH_DEV_POOL tp SCRATCH_DEV,
+		# so we must make it into account.
+		if [ $((`echo $SCRATCH_DEV_POOL | wc -w` + 1)) -lt $ndevs ]
+		then
+			_notrun "btrfs and this test needs $ndevs or more disks in SCRATCH_DEV_POOL"
 		fi
 	;;
 	*)
@@ -1731,17 +1735,15 @@  _require_scratch_dev_pool()
 	done
 }
 
-# We will check if the device is virtual (eg: loop device) since it does not
-# have the delete entry-point. Otherwise SCSI and USB devices are fine. 
+# We will check if the device is deletable. 
 _require_deletable_scratch_dev_pool()
 {
 	local i
 	local x
 	for i in $SCRATCH_DEV_POOL; do
 		x=`echo $i | cut -d"/" -f 3`
-		ls -l /sys/class/block/${x} | grep -q "virtual" 
-		if [ $? == "0" ]; then
-			_notrun "$i is a virtual device which is not deletable"
+		if [ ! -f /sys/class/block/${x}/device/delete ]; then
+			_notrun "$i is a device which is not deletable"
 		fi
 	done
 }