BC=$(which bc 2> /dev/null) || BC=
-# Some tests are not relevant or functional when testing XFS realtime
-# subvolumes along with the rtinherit=1 mkfs option. In these cases,
-# this test will opt-out of the test.
-_require_no_rtinherit()
-{
- [ "$FSTYP" = "xfs" ] && echo "$MKFS_OPTIONS" |
- egrep -q "rtinherit([^=]|=1|$)" && \
- _notrun "rtinherit mkfs option is not supported by this test."
-}
-
_require_math()
{
if [ -z "$BC" ]; then
local params="$*"
local last_index=$(( $# - 1 ))
- #get mount point to handle dmapi mtpt option correctly
[ $last_index -gt 0 ] && shift $last_index
local fs_escaped=$1
- echo $params | sed -e 's/dmapi/dmi/' \
- | $PERL_PROG -ne "s#mtpt=[^,|^\n|^\s]*#mtpt=$fs_escaped\1\2#; print;"
+ echo $params | \
+ $PERL_PROG -ne "s#mtpt=[^,|^\n|^\s]*#mtpt=$fs_escaped\1\2#; print;"
}
_try_scratch_mount $* || _fail "mount failed"
}
+_scratch_mount_idmapped()
+{
+ local type="$1"
+ local id="$2"
+
+ if [ "$type" = "u" ]; then
+ # This means root will be able to create files as uid %id in
+ # the underlying filesystem by going through the idmapped mount.
+ $here/src/idmapped-mounts/mount-idmapped --map-mount u:0:$id:1 \
+ --map-mount u:$id:0:1 \
+ --map-mount g:0:0:1 \
+ "$SCRATCH_MNT" "$SCRATCH_MNT" || _fail "mount-idmapped failed"
+ elif [ "$type" = "g" ]; then
+ # This means root will be able to create files as gid %id in
+ # the underlying filesystem by going through the idmapped mount.
+ $here/src/idmapped-mounts/mount-idmapped --map-mount g:0:$id:1 \
+ --map-mount g:$id:0:1 \
+ --map-mount u:0:0:1 \
+ "$SCRATCH_MNT" "$SCRATCH_MNT" || _fail "mount-idmapped failed"
+ elif [ "$type" = "b" ]; then
+ # This means root will be able to create files as uid and gid
+ # %id in the underlying filesystem by going through the idmapped mount.
+ $here/src/idmapped-mounts/mount-idmapped --map-mount b:0:$id:1 \
+ --map-mount b:$id:0:1 \
+ "$SCRATCH_MNT" "$SCRATCH_MNT" || _fail "mount-idmapped failed"
+ else
+ _fail "usage: either \"u\" (uid), \"g\" (gid), or \"b\" (uid and gid) must be specified "
+ fi
+}
+
_scratch_unmount()
{
case "$FSTYP" in
esac
}
+_scratch_umount_idmapped()
+{
+ $UMOUNT_PROG $SCRATCH_MNT
+}
+
_scratch_remount()
{
local opts="$1"
return $mkfs_status
}
-_scratch_metadump()
-{
- local dumpfile=$1
- shift
- local options=
-
- [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
- options="-l $SCRATCH_LOGDEV"
-
- xfs_metadump $options "$@" $SCRATCH_DEV $dumpfile
-}
-
_setup_large_ext4_fs()
{
local fs_size=$1
return $mkfs_status
}
+_ext4_metadump()
+{
+ local device="$1"
+ local dumpfile="$2"
+ local compressopt="$3"
+
+ test -n "$E2IMAGE_PROG" || _fail "e2image not installed"
+ $E2IMAGE_PROG -Q "$device" "$dumpfile"
+ [ "$compressopt" = "compress" ] && [ -n "$DUMP_COMPRESSOR" ] &&
+ $DUMP_COMPRESSOR "$dumpfile" &>> "$seqres.full"
+}
+
_test_mkfs()
{
case $FSTYP in
tmpfs)
if [ -z "$SCRATCH_DEV" -o ! -d "$SCRATCH_MNT" ];
then
- _notrun "this test requires a valid \$SCRATCH_MNT and unique $SCRATCH_DEV"
+ _notrun "this test requires a valid \$SCRATCH_MNT and unique \$SCRATCH_DEV"
fi
;;
ubifs)
[ $devsize -lt $1 ] && _notrun "scratch dev too small"
}
-# require scratch fs which supports >16T of filesystem size.
+# Require scratch fs which supports >16T of filesystem size.
+# _require_scratch must be called before this function is called.
_require_scratch_16T_support()
{
case $FSTYP in
fi
}
-# this test requires ext2 filesystem support
-#
-_require_ext2()
-{
- modprobe ext2 >/dev/null 2>&1
- if grep ext2 /proc/filesystems >/dev/null 2>&1
- then
- :
- else
- _notrun "This test requires ext2 filesystem support"
- fi
-}
-
-# this test requires tmpfs filesystem support
+# this test requires kernel support for a secondary filesystem
#
-_require_tmpfs()
+_require_extra_fs()
{
- modprobe tmpfs >/dev/null 2>&1
- grep -q tmpfs /proc/filesystems ||
- _notrun "this test requires tmpfs support"
+ modprobe "$1" >/dev/null 2>&1
+ grep -q -w "$1" /proc/filesystems ||
+ _notrun "this test requires $1 support"
}
# this test requires that (large) loopback device files are not in use
_require_sane_bdev_flush $SCRATCH_DEV
_require_command "$DMSETUP_PROG" dmsetup
- _normalize_mount_options | egrep -q "dax(=always| |$)"
+ _normalize_mount_options | egrep -q "dax(=always| |$)" || \
+ test -e "/sys/block/$(_short_dev $SCRATCH_DEV)/dax"
if [ $? -eq 0 ]; then
case $target in
stripe|linear|log-writes)
esac
}
+# test whether the mount_setattr syscall is available
+_require_mount_setattr()
+{
+ $here/src/feature -r
+ case $? in
+ 0)
+ ;;
+ 1)
+ _notrun "kernel does not support mount_setattr syscall"
+ ;;
+ *)
+ _fail "unexpected error testing for mount_setattr support"
+ ;;
+ esac
+}
+
+# test whether idmapped mounts are supported
+_require_idmapped_mounts()
+{
+ IDMAPPED_MOUNTS_TEST=$here/src/idmapped-mounts/idmapped-mounts
+ [ -x $IDMAPPED_MOUNTS_TEST ] || _notrun "idmapped-mounts utilities required"
+
+ _require_mount_setattr
+
+ $here/src/idmapped-mounts/idmapped-mounts --supported \
+ --device "$TEST_DEV" \
+ --mount "$TEST_DIR" \
+ --fstype "$FSTYP"
+
+ if [ $? -ne 0 ]; then
+ _notrun "idmapped-mounts not support by $FSTYP"
+ fi
+}
+
# this test requires that a test program exists under src/
# $1 - command (require)
#
[ "$?" == "0" ] || _notrun "$qa_user cannot execute commands."
}
+# check for a chown support
+#
+_require_chown()
+{
+ local rnd_uid=4242
+ local file="$TEST_DIR/chown_testfile"
+
+ rm -f $file
+ touch $file
+ chown ${rnd_uid}:${rnd_uid} $file >/dev/null 2>&1 \
+ || _notrun "chown is not supported ${FSTYP}"
+}
+
+
+# check for a chmod support
+# Since chmod sometimes fails silently actual functionality test is done
+#
+_require_chmod()
+{
+ local file="$TEST_DIR/chmod_testfile"
+
+ rm -f $file
+ touch $file
+
+ # get original file mode
+ local mode=`stat --format="0%a" $file`
+ # flip the user's read bit
+ let mode^=0400
+ chmod `printf '%o' "$mode"` $file
+ # check that the chmod actually flipped the bit
+ [ `stat --format="0%a" $file` == `printf '0%o' "$mode"` ] \
+ || _notrun "chmod is not supported ${FSTYP}"
+}
+
# check for a group on the machine, fsgqa as default
#
_require_group()
# Swap files must be nocow on Btrfs.
$CHATTR_PROG +C "$fname" > /dev/null 2>&1
_pwrite_byte 0x61 0 "$sz" "$fname" >> $seqres.full
- $MKSWAP_PROG "$fname" >> $seqres.full
+ # Ignore permission complaints on filesystems that don't support perms
+ $MKSWAP_PROG "$fname" 2> >(grep -v 'insecure permission' >&2) >> $seqres.full
+}
+
+_swapon_file() {
+ local fname="$1"
+
+ # Ignore permission complaints on filesystems that don't support perms
+ swapon "$fname" 2> >(grep -v "insecure permissions" >&2)
}
# Check that the filesystem supports swapfiles
fi
rm -f $tmp.fsck
+ if [ $ok -eq 0 ] && [ -n "$DUMP_CORRUPT_FS" ]; then
+ case "$FSTYP" in
+ ext*)
+ local flatdev="$(basename "$device")"
+ _ext4_metadump "$seqres.$flatdev.check.qcow2" "$device" compress
+ ;;
+ esac
+ fi
+
if [ $ok -eq 0 ]
then
echo "*** mount output ***" >>$seqres.full
{
_exclude_scratch_mount_option "noatime"
case $FSTYP in
- nfs|cifs)
+ nfs|cifs|virtiofs)
_notrun "atime related mount options have no effect on $FSTYP"
;;
esac
# return device size in kb
_get_device_size()
{
- grep -w `_short_dev $1` /proc/partitions | awk '{print $3}'
+ echo $(($(blockdev --getsz $1) >> 1))
}
# Make sure we actually have dmesg checking set up.
stat -f -c %S $1
}
+# Require that the fundamental allocation unit of a file is the same as the
+# filesystem block size.
+_require_file_block_size_equals_fs_block_size()
+{
+ local file_alloc_unit="$(_get_file_block_size $1)"
+ local fs_block_size="$(_get_block_size $1)"
+ test "$file_alloc_unit" != "$fs_block_size" && \
+ _notrun "File allocation unit is larger than a filesystem block"
+}
+
get_page_size()
{
echo $(getconf PAGE_SIZE)