common: support black listing fs in _supported_fs()
authorAmir Goldstein <amir73il@gmail.com>
Tue, 19 Apr 2022 12:56:36 +0000 (15:56 +0300)
committerZorro Lang <zlang@kernel.org>
Mon, 2 May 2022 04:11:54 +0000 (12:11 +0800)
For example:
_supported_fs ^xfs

There is no need to specify "generic" when using a block list
"all other fs are supported" is implied.

Converted some generic tests that open code this condition without
emitting a meaningful reason.

More generic test like generic/186,187 could use a block list, but
were not converted because they emit some meaningful reason:
  _notrun "Can't fragment free space on btrfs."

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/rc
tests/generic/500
tests/generic/631
tests/generic/679

index a8252c7f6eedb070ef12afa52f7555eca178fd4a..eda5fcff34a0c2986a1b988a51e695c2332db4ee 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -1585,19 +1585,29 @@ _fail()
 
 # tests whether $FSTYP is one of the supported filesystems for a test
 #
 
 # tests whether $FSTYP is one of the supported filesystems for a test
 #
-_supported_fs()
+_check_supported_fs()
 {
 {
-    local f
+       local res=1
+       local f
 
 
-    for f
-    do
-       if [ "$f" = "$FSTYP" -o "$f" = "generic" ]
-       then
-           return
-       fi
-    done
+       for f; do
+               # ^FS means black listed fs
+               if [ "$f" = "^$FSTYP" ]; then
+                       return 1
+               elif [ "$f" = "generic" ] || [[ "$f" == "^"* ]]; then
+                       # ^FS implies "generic ^FS"
+                       res=0
+               elif [ "$f" = "$FSTYP" ]; then
+                       return 0
+               fi
+       done
+       return $res
+}
 
 
-    _notrun "not suitable for this filesystem type: $FSTYP"
+_supported_fs()
+{
+       _check_supported_fs $* || \
+               _notrun "not suitable for this filesystem type: $FSTYP"
 }
 
 _check_if_dev_already_mounted()
 }
 
 _check_if_dev_already_mounted()
index 0be599349fbaaa6d6fc1e9990ba2a2c65fca7d93..bc84d219fa66d12be43f3bf4f33d0f20d038f64f 100755 (executable)
@@ -35,7 +35,6 @@ _cleanup()
 . ./common/dmthin
 
 # real QA test starts here
 . ./common/dmthin
 
 # real QA test starts here
-_supported_fs generic
 _require_scratch_nocheck
 _require_dm_target thin-pool
 
 _require_scratch_nocheck
 _require_dm_target thin-pool
 
@@ -43,7 +42,7 @@ _require_dm_target thin-pool
 # and since we've filled the thinp device it'll return EIO, which will make
 # btrfs flip read only, making it fail this test when it just won't work right
 # for us in the first place.
 # and since we've filled the thinp device it'll return EIO, which will make
 # btrfs flip read only, making it fail this test when it just won't work right
 # for us in the first place.
-test $FSTYP == "btrfs"  && _notrun "btrfs doesn't work that way lol"
+_supported_fs ^btrfs
 
 # Require underlying device support discard
 _scratch_mkfs >>$seqres.full 2>&1
 
 # Require underlying device support discard
 _scratch_mkfs >>$seqres.full 2>&1
index 4996bce70550eb3315c8a85f8749fe86872fd00e..219f7a05e7fc4ba0fd66c949aa9bd90c53a266ac 100755 (executable)
@@ -36,10 +36,9 @@ _cleanup()
 . ./common/attr
 
 # real QA test starts here
 . ./common/attr
 
 # real QA test starts here
-_supported_fs generic
 _require_scratch
 _require_attrs trusted
 _require_scratch
 _require_attrs trusted
-test "$FSTYP" = "overlay" && _notrun "Test does not apply to overlayfs."
+_supported_fs ^overlay
 _require_extra_fs overlay
 
 _scratch_mkfs >> $seqres.full
 _require_extra_fs overlay
 
 _scratch_mkfs >> $seqres.full
index 440f0c081c6ff216729e7a8629e7d8f3972787d6..c32d42b95463a745e3e4984385393fd463729f08 100755 (executable)
@@ -17,7 +17,6 @@ _begin_fstest auto quick prealloc
 
 # real QA test starts here
 
 
 # real QA test starts here
 
-_supported_fs generic
 _require_scratch
 _require_xfs_io_command "falloc"
 _require_xfs_io_command "fiemap"
 _require_scratch
 _require_xfs_io_command "falloc"
 _require_xfs_io_command "fiemap"
@@ -26,7 +25,7 @@ _require_xfs_io_command "fiemap"
 #
 #   https://lore.kernel.org/linux-btrfs/20220315164011.GF8241@magnolia/
 #
 #
 #   https://lore.kernel.org/linux-btrfs/20220315164011.GF8241@magnolia/
 #
-[ $FSTYP == "xfs" ] && _notrun "test not valid for xfs"
+_supported_fs ^xfs
 
 rm -f $seqres.full
 
 
 rm -f $seqres.full