generic/{453,454}: Don't run for FSs restricting names
[xfstests-dev.git] / common / rc
index 2cf550ec680059d797e11ada9fb9aeb09d52f542..d4b1f21f64c1eb0500d94cc6513bc9824ab5dfd9 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -628,7 +628,7 @@ _ext4_metadump()
        test -n "$E2IMAGE_PROG" || _fail "e2image not installed"
        $E2IMAGE_PROG -Q "$device" "$dumpfile"
        [ "$compressopt" = "compress" ] && [ -n "$DUMP_COMPRESSOR" ] &&
-               $DUMP_COMPRESSOR "$dumpfile" &>> "$seqres.full"
+               $DUMP_COMPRESSOR -f "$dumpfile" &>> "$seqres.full"
 }
 
 _test_mkfs()
@@ -1065,6 +1065,9 @@ _scratch_mkfs_sized()
                fi
                export MOUNT_OPTIONS="-o size=$fssize $TMPFS_MOUNT_OPTIONS"
                ;;
+       bcachefs)
+               $MKFS_PROG -t $FSTYP -- $MKFS_OPTIONS --fs_size=$fssize --block_size=$blocksize $SCRATCH_DEV
+               ;;
        *)
                _notrun "Filesystem $FSTYP not supported in _scratch_mkfs_sized"
                ;;
@@ -1113,30 +1116,44 @@ _scratch_mkfs_geom()
 # _scratch_mkfs_blocksized blocksize
 _scratch_mkfs_blocksized()
 {
-    local blocksize=$1
+       local blocksize=$1
 
-    local re='^[0-9]+$'
-    if ! [[ $blocksize =~ $re ]] ; then
-        _notrun "error: _scratch_mkfs_sized: block size \"$blocksize\" not an integer."
-    fi
+       local re='^[0-9]+$'
+       if ! [[ $blocksize =~ $re ]] ; then
+               _notrun "error: _scratch_mkfs_sized: block size \"$blocksize\" not an integer."
+       fi
 
-    case $FSTYP in
-    xfs)
-       _scratch_mkfs_xfs $MKFS_OPTIONS -b size=$blocksize
-       ;;
-    ext2|ext3|ext4)
-       ${MKFS_PROG} -t $FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV
-       ;;
-    gfs2)
-       ${MKFS_PROG} -t $FSTYP $MKFS_OPTIONS -O -b $blocksize $SCRATCH_DEV
-       ;;
-    ocfs2)
-       yes | ${MKFS_PROG} -t $FSTYP -F $MKFS_OPTIONS -b $blocksize -C $blocksize $SCRATCH_DEV
-       ;;
-    *)
-       _notrun "Filesystem $FSTYP not supported in _scratch_mkfs_blocksized"
-       ;;
-    esac
+       case $FSTYP in
+       btrfs)
+               test -f /sys/fs/btrfs/features/supported_sectorsizes || \
+               _notrun "Subpage sectorsize support is not found in $FSTYP"
+
+               grep -wq $blocksize /sys/fs/btrfs/features/supported_sectorsizes || \
+               _notrun "$FSTYP does not support sectorsize=$blocksize yet"
+
+               _scratch_mkfs --sectorsize=$blocksize
+               ;;
+       xfs)
+               _scratch_mkfs_xfs $MKFS_OPTIONS -b size=$blocksize
+               ;;
+       ext2|ext3|ext4)
+               ${MKFS_PROG} -t $FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV
+               ;;
+       gfs2)
+               ${MKFS_PROG} -t $FSTYP $MKFS_OPTIONS -O -b $blocksize $SCRATCH_DEV
+               ;;
+       ocfs2)
+               yes | ${MKFS_PROG} -t $FSTYP -F $MKFS_OPTIONS -b $blocksize \
+                                               -C $blocksize $SCRATCH_DEV
+               ;;
+       bcachefs)
+               ${MKFS_PROG} -t $FSTYP $MKFS_OPTIONS --block_size=$blocksize \
+                                                               $SCRATCH_DEV
+               ;;
+       *)
+               _notrun "Filesystem $FSTYP not supported in _scratch_mkfs_blocksized"
+               ;;
+       esac
 }
 
 _scratch_resvblks()
@@ -1179,6 +1196,11 @@ _repair_scratch_fs()
        fi
        return $res
         ;;
+    bcachefs)
+       # With bcachefs, if fsck detects any errors we consider it a bug and we
+       # want the test to fail:
+       _check_scratch_fs
+       ;;
     *)
        local dev=$SCRATCH_DEV
        local fstyp=$FSTYP
@@ -1931,6 +1953,50 @@ _require_dm_target()
        fi
 }
 
