]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
common: Enhance the scratch dev pool and deletable device check
authorMiao Xie <miaox@cn.fujitsu.com>
Mon, 20 Jan 2014 01:52:21 +0000 (12:52 +1100)
committerDave Chinner <david@fromorbit.com>
Mon, 20 Jan 2014 01:52:21 +0000 (12:52 +1100)
_require_scratch_dev_pool() checks the devices number in
SCRATCH_DEV_POOL, but it's not enough since some btrfs RAID10 tests
needs 4 devices, but when 3 or less devices are provided, the check is
useless and related test case will fail(btrfs/003 btrfs/011 btrfs/023).

Also _require_deletable_scratch_dev_pool only checks whether it is
virtul, like virtio(not including virtio-scsi) disk will pass the check
but is unable to delete.

This patch enhance _require_scratch_dev_pool by add optional $1 as
needed device number to do extra check.
And enhance _require_deletable_scratch_dev_pool by directly check
/sys/class/block/$DEV/device/delete file.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
common/rc
tests/btrfs/003
tests/btrfs/011

index 70b49922a80872ed8d0c7eec4b0ec80f5b170585..a8c93e1bafec5555afca60010a97a81922172ec9 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -1947,16 +1947,24 @@ _test_inode_extsz()
 _require_scratch_dev_pool()
 {
        local i
+       local ndevs
+
        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
+       if [ -z "$1" ]; then
+               ndevs=2
+       else
+               ndevs=$1
+       fi
+
+       # btrfs test case needs ndevs or more 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"
+               if [ "`echo $SCRATCH_DEV_POOL|wc -w`" -lt $ndevs ]; then
+                       _notrun "btrfs and this test needs $ndevs or more disks in SCRATCH_DEV_POOL"
                fi
        ;;
        *)
@@ -1983,17 +1991,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
 }
index 9105d064ab7eaebc1c12621f01a7911dc9eeebe1..29f947b631cd66a9aa92b75e7d5b7e7fab3d43be 100755 (executable)
@@ -49,7 +49,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
 _require_command $WIPEFS_PROG
 
index 71ff3deb96dfa60998c6d355403b632c8ce71264..faa0402d4cb78f0a38ded8dc6fdf51cd51b0c818 100755 (executable)
@@ -62,7 +62,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 _need_to_be_root
 _supported_fs btrfs
 _require_scratch
-_require_scratch_dev_pool
+_require_scratch_dev_pool 4
 _require_command $BTRFS_SHOW_SUPER_PROG btrfs-show-super
 
 rm -f $seqres.full