_scratch_mkfs_xfs -d size=$fssize -b size=$blocksize
;;
ext2|ext3|ext4)
- /sbin/mkfs.$FSTYP -b $blocksize $SCRATCH_DEV $blocks
+ /sbin/mkfs.$FSTYP $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
+ ;;
+ btrfs)
+ /sbin/mkfs.$FSTYP $MKFS_OPTIONS $SCRATCH_DEV -b $fssize
;;
*)
_notrun "Filesystem $FSTYP not supported in _scratch_mkfs_sized"
case $FSTYP in
xfs)
- MKFS_OPTIONS="-b size=$blocksize, -d su=$sunit_bytes,sw=$swidth_mult"
+ MKFS_OPTIONS+=" -b size=$blocksize, -d su=$sunit_bytes,sw=$swidth_mult"
;;
ext4)
- MKFS_OPTIONS="-b $blocksize -E stride=$sunit_blocks,stripe_width=$swidth_blocks"
+ MKFS_OPTIONS+=" -b $blocksize -E stride=$sunit_blocks,stripe_width=$swidth_blocks"
;;
*)
_notrun "can't mkfs $FSTYP with geometry"
exit 1
fi
- [ -b $1 ] && src/lstat64 $1 | $AWK_PROG '/Device type:/ { print $9 }'
+ _dev=$1
+ if [ -L "${_dev}" ]; then
+ _dev=`readlink -f ${_dev}`
+ fi
+
+ if [ -b "${_dev}" ]; then
+ src/lstat64 ${_dev} | $AWK_PROG '/Device type:/ { print $9 }'
+ fi
}
# Do a command, log it to $seq.full, optionally test return status
then
_notrun "this test requires a valid \$SCRATCH_DEV"
fi
+ if [ ! -d "$SCRATCH_MNT" ]
+ then
+ _notrun "this test requires a valid \$SCRATCH_MNT"
+ fi
;;
esac
}
# this test requires that a specified command (executable) exists
+# $1 - command, $2 - name for error message
#
_require_command()
{
- [ -x "$1" ] || _notrun "$1 utility required, skipped this test"
+ [ -n "$1" ] && _cmd="$1" || _cmd="$2"
+ [ -n "$1" -a -x "$1" ] || _notrun "$_cmd utility required, skipped this test"
}
# this test requires that external log/realtime devices are not in use
_notrun "External device testing in progress, skipped this test"
}
+# indicate whether YP/NIS is active or not
+#
+_yp_active()
+{
+ local dn
+ dn=$(domainname 2>/dev/null)
+ test -n "${dn}" -a "${dn}" != "(none)"
+ echo $?
+}
+
+# cat the password file
+#
+_cat_passwd()
+{
+ [ $(_yp_active) -eq 0 ] && ypcat passwd
+ cat /etc/passwd
+}
+
+# cat the group file
+#
+_cat_group()
+{
+ [ $(_yp_active) -eq 0 ] && ypcat group
+ cat /etc/group
+}
+
# check for the fsgqa user on the machine
#
_require_user()
{
qa_user=fsgqa
- cat /etc/passwd | grep -q $qa_user
+ _cat_passwd | grep -q $qa_user
[ "$?" == "0" ] || _notrun "$qa_user user not defined."
}
#
_require_xfs_io_falloc()
{
- testio=`$XFS_IO_PROG -F -f -c "falloc 0 1m" $TEST_DIR/$tmp.io 2>&1`
- rm -f $TEST_DIR/$tmp.io 2>&1 > /dev/null
+ testfile=$TEST_DIR/$$.falloc
+ testio=`$XFS_IO_PROG -F -f -c "falloc 0 1m" $testfile 2>&1`
+ rm -f $testfile 2>&1 > /dev/null
echo $testio | grep -q "not found" && \
_notrun "xfs_io fallocate support is missing"
echo $testio | grep -q "Operation not supported" && \
_notrun "xfs_io fallocate command failed (old kernel/wrong fs?)"
}
+# check that xfs_io, kernel and filesystem all support fallocate with hole
+# punching
+_require_xfs_io_falloc_punch()
+{
+ testfile=$TEST_DIR/$$.falloc
+ testio=`$XFS_IO_PROG -F -f -c "pwrite 0 20k" -c "fsync" \
+ -c "fpunch 4k 8k" $testfile 2>&1`
+ rm -f $testfile 2>&1 > /dev/null
+ echo $testio | grep -q "not found" && \
+ _notrun "xfs_io fallocate punch support is missing"
+ echo $testio | grep -q "Operation not supported" && \
+ _notrun "xfs_io fallocate punch command failed (no fs support?)"
+}
+
+# check that xfs_io, kernel and filesystem support fiemap
+_require_xfs_io_fiemap()
+{
+ testfile=$TEST_DIR/$$.fiemap
+ testio=`$XFS_IO_PROG -F -f -c "pwrite 0 20k" -c "fsync" \
+ -c "fiemap -v" $testfile 2>&1`
+ rm -f $testfile 2>&1 > /dev/null
+ echo $testio | grep -q "not found" && \
+ _notrun "xfs_io fiemap support is missing"
+ echo $testio | grep -q "Operation not supported" && \
+ _notrun "xfs_io fiemap command failed (no fs support?)"
+}
+
# Check that a fs has enough free space (in 1024b blocks)
#
_require_fs_space()
_notrun "This test requires at least ${GB}GB free on $MNT to run"
}
+#
+# Check if the filesystem supports sparse files.
+#
+# Unfortunately there is no better way to do this than a manual black list.
+#
+_require_sparse_files()
+{
+ case $FSTYP in
+ hfsplus)
+ _notrun "Sparse files not supported by this filesystem type: $FSTYP"
+ ;;
+ *)
+ ;;
+ esac
+}
+
# check that a FS on a device is mounted
# if so, return mount point
#
ok=$?
fi
- [ $ok -eq 0 ] && exit 1
+ if [ $ok -eq 0 ]; then
+ status=1
+ exit 1
+ fi
+
return 0
}
_mount_or_remount_rw "$extra_mount_options" $device $mountpoint
fi
- [ $ok -eq 0 ] && exit 1
+ if [ $ok -eq 0 ]; then
+ status=1
+ exit 1
+ fi
+
return 0
}