+_zone_type()
+{
+       local target=$1
+       if [ -z $target ]; then
+               echo "Usage: _zone_type <device>"
+               exit 1
+       fi
+       local sdev=`_short_dev $target`
+
+       if [ -e /sys/block/${sdev}/queue/zoned ]; then
+               cat /sys/block/${sdev}/queue/zoned
+       else
+               echo none
+       fi
+}
+
+_require_zoned_device()
+{
+       local target=$1
+       if [ -z $target ]; then
+               echo "Usage: _require_zoned_device <device>"
+               exit 1
+       fi
+
+       local type=`_zone_type ${target}`
+       if [ "${type}" = "none" ]; then
+               _notrun "this test require zoned block device"
+       fi
+}
+
+_require_non_zoned_device()
+{
+       local target=$1
+       if [ -z $target ]; then
+               echo "Usage: _require_non_zoned_device <device>"
+               exit 1
+       fi
+
+       local type=`_zone_type ${target}`
+       if [ "${type}" != "none" ]; then
+               _notrun "this test require non-zoned block device"
+       fi
+}
+
 # this test requires the ext4 kernel support crc feature on scratch device
 #
 _require_scratch_ext4_crc()
@@ -2490,13 +2556,18 @@ _require_scratch_swapfile()
        # Minimum size for mkswap is 10 pages
        _format_swapfile "$SCRATCH_MNT/swap" $(($(get_page_size) * 10))
 
-       # ext* and xfs have supported all variants of swap files since their
+       # ext* has supported all variants of swap files since their
        # introduction, so swapon should not fail.
        case "$FSTYP" in
-       ext2|ext3|ext4|xfs)
+       ext2|ext3|ext4)
                if ! swapon "$SCRATCH_MNT/swap" >/dev/null 2>&1; then
-                       _scratch_unmount
-                       _fail "swapon failed for $FSTYP"
+                       if _check_s_dax "$SCRATCH_MNT/swap" 1 >/dev/null; then
+                               _scratch_unmount
+                               _notrun "swapfiles are not supported"
+                       else
+                               _scratch_unmount
+                               _fail "swapon failed for $FSTYP"
+                       fi
                fi
                ;;
        *)
@@ -3360,6 +3431,7 @@ _check_s_dax()
 {
        local target=$1
        local exp_s_dax=$2
+       local ret=0
 
        local attributes=$($XFS_IO_PROG -c 'statx -r' $target | awk '/stat.attributes / { print $3 }')
 
@@ -3380,10 +3452,17 @@ _check_s_dax()
        fi
 
        if [ $exp_s_dax -eq 0 ]; then
-               (( attributes & 0x00200000 )) && echo "$target has unexpected S_DAX flag"
+               if (( attributes & 0x00200000 )); then
+                       echo "$target has unexpected S_DAX flag"
+                       ret=1
+               fi
        else
-               (( attributes & 0x00200000 )) || echo "$target doesn't have expected S_DAX flag"
+               if ! (( attributes & 0x00200000 )); then
+                       echo "$target doesn't have expected S_DAX flag"
+                       ret=2
+               fi
        fi
+       return $ret
 }
 
 _check_xflag()
@@ -3475,7 +3554,7 @@ _has_metadata_journaling()
        fi
 
        case "$FSTYP" in
-       ext2|vfat|msdos|udf|exfat)
+       ext2|vfat|msdos|udf|exfat|tmpfs)
                echo "$FSTYP does not support metadata journaling"
                return 1
                ;;
@@ -4174,7 +4253,8 @@ _get_block_size()
 }
 
 # Require that the fundamental allocation unit of a file is the same as the
-# filesystem block size.
+# filesystem block size.  The sole parameter must be the root dir of a
+# filesystem.
 _require_file_block_size_equals_fs_block_size()
 {
        local file_alloc_unit="$(_get_file_block_size $1)"
@@ -4513,6 +4593,25 @@ _getcap()
        return ${PIPESTATUS[0]}
 }
 
+_require_od_endian_flag()
+{
+       od --endian=little < /dev/null > /dev/null 2>&1 || \
+               _notrun "od does not support endian flag"
+}
+
+# Skip this test unless the filesystem treats names (directory entries,
+# fs labels, and extended attribute names) as raw byte sequences.
+_require_names_are_bytes() {
+        case "$FSTYP" in
+        ext2|ext3|ext4|f2fs|xfs|btrfs)
+               # do nothing
+               ;;
+       *)
+                _notrun "$FSTYP does not allow unrestricted byte streams for names"
+               ;;
+        esac
+}
+
 init_rc
 
 ################################################################################