##/bin/bash
-#
+# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2000-2003,2006 Silicon Graphics, Inc. All Rights Reserved.
#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it would be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#
-#
# setup and check for config parameters, and in particular
#
# EMAIL - email of the script runner.
# RMT_IRIXTAPE_DEV- the IRIX remote tape device for the xfsdump tests
# RMT_TAPE_USER - remote user for tape device
# SELINUX_MOUNT_OPTIONS - Options to use when SELinux is enabled.
+# KEEP_DMESG - whether to keep all dmesg for each test case.
+# yes: keep all dmesg
+# no: only keep dmesg with error/warning (default)
#
# - These can be added to $HOST_CONFIG_DIR (witch default to ./config)
# below or a separate local configuration file can be used (using
PATH=".:$PATH"
export HOST=`hostname -s`
-export HOSTOS=`uname -s`
+test `uname -s` = "Linux" || _fatal "fstests only supports Linux"
export MODULAR=0 # using XFS as a module or not
export BOOT="/boot" # install target for kernels
export HOST_OPTIONS=${HOST_OPTIONS:=local.config}
export CHECK_OPTIONS=${CHECK_OPTIONS:="-g auto"}
export BENCH_PASSES=${BENCH_PASSES:=5}
-export XFS_MKFS_OPTIONS=${XFS_MKFS_OPTIONS:=-bsize=4096}
export TIME_FACTOR=${TIME_FACTOR:=1}
export LOAD_FACTOR=${LOAD_FACTOR:=1}
export DEBUGFS_MNT=${DEBUGFS_MNT:="/sys/kernel/debug"}
export OVL_WORK="ovl-work"
# overlay mount point parent must be the base fs root
export OVL_MNT="ovl-mnt"
+# By default unionmount-testsuite is expected under src
+export UNIONMOUNT_TESTSUITE=${UNIONMOUNT_TESTSUITE:=$here/src/unionmount-testsuite}
+
+# From e2fsprogs/e2fsck/e2fsck.h:
+# Exit code used by fsck-type programs
+export FSCK_OK=0
+export FSCK_NONDESTRUCT=1
+export FSCK_REBOOT=2
+export FSCK_UNCORRECTED=4
+export FSCK_ERROR=8
+export FSCK_USAGE=16
+export FSCK_CANCELED=32
+export FSCK_LIBRARY=128
export PWD=`pwd`
#export DEBUG=${DEBUG:=...} # arbitrary CFLAGS really.
export DF_PROG="$(type -P df)"
[ "$DF_PROG" = "" ] && _fatal "df not found"
-[ "$HOSTOS" = "Linux" ] && export DF_PROG="$DF_PROG -T -P"
+export DF_PROG="$DF_PROG -T -P" # Linux
export XFS_IO_PROG="$(type -P xfs_io)"
[ "$XFS_IO_PROG" = "" ] && _fatal "xfs_io not found"
+export MKSWAP_PROG="$(type -P mkswap)"
+# mkswap from util-linux v2.17.2 or older needs "-f" option to force to erase
+# bootbits sectors
+MKSWAP_PROG="$MKSWAP_PROG -f"
+
export XFS_LOGPRINT_PROG="$(type -P xfs_logprint)"
export XFS_REPAIR_PROG="$(type -P xfs_repair)"
export XFS_DB_PROG="$(type -P xfs_db)"
+export XFS_METADUMP_PROG="$(type -P xfs_metadump)"
+export XFS_ADMIN_PROG="$(type -P xfs_admin)"
export XFS_GROWFS_PROG=$(type -P xfs_growfs)
export XFS_SPACEMAN_PROG="$(type -P xfs_spaceman)"
export XFS_SCRUB_PROG="$(type -P xfs_scrub)"
export FSTRIM_PROG="$(type -P fstrim)"
export DUMPE2FS_PROG="$(type -P dumpe2fs)"
export RESIZE2FS_PROG="$(type -P resize2fs)"
+export F2FS_IO_PROG="$(type -P f2fs_io)"
export FIO_PROG="$(type -P fio)"
export FILEFRAG_PROG="$(type -P filefrag)"
export E4DEFRAG_PROG="$(type -P e4defrag)"
export DBENCH_PROG="$(type -P dbench)"
export DMSETUP_PROG="$(type -P dmsetup)"
export WIPEFS_PROG="$(type -P wipefs)"
+export BLKDISCARD_PROG="$(type -P blkdiscard)"
export DUMP_PROG="$(type -P dump)"
export RESTORE_PROG="$(type -P restore)"
export LVM_PROG="$(type -P lvm)"
+export LSATTR_PROG="$(type -P lsattr)"
export CHATTR_PROG="$(type -P chattr)"
export DEBUGFS_PROG="$(type -P debugfs)"
export UUIDGEN_PROG="$(type -P uuidgen)"
export SETRICHACL_PROG="$(type -P setrichacl)"
export KEYCTL_PROG="$(type -P keyctl)"
export XZ_PROG="$(type -P xz)"
+export LZ4_PROG="$(type -P lz4)"
export FLOCK_PROG="$(type -P flock)"
export LDD_PROG="$(type -P ldd)"
export TIMEOUT_PROG="$(type -P timeout)"
export TIMEOUT_PROG="$(type -P timeout)"
export SETCAP_PROG="$(type -P setcap)"
export GETCAP_PROG="$(type -P getcap)"
+export CAPSH_PROG="$(type -P capsh)"
export CHECKBASHISMS_PROG="$(type -P checkbashisms)"
+export XFS_INFO_PROG="$(type -P xfs_info)"
+export DUPEREMOVE_PROG="$(type -P duperemove)"
+export CC_PROG="$(type -P cc)"
+export FSVERITY_PROG="$(type -P fsverity)"
+export OPENSSL_PROG="$(type -P openssl)"
+export ACCTON_PROG="$(type -P accton)"
+export E2IMAGE_PROG="$(type -P e2image)"
+export BLKZONE_PROG="$(type -P blkzone)"
# use 'udevadm settle' or 'udevsettle' to wait for lv to be settled.
# newer systems have udevadm command but older systems like RHEL5 don't.
fi
export UDEV_SETTLE_PROG
-case "$HOSTOS" in
- Linux)
- export MKFS_XFS_PROG=$(type -P mkfs.xfs)
- export MKFS_EXT4_PROG=$(type -P mkfs.ext4)
- export MKFS_UDF_PROG=$(type -P mkudffs)
- export MKFS_BTRFS_PROG=$(set_mkfs_prog_path_with_opts btrfs)
- export MKFS_F2FS_PROG=$(set_mkfs_prog_path_with_opts f2fs)
- export DUMP_F2FS_PROG=$(type -P dump.f2fs)
- export BTRFS_UTIL_PROG=$(type -P btrfs)
- export BTRFS_SHOW_SUPER_PROG=$(type -P btrfs-show-super)
- export BTRFS_CONVERT_PROG=$(type -P btrfs-convert)
- export BTRFS_DEBUG_TREE_PROG=$(type -P btrfs-debug-tree)
- export XFS_FSR_PROG=$(type -P xfs_fsr)
- export MKFS_NFS_PROG="false"
- export MKFS_CIFS_PROG="false"
- export MKFS_OVERLAY_PROG="false"
- export MKFS_REISER4_PROG=$(type -P mkfs.reiser4)
- export E2FSCK_PROG=$(type -P e2fsck)
- export TUNE2FS_PROG=$(type -P tune2fs)
- export FSCK_OVERLAY_PROG=$(type -P fsck.overlay)
- ;;
-esac
+export MKFS_XFS_PROG=$(type -P mkfs.xfs)
+export MKFS_EXT4_PROG=$(type -P mkfs.ext4)
+export MKFS_UDF_PROG=$(type -P mkudffs)
+export MKFS_BTRFS_PROG=$(set_mkfs_prog_path_with_opts btrfs)
+export MKFS_F2FS_PROG=$(set_mkfs_prog_path_with_opts f2fs)
+export DUMP_F2FS_PROG=$(type -P dump.f2fs)
+export F2FS_IO_PROG=$(type -P f2fs_io)
+export BTRFS_UTIL_PROG=$(type -P btrfs)
+export BTRFS_SHOW_SUPER_PROG=$(type -P btrfs-show-super)
+export BTRFS_CONVERT_PROG=$(type -P btrfs-convert)
+export BTRFS_TUNE_PROG=$(type -P btrfstune)
+export XFS_FSR_PROG=$(type -P xfs_fsr)
+export MKFS_NFS_PROG="false"
+export MKFS_CIFS_PROG="false"
+export MKFS_OVERLAY_PROG="false"
+export MKFS_REISER4_PROG=$(type -P mkfs.reiser4)
+export E2FSCK_PROG=$(type -P e2fsck)
+export TUNE2FS_PROG=$(type -P tune2fs)
+export FSCK_OVERLAY_PROG=$(type -P fsck.overlay)
# SELinux adds extra xattrs which can mess up our expected output.
# So, mount with a context, and they won't be created.
fi
# check if mkfs.xfs supports v5 xfs
-XFS_MKFS_HAS_NO_META_SUPPORT=""
-touch /tmp/crc_check.img
-$MKFS_XFS_PROG -N -d file,name=/tmp/crc_check.img,size=32m -m crc=0 \
- >/dev/null 2>&1;
-if [ $? -ne 0 ]; then
- XFS_MKFS_HAS_NO_META_SUPPORT=true
+if [ "$FSTYP" == "xfs" ]; then
+ XFS_MKFS_HAS_NO_META_SUPPORT=""
+ touch /tmp/crc_check.img
+ $MKFS_XFS_PROG -N -d file,name=/tmp/crc_check.img,size=32m -m crc=0 \
+ >/dev/null 2>&1;
+ if [ $? -ne 0 ]; then
+ XFS_MKFS_HAS_NO_META_SUPPORT=true
+ fi
+ rm -f /tmp/crc_check.img
+ export XFS_MKFS_HAS_NO_META_SUPPORT
fi
-rm -f /tmp/crc_check.img
-export XFS_MKFS_HAS_NO_META_SUPPORT
_mount_opts()
{
f2fs)
export MKFS_OPTIONS="$F2FS_MKFS_OPTIONS"
;;
+ btrfs)
+ export MKFS_OPTIONS="$BTRFS_MKFS_OPTIONS"
+ ;;
+ bcachefs)
+ export MKFS_OPTIONS=$BCACHEFS_MKFS_OPTIONS
+ ;;
*)
;;
esac
# in the section name otherwise the section will not be resognised.
# Section name must be contained between square brackets.
get_config_sections() {
- sed -n -e "s/^\[\([[:alnum:]_]*\)\]/\1/p" < $1
+ sed -n -e "s/^\[\([[:alnum:]_-]*\)\]/\1/p" < $1
}
if [ ! -f "$HOST_OPTIONS" ]; then
fi
case "$FSTYP" in
- 9p)
- # 9p mount tags are just plain strings, so anything is allowed
+ 9p|tmpfs|virtiofs)
+ # 9p and virtiofs mount tags are just plain strings, so anything is allowed
+ # tmpfs doesn't use mount source, ignore
;;
overlay)
if [ ! -d "$dev" ]; then
# When SCRATCH/TEST_* vars are defined in evironment and not
# in config file, this function is called after vars have already
# been overriden in the previous test.
-# In that case, TEST_DEV is a directory and not a blockdev and
+# In that case, TEST_DEV is a directory and not a blockdev/chardev and
# the function will return without overriding the SCRATCH/TEST_* vars.
_overlay_config_override()
{
# the new OVL_BASE_SCRATCH/TEST_DEV/MNT vars are set to the values
# of the configured base fs and SCRATCH/TEST_DEV vars are set to the
# overlayfs base and mount dirs inside base fs mount.
- [ -b "$TEST_DEV" ] || return 0
+ [ -b "$TEST_DEV" ] || [ -c "$TEST_DEV" ] || return 0
# Config file may specify base fs type, but we obay -overlay flag
- export OVL_BASE_FSTYP="$FSTYP"
+ [ "$FSTYP" == overlay ] || export OVL_BASE_FSTYP="$FSTYP"
export FSTYP=overlay
# Store original base fs vars
export TEST_DIR="$OVL_BASE_TEST_DIR/$OVL_MNT"
export MOUNT_OPTIONS="$OVERLAY_MOUNT_OPTIONS"
- [ -b "$SCRATCH_DEV" ] || return 0
+ [ -b "$SCRATCH_DEV" ] || [ -c "$SCRATCH_DEV" ] || return 0
# Store original base fs vars
export OVL_BASE_SCRATCH_DEV="$SCRATCH_DEV"
export RESULT_BASE="$here/results/"
fi
+ if [ "$FSTYP" == "tmpfs" ]; then
+ if [ -z "TEST_DEV" ]; then
+ export TEST_DEV=tmpfs_test
+ fi
+ if [ -z "SCRATCH_DEV" ]; then
+ export TEST_DEV=tmpfs_scratch
+ fi
+ fi
+
# Mandatory Config values.
MC=""
[ -z "$EMAIL" ] && MC="$MC EMAIL"
# Autodetect fs type based on what's on $TEST_DEV unless it's been set
# externally
- if [ -z "$FSTYP" ] && \
- [ "$HOSTOS" == "Linux" -o "$OSTYPE" == "linux-gnu" ] && \
- [ ! -z "$TEST_DEV" ]; then
+ if [ -z "$FSTYP" ] && [ ! -z "$TEST_DEV" ]; then
FSTYP=`blkid -c /dev/null -s TYPE -o value $TEST_DEV`
fi
FSTYP=${FSTYP:=xfs}