Update ZTS to work on FreeBSD

Update the common ZTS scripts and individual test cases as needed 
in order to allow them to be run on FreeBSD.  The high level goal
is to provide compatibility wrappers whenever possible to minimize
changes to individual test cases.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Signed-off-by: Ryan Moeller <ryan@ixsystems.com>
Closes #9692
This commit is contained in:
Matthew Macy 2019-12-18 12:29:43 -08:00 committed by Brian Behlendorf
parent 118fc3ef07
commit 7839c4b5e1
145 changed files with 1723 additions and 573 deletions

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
# #
# CDDL HEADER START # CDDL HEADER START
# #
@ -47,10 +47,19 @@ TAGS=""
ITERATIONS=1 ITERATIONS=1
ZFS_DBGMSG="$STF_SUITE/callbacks/zfs_dbgmsg.ksh" ZFS_DBGMSG="$STF_SUITE/callbacks/zfs_dbgmsg.ksh"
ZFS_DMESG="$STF_SUITE/callbacks/zfs_dmesg.ksh" ZFS_DMESG="$STF_SUITE/callbacks/zfs_dmesg.ksh"
ZFS_MMP="$STF_SUITE/callbacks/zfs_mmp.ksh" UNAME=$(uname -s)
TESTFAIL_CALLBACKS=${TESTFAIL_CALLBACKS:-"$ZFS_DBGMSG:$ZFS_DMESG:$ZFS_MMP"}
LOSETUP=${LOSETUP:-/sbin/losetup} # Override some defaults if on FreeBSD
DMSETUP=${DMSETUP:-/sbin/dmsetup} if [ "$UNAME" = "FreeBSD" ] ; then
TESTFAIL_CALLBACKS=${TESTFAIL_CALLBACKS:-"$ZFS_DMESG"}
LOSETUP=/sbin/mdconfig
DMSETUP=/sbin/gpart
else
ZFS_MMP="$STF_SUITE/callbacks/zfs_mmp.ksh"
TESTFAIL_CALLBACKS=${TESTFAIL_CALLBACKS:-"$ZFS_DBGMSG:$ZFS_DMESG:$ZFS_MMP"}
LOSETUP=${LOSETUP:-/sbin/losetup}
DMSETUP=${DMSETUP:-/sbin/dmsetup}
fi
# #
# Log an informational message when additional verbosity is enabled. # Log an informational message when additional verbosity is enabled.
@ -70,6 +79,33 @@ fail() {
exit 1 exit 1
} }
cleanup_freebsd_loopback() {
for TEST_LOOPBACK in ${LOOPBACKS}; do
if [ -c "/dev/${TEST_LOOPBACK}" ]; then
sudo "${LOSETUP}" -d -u "${TEST_LOOPBACK}" ||
echo "Failed to destroy: ${TEST_LOOPBACK}"
fi
done
}
cleanup_linux_loopback() {
for TEST_LOOPBACK in ${LOOPBACKS}; do
LOOP_DEV=$(basename "$TEST_LOOPBACK")
DM_DEV=$(sudo "${DMSETUP}" ls 2>/dev/null | \
grep "${LOOP_DEV}" | cut -f1)
if [ -n "$DM_DEV" ]; then
sudo "${DMSETUP}" remove "${DM_DEV}" ||
echo "Failed to remove: ${DM_DEV}"
fi
if [ -n "${TEST_LOOPBACK}" ]; then
sudo "${LOSETUP}" -d "${TEST_LOOPBACK}" ||
echo "Failed to remove: ${TEST_LOOPBACK}"
fi
done
}
# #
# Attempt to remove loopback devices and files which where created earlier # Attempt to remove loopback devices and files which where created earlier
# by this script to run the test framework. The '-k' option may be passed # by this script to run the test framework. The '-k' option may be passed
@ -80,22 +116,13 @@ cleanup() {
return 0 return 0
fi fi
if [ "$LOOPBACK" = "yes" ]; then if [ "$LOOPBACK" = "yes" ]; then
for TEST_LOOPBACK in ${LOOPBACKS}; do if [ "$UNAME" = "FreeBSD" ] ; then
LOOP_DEV=$(basename "$TEST_LOOPBACK") cleanup_freebsd_loopback
DM_DEV=$(sudo "${DMSETUP}" ls 2>/dev/null | \ else
grep "${LOOP_DEV}" | cut -f1) cleanup_linux_loopback
fi
if [ -n "$DM_DEV" ]; then
sudo "${DMSETUP}" remove "${DM_DEV}" ||
echo "Failed to remove: ${DM_DEV}"
fi
if [ -n "${TEST_LOOPBACK}" ]; then
sudo "${LOSETUP}" -d "${TEST_LOOPBACK}" ||
echo "Failed to remove: ${TEST_LOOPBACK}"
fi
done
fi fi
for TEST_FILE in ${FILES}; do for TEST_FILE in ${FILES}; do
@ -118,7 +145,11 @@ cleanup_all() {
local TEST_POOLS local TEST_POOLS
TEST_POOLS=$(sudo "$ZPOOL" list -H -o name | grep testpool) TEST_POOLS=$(sudo "$ZPOOL" list -H -o name | grep testpool)
local TEST_LOOPBACKS local TEST_LOOPBACKS
TEST_LOOPBACKS=$(sudo "${LOSETUP}" -a|grep file-vdev|cut -f1 -d:) if [ "$UNAME" = "FreeBSD" ] ; then
TEST_LOOPBACKS=$(sudo "${LOSETUP}" -l)
else
TEST_LOOPBACKS=$(sudo "${LOSETUP}" -a|grep file-vdev|cut -f1 -d:)
fi
local TEST_FILES local TEST_FILES
TEST_FILES=$(ls /var/tmp/file-vdev* 2>/dev/null) TEST_FILES=$(ls /var/tmp/file-vdev* 2>/dev/null)
@ -129,13 +160,19 @@ cleanup_all() {
sudo "$ZPOOL" destroy "${TEST_POOL}" sudo "$ZPOOL" destroy "${TEST_POOL}"
done done
msg "Removing dm(s): $(sudo "${DMSETUP}" ls | if [ "$UNAME" != "FreeBSD" ] ; then
grep loop | tr '\n' ' ')" msg "Removing dm(s): $(sudo "${DMSETUP}" ls |
sudo "${DMSETUP}" remove_all grep loop | tr '\n' ' ')"
sudo "${DMSETUP}" remove_all
fi
msg "Removing loopback(s): $(echo "${TEST_LOOPBACKS}" | tr '\n' ' ')" msg "Removing loopback(s): $(echo "${TEST_LOOPBACKS}" | tr '\n' ' ')"
for TEST_LOOPBACK in $TEST_LOOPBACKS; do for TEST_LOOPBACK in $TEST_LOOPBACKS; do
sudo "${LOSETUP}" -d "${TEST_LOOPBACK}" if [ "$UNAME" = "FreeBSD" ] ; then
sudo "${LOSETUP}" -d -u "${TEST_LOOPBACK}"
else
sudo "${LOSETUP}" -d "${TEST_LOOPBACK}"
fi
done done
msg "Removing files(s): $(echo "${TEST_FILES}" | tr '\n' ' ')" msg "Removing files(s): $(echo "${TEST_FILES}" | tr '\n' ' ')"
@ -202,6 +239,9 @@ create_links() {
constrain_path() { constrain_path() {
. "$STF_SUITE/include/commands.cfg" . "$STF_SUITE/include/commands.cfg"
SYSTEM_DIRS="/bin /sbin /usr/bin /usr/sbin"
SYSTEM_DIRS+=" /usr/local/bin /usr/local/sbin"
if [ "$INTREE" = "yes" ]; then if [ "$INTREE" = "yes" ]; then
# Constrained path set to ./zfs/bin/ # Constrained path set to ./zfs/bin/
STF_PATH="$BIN_DIR" STF_PATH="$BIN_DIR"
@ -224,30 +264,40 @@ constrain_path() {
else else
# Constrained path set to /var/tmp/constrained_path.* # Constrained path set to /var/tmp/constrained_path.*
SYSTEMDIR=${SYSTEMDIR:-/var/tmp/constrained_path.XXXX} SYSTEMDIR=${SYSTEMDIR:-/var/tmp/constrained_path.XXXX}
STF_PATH=$(/bin/mktemp -d "$SYSTEMDIR") STF_PATH=$(mktemp -d "$SYSTEMDIR")
STF_PATH_REMOVE="yes" STF_PATH_REMOVE="yes"
STF_MISSING_BIN="" STF_MISSING_BIN=""
chmod 755 "$STF_PATH" || fail "Couldn't chmod $STF_PATH" chmod 755 "$STF_PATH" || fail "Couldn't chmod $STF_PATH"
# Special case links for standard zfs utilities # Special case links for standard zfs utilities
create_links "/bin /usr/bin /sbin /usr/sbin" "$ZFS_FILES" create_links "$SYSTEM_DIRS" "$ZFS_FILES"
# Special case links for zfs test suite utilities # Special case links for zfs test suite utilities
create_links "$STF_SUITE/bin" "$ZFSTEST_FILES" create_links "$STF_SUITE/bin" "$ZFSTEST_FILES"
fi fi
# Standard system utilities # Standard system utilities
create_links "/bin /usr/bin /sbin /usr/sbin" "$SYSTEM_FILES" SYSTEM_FILES="$SYSTEM_FILES_COMMON"
if [ "$UNAME" = "FreeBSD" ] ; then
SYSTEM_FILES+=" $SYSTEM_FILES_FREEBSD"
else
SYSTEM_FILES+=" $SYSTEM_FILES_LINUX"
fi
create_links "$SYSTEM_DIRS" "$SYSTEM_FILES"
# Exceptions # Exceptions
ln -fs "$STF_PATH/awk" "$STF_PATH/nawk" ln -fs "$STF_PATH/awk" "$STF_PATH/nawk"
ln -fs /sbin/fsck.ext4 "$STF_PATH/fsck" if [ "$UNAME" = "Linux" ] ; then
ln -fs /sbin/mkfs.ext4 "$STF_PATH/newfs" ln -fs /sbin/fsck.ext4 "$STF_PATH/fsck"
ln -fs "$STF_PATH/gzip" "$STF_PATH/compress" ln -fs /sbin/mkfs.ext4 "$STF_PATH/newfs"
ln -fs "$STF_PATH/gunzip" "$STF_PATH/uncompress" ln -fs "$STF_PATH/gzip" "$STF_PATH/compress"
ln -fs "$STF_PATH/exportfs" "$STF_PATH/share" ln -fs "$STF_PATH/gunzip" "$STF_PATH/uncompress"
ln -fs "$STF_PATH/exportfs" "$STF_PATH/unshare" ln -fs "$STF_PATH/exportfs" "$STF_PATH/share"
ln -fs "$STF_PATH/exportfs" "$STF_PATH/unshare"
elif [ "$UNAME" = "FreeBSD" ] ; then
ln -fs /usr/local/bin/ksh93 "$STF_PATH/ksh"
fi
if [ -L "$STF_PATH/arc_summary3" ]; then if [ -L "$STF_PATH/arc_summary3" ]; then
ln -fs "$STF_PATH/arc_summary3" "$STF_PATH/arc_summary" ln -fs "$STF_PATH/arc_summary3" "$STF_PATH/arc_summary"
@ -466,6 +516,9 @@ constrain_path
# #
# Check if ksh exists # Check if ksh exists
# #
if [ "$UNAME" = "FreeBSD" ]; then
sudo ln -fs /usr/local/bin/ksh93 /bin/ksh
fi
[ -e "$STF_PATH/ksh" ] || fail "This test suite requires ksh." [ -e "$STF_PATH/ksh" ] || fail "This test suite requires ksh."
[ -e "$STF_SUITE/include/default.cfg" ] || fail \ [ -e "$STF_SUITE/include/default.cfg" ] || fail \
"Missing $STF_SUITE/include/default.cfg file." "Missing $STF_SUITE/include/default.cfg file."
@ -509,7 +562,11 @@ fi
# #
# See libzfs/libzfs_config.c for more information. # See libzfs/libzfs_config.c for more information.
# #
__ZFS_POOL_EXCLUDE="$(echo "$KEEP" | sed ':a;N;s/\n/ /g;ba')" if [ "$UNAME" = "FreeBSD" ] ; then
__ZFS_POOL_EXCLUDE="$(echo "$KEEP" | tr -s '\n' ' ')"
else
__ZFS_POOL_EXCLUDE="$(echo "$KEEP" | sed ':a;N;s/\n/ /g;ba')"
fi
. "$STF_SUITE/include/default.cfg" . "$STF_SUITE/include/default.cfg"
@ -549,15 +606,28 @@ if [ -z "${DISKS}" ]; then
test -x "$LOSETUP" || fail "$LOSETUP utility must be installed" test -x "$LOSETUP" || fail "$LOSETUP utility must be installed"
for TEST_FILE in ${FILES}; do for TEST_FILE in ${FILES}; do
TEST_LOOPBACK=$(sudo "${LOSETUP}" -f) if [ "$UNAME" = "FreeBSD" ] ; then
sudo "${LOSETUP}" "${TEST_LOOPBACK}" "${TEST_FILE}" || MDDEVICE=$(sudo "${LOSETUP}" -a -t vnode -f "${TEST_FILE}")
fail "Failed: ${TEST_FILE} -> ${TEST_LOOPBACK}" if [ -z "$MDDEVICE" ] ; then
LOOPBACKS="${LOOPBACKS}${TEST_LOOPBACK} " fail "Failed: ${TEST_FILE} -> loopback"
BASELOOPBACKS=$(basename "$TEST_LOOPBACK") fi
if [[ "$DISKS" ]]; then LOOPBACKS="${LOOPBACKS}${MDDEVICE} "
DISKS="$DISKS $BASELOOPBACKS" if [[ "$DISKS" ]]; then
DISKS="$DISKS $MDDEVICE"
else
DISKS="$MDDEVICE"
fi
else else
DISKS="$BASELOOPBACKS" TEST_LOOPBACK=$(sudo "${LOSETUP}" -f)
sudo "${LOSETUP}" "${TEST_LOOPBACK}" "${TEST_FILE}" ||
fail "Failed: ${TEST_FILE} -> ${TEST_LOOPBACK}"
LOOPBACKS="${LOOPBACKS}${TEST_LOOPBACK} "
BASELOOPBACKS=$(basename "$TEST_LOOPBACK")
if [[ "$DISKS" ]]; then
DISKS="$DISKS $BASELOOPBACKS"
else
DISKS="$BASELOOPBACKS"
fi
fi fi
done done
fi fi
@ -604,8 +674,14 @@ export __ZFS_POOL_EXCLUDE
export TESTFAIL_CALLBACKS export TESTFAIL_CALLBACKS
export PATH=$STF_PATH export PATH=$STF_PATH
RESULTS_FILE=$(mktemp -u -t zts-results.XXXX -p "$FILEDIR") if [ "$UNAME" = "FreeBSD" ] ; then
REPORT_FILE=$(mktemp -u -t zts-report.XXXX -p "$FILEDIR") mkdir -p "$FILEDIR" || true
RESULTS_FILE=$(mktemp -u "${FILEDIR}/zts-results.XXXX")
REPORT_FILE=$(mktemp -u "${FILEDIR}/zts-report.XXXX")
else
RESULTS_FILE=$(mktemp -u -t zts-results.XXXX -p "$FILEDIR")
REPORT_FILE=$(mktemp -u -t zts-report.XXXX -p "$FILEDIR")
fi
# #
# Run all the tests as specified. # Run all the tests as specified.

View File

@ -2,7 +2,6 @@ EXTRA_DIST = file_common.h
SUBDIRS = \ SUBDIRS = \
chg_usr_exec \ chg_usr_exec \
user_ns_exec \
devname2devid \ devname2devid \
dir_rd_update \ dir_rd_update \
file_check \ file_check \
@ -19,11 +18,16 @@ SUBDIRS = \
mmap_libaio \ mmap_libaio \
mmapwrite \ mmapwrite \
nvlist_to_lua \ nvlist_to_lua \
randfree_file \
randwritecomp \ randwritecomp \
readmmap \ readmmap \
rename_dir \ rename_dir \
rm_lnkcnt_zero_file \ rm_lnkcnt_zero_file \
threadsappend \ stride_dd \
xattrtest \ threadsappend
stride_dd
if BUILD_LINUX
SUBDIRS += \
randfree_file \
user_ns_exec \
xattrtest
endif

View File

@ -4,3 +4,6 @@ pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin
pkgexec_PROGRAMS = mkfile pkgexec_PROGRAMS = mkfile
mkfile_SOURCES = mkfile.c mkfile_SOURCES = mkfile.c
if BUILD_FREEBSD
mkfile_LDADD = -L/usr/local/lib -lintl
endif

View File

@ -137,8 +137,17 @@ main(int argc, char **argv)
argv++; argv++;
argc--; argc--;
continue; continue;
} } else if (fchown(fd, getuid(), getgid()) < 0) {
if (lseek(fd, (off_t)size-1, SEEK_SET) < 0) { saverr = errno;
(void) fprintf(stderr, gettext(
"Could not set owner/group of %s: %s\n"),
argv[1], strerror(saverr));
(void) close(fd);
errors++;
argv++;
argc--;
continue;
} else if (lseek(fd, (off_t)size-1, SEEK_SET) < 0) {
saverr = errno; saverr = errno;
(void) fprintf(stderr, gettext( (void) fprintf(stderr, gettext(
"Could not seek to offset %ld in %s: %s\n"), "Could not seek to offset %ld in %s: %s\n"),

View File

@ -55,6 +55,10 @@ main(int argc, char **argv)
(void) fprintf(stderr, "Failed to create %s %s\n", buf, (void) fprintf(stderr, "Failed to create %s %s\n", buf,
strerror(errno)); strerror(errno));
return (-4); return (-4);
} else if (fchown(fd, getuid(), getgid()) < 0) {
(void) fprintf(stderr, "Failed to chown %s %s\n", buf,
strerror(errno));
return (-5);
} }
(void) close(fd); (void) close(fd);
} }

View File

@ -30,7 +30,9 @@
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include <fcntl.h> #include <fcntl.h>
#ifdef __linux__
#include <sys/xattr.h> #include <sys/xattr.h>
#endif
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/param.h> #include <sys/param.h>
@ -176,11 +178,13 @@ crtfile(char *pname)
exit(errno); exit(errno);
} }
#ifdef __linux__
if (fsetxattr(fd, "user.xattr", pbuf, 1024, 0) < 0) { if (fsetxattr(fd, "user.xattr", pbuf, 1024, 0) < 0) {
(void) fprintf(stderr, "fsetxattr(fd, \"xattr\", pbuf, " (void) fprintf(stderr, "fsetxattr(fd, \"xattr\", pbuf, "
"1024, 0) failed.\n[%d]: %s.\n", errno, strerror(errno)); "1024, 0) failed.\n[%d]: %s.\n", errno, strerror(errno));
exit(errno); exit(errno);
} }
#endif
(void) close(fd); (void) close(fd);
free(pbuf); free(pbuf);

View File

@ -79,6 +79,8 @@ function block_device_wait
typeset local elapsed=$((SECONDS - start)) typeset local elapsed=$((SECONDS - start))
[[ $elapsed > 60 ]] && \ [[ $elapsed > 60 ]] && \
log_note udevadm settle time too long: $elapsed log_note udevadm settle time too long: $elapsed
elif is_freebsd; then
sleep 3
fi fi
} }
@ -94,6 +96,9 @@ function is_physical_device #device
[[ -b "$DEV_DSKDIR/$device" ]] && \ [[ -b "$DEV_DSKDIR/$device" ]] && \
[[ -f /sys/module/loop/parameters/max_part ]] [[ -f /sys/module/loop/parameters/max_part ]]
return $? return $?
elif is_freebsd; then
echo $device | grep -q -e '^a?da[0-9]*$' -e '^md[0-9]*$' > /dev/null 2>&1
return $?
else else
echo $device | egrep "^c[0-F]+([td][0-F]+)+$" > /dev/null 2>&1 echo $device | egrep "^c[0-F]+([td][0-F]+)+$" > /dev/null 2>&1
return $? return $?
@ -131,10 +136,17 @@ function is_loop_device #disk
} }
# #
# Linux:
# Check if the given device is a multipath device and if there is a symbolic # Check if the given device is a multipath device and if there is a symbolic
# link to a device mapper and to a disk # link to a device mapper and to a disk
# Currently no support for dm devices alone without multipath # Currently no support for dm devices alone without multipath
# #
# FreeBSD:
# Check if the given device is a gmultipath device.
#
# Others:
# No multipath detection.
#
function is_mpath_device #disk function is_mpath_device #disk
{ {
typeset disk=$1 typeset disk=$1
@ -149,6 +161,10 @@ function is_mpath_device #disk
else else
return $? return $?
fi fi
elif is_freebsd; then
test -b $DEV_MPATHDIR/$disk
else
false
fi fi
} }
@ -178,6 +194,9 @@ function set_slice_prefix
fi fi
(( i = i + 1)) (( i = i + 1))
done done
elif is_freebsd; then
export SLICE_PREFIX="p"
return 0
fi fi
} }
@ -218,7 +237,7 @@ function get_device_dir #device
{ {
typeset device=$1 typeset device=$1
if ! $(is_physical_device $device) ; then if ! is_freebsd && ! $(is_physical_device $device) ; then
if [[ $device != "/" ]]; then if [[ $device != "/" ]]; then
device=${device%/*} device=${device%/*}
fi fi
@ -459,7 +478,7 @@ function get_pool_devices #testpool #devdir
typeset devdir=$2 typeset devdir=$2
typeset out="" typeset out=""
if is_linux; then if is_linux || is_freebsd; then
out=$(zpool status -P $testpool |grep ${devdir} | awk '{print $1}') out=$(zpool status -P $testpool |grep ${devdir} | awk '{print $1}')
out=$(echo $out | sed -e "s|${devdir}/||g" | tr '\n' ' ') out=$(echo $out | sed -e "s|${devdir}/||g" | tr '\n' ' ')
fi fi

View File

@ -8,22 +8,17 @@
# Please keep the contents of each variable sorted for ease of reading # Please keep the contents of each variable sorted for ease of reading
# and maintenance. # and maintenance.
# #
export SYSTEM_FILES='arp export SYSTEM_FILES_COMMON='arp
awk awk
attr
base64 base64
basename basename
bc bc
blkid
blockdev
bunzip2 bunzip2
bzcat bzcat
cat cat
chattr
chgrp chgrp
chmod chmod
chown chown
cksum
cmp cmp
cp cp
cpio cpio
@ -37,11 +32,8 @@ export SYSTEM_FILES='arp
du du
echo echo
egrep egrep
exportfs
expr expr
fallocate
false false
fdisk
file file
find find
fio fio
@ -49,15 +41,10 @@ export SYSTEM_FILES='arp
getconf getconf
getent getent
getfacl getfacl
getfattr
grep grep
groupadd
groupdel
groupmod
gunzip gunzip
gzip gzip
head head
hostid
hostname hostname
id id
iostat iostat
@ -65,29 +52,16 @@ export SYSTEM_FILES='arp
ksh ksh
ln ln
logname logname
losetup
ls ls
lsattr
lsblk
lscpu
lsmod
lsscsi
md5sum
mkdir mkdir
mknod mknod
mkswap
mktemp mktemp
modprobe
mount mount
mpstat
mv mv
net net
nproc
od od
openssl openssl
parted
pax pax
perf
pgrep pgrep
ping ping
pkill pkill
@ -105,11 +79,8 @@ export SYSTEM_FILES='arp
scp scp
sed sed
seq seq
setenforce
setfacl setfacl
setfattr
sh sh
sha256sum
shuf shuf
sleep sleep
sort sort
@ -130,13 +101,9 @@ export SYSTEM_FILES='arp
tr tr
true true
truncate truncate
udevadm
umask umask
umount umount
uname uname
useradd
userdel
usermod
uuidgen uuidgen
vmstat vmstat
wait wait
@ -144,6 +111,55 @@ export SYSTEM_FILES='arp
which which
xargs' xargs'
export SYSTEM_FILES_FREEBSD='chflags
compress
dumpon
fsck
gpart
md5
mdconfig
mkfifo
newfs
pw
sha256
swapctl
sysctl
uncompress'
export SYSTEM_FILES_LINUX='attr
blkid
blockdev
chattr
cksum
exportfs
fallocate
fdisk
getfattr
groupadd
groupdel
groupmod
hostid
losetup
lsattr
lsblk
lscpu
lsmod
lsscsi
md5sum
mkswap
modprobe
mpstat
nproc
parted
perf
setenforce
setfattr
sha256sum
udevadm
useradd
userdel
usermod'
export ZFS_FILES='zdb export ZFS_FILES='zdb
zfs zfs
zhack zhack

View File

@ -143,7 +143,7 @@ export SPA_MINDEVSIZE=$((64 * 1024 * 1024))
# For iscsi target support # For iscsi target support
export ISCSITGTFILE=/tmp/iscsitgt_file export ISCSITGTFILE=/tmp/iscsitgt_file
export ISCSITGT_FMRI=svc:/system/iscsitgt:default export ISCSITGT_FMRI=svc:/system/iscsitgt:default
if ! is_linux; then if ! is_linux && ! is_freebsd; then
export AUTO_SNAP=$(svcs -a | grep auto-snapshot | grep online | awk \ export AUTO_SNAP=$(svcs -a | grep auto-snapshot | grep online | awk \
'{print $3}') '{print $3}')
fi fi
@ -184,6 +184,20 @@ if is_linux; then
NEWFS_DEFAULT_FS="ext2" NEWFS_DEFAULT_FS="ext2"
elif is_freebsd; then
unpack_opts="xv"
pack_opts="cf"
verbose="v"
unpack_preserve="xpf"
pack_preserve="cpf"
ZVOL_DEVDIR="/dev/zvol"
ZVOL_RDEVDIR="/dev/zvol"
DEV_DSKDIR="/dev"
DEV_RDSKDIR="/dev"
DEV_MPATHDIR="/dev/multipath"
NEWFS_DEFAULT_FS="ufs"
else else
unpack_opts="xv" unpack_opts="xv"
pack_opts="cf" pack_opts="cf"

View File

@ -92,6 +92,19 @@ function is_linux
fi fi
} }
# Determine if this is a FreeBSD test system
#
# Return 0 if platform FreeBSD, 1 if otherwise
function is_freebsd
{
if [[ $(uname -o) == "FreeBSD" ]]; then
return 0
else
return 1
fi
}
# Determine if this is a 32-bit system # Determine if this is a 32-bit system
# #
# Return 0 if platform is 32-bit, 1 if otherwise # Return 0 if platform is 32-bit, 1 if otherwise
@ -144,17 +157,23 @@ function ismounted
fi fi
;; ;;
ufs|nfs) ufs|nfs)
out=$(df -F $fstype $1 2>/dev/null) if is_freebsd; then
ret=$? mount -pt $fstype | while read dev dir _t _flags; do
(($ret != 0)) && return $ret [[ "$1" == "$dev" || "$1" == "$dir" ]] && return 0
done
else
out=$(df -F $fstype $1 2>/dev/null)
ret=$?
(($ret != 0)) && return $ret
dir=${out%%\(*} dir=${out%%\(*}
dir=${dir%% *} dir=${dir%% *}
name=${out##*\(} name=${out##*\(}
name=${name%%\)*} name=${name%%\)*}
name=${name%% *} name=${name%% *}
[[ "$1" == "$dir" || "$1" == "$name" ]] && return 0 [[ "$1" == "$dir" || "$1" == "$name" ]] && return 0
fi
;; ;;
ext*) ext*)
out=$(df -t $fstype $1 2>/dev/null) out=$(df -t $fstype $1 2>/dev/null)
@ -881,7 +900,8 @@ function set_partition
typeset size=$3 typeset size=$3
typeset disk=$4 typeset disk=$4
if is_linux; then case "$(uname)" in
Linux)
if [[ -z $size || -z $disk ]]; then if [[ -z $size || -z $disk ]]; then
log_fail "The size or disk name is unspecified." log_fail "The size or disk name is unspecified."
fi fi
@ -928,7 +948,36 @@ function set_partition
blockdev --rereadpt $disk 2>/dev/null blockdev --rereadpt $disk 2>/dev/null
block_device_wait $disk block_device_wait $disk
else ;;
FreeBSD)
if [[ -z $size || -z $disk ]]; then
log_fail "The size or disk name is unspecified."
fi
[[ -n $DEV_DSKDIR ]] && disk=$DEV_DSKDIR/$disk
if [[ $slicenum -eq 0 ]] || ! gpart show $disk >/dev/null 2>&1; then
gpart destroy -F $disk >/dev/null 2>&1
gpart create -s GPT $disk
if [[ $? -ne 0 ]]; then
log_note "Failed to create GPT partition table on $disk"
return 1
fi
fi
typeset index=$((slicenum + 1))
if [[ -n $start ]]; then
start="-b $start"
fi
gpart add -t freebsd-zfs $start -s $size -i $index $disk
if [[ $ret_val -ne 0 ]]; then
log_note "Failed to create partition $slicenum on $disk"
return 1
fi
block_device_wait $disk
;;
*)
if [[ -z $slicenum || -z $size || -z $disk ]]; then if [[ -z $slicenum || -z $size || -z $disk ]]; then
log_fail "The slice, size or disk name is unspecified." log_fail "The slice, size or disk name is unspecified."
fi fi
@ -949,7 +998,8 @@ function set_partition
format -e -s -d $disk -f $format_file format -e -s -d $disk -f $format_file
typeset ret_val=$? typeset ret_val=$?
rm -f $format_file rm -f $format_file
fi ;;
esac
if [[ $ret_val -ne 0 ]]; then if [[ $ret_val -ne 0 ]]; then
log_note "Unable to format $disk slice $slicenum to $size" log_note "Unable to format $disk slice $slicenum to $size"
@ -984,6 +1034,14 @@ function delete_partitions
fi fi
done done
done done
elif is_freebsd; then
for disk in $DISKSARRAY; do
if gpart destroy -F $disk; then
log_note "Partitions for ${disk} deleted"
else
log_fail "Partitions for ${disk} not deleted"
fi
done
fi fi
} }
@ -998,13 +1056,22 @@ function get_endslice #<disk> <slice>
log_fail "The disk name or slice number is unspecified." log_fail "The disk name or slice number is unspecified."
fi fi
if is_linux; then case "$(uname)" in
Linux)
endcyl=$(parted -s $DEV_DSKDIR/$disk -- unit cyl print | \ endcyl=$(parted -s $DEV_DSKDIR/$disk -- unit cyl print | \
grep "part${slice}" | \ grep "part${slice}" | \
awk '{print $3}' | \ awk '{print $3}' | \
sed 's,cyl,,') sed 's,cyl,,')
((endcyl = (endcyl + 1))) ((endcyl = (endcyl + 1)))
else ;;
FreeBSD)
disk=${disk#/dev/zvol/}
disk=${disk%p*}
slice=$((slice + 1))
endcyl=$(gpart show $disk | \
awk -v slice=$slice '$3 == slice { print $1 + $2 }')
;;
*)
disk=${disk#/dev/dsk/} disk=${disk#/dev/dsk/}
disk=${disk#/dev/rdsk/} disk=${disk#/dev/rdsk/}
disk=${disk%s*} disk=${disk%s*}
@ -1022,7 +1089,8 @@ function get_endslice #<disk> <slice>
nawk -v token="$slice" '{if ($1==token) print $6}') nawk -v token="$slice" '{if ($1==token) print $6}')
((endcyl = (endcyl + 1) / ratio)) ((endcyl = (endcyl + 1) / ratio))
fi ;;
esac
echo $endcyl echo $endcyl
} }
@ -1441,7 +1509,7 @@ function setup_nfs_server
return return
fi fi
if is_linux; then if is_linux || is_freebsd; then
# #
# Re-synchronize /var/lib/nfs/etab with /etc/exports and # Re-synchronize /var/lib/nfs/etab with /etc/exports and
# /etc/exports.d./* to provide a clean test environment. # /etc/exports.d./* to provide a clean test environment.
@ -1497,7 +1565,7 @@ function setup_nfs_server
# #
function is_global_zone function is_global_zone
{ {
if is_linux; then if is_linux || is_freebsd; then
return 0 return 0
else else
typeset cur_zone=$(zonename 2>/dev/null) typeset cur_zone=$(zonename 2>/dev/null)
@ -2244,7 +2312,7 @@ function cleanup_devices #vdevs
function find_disks function find_disks
{ {
# Trust provided list, no attempt is made to locate unused devices. # Trust provided list, no attempt is made to locate unused devices.
if is_linux; then if is_linux || is_freebsd; then
echo "$@" echo "$@"
return return
fi fi
@ -2325,6 +2393,224 @@ EOF
echo $unused echo $unused
} }
function add_user_freebsd #<group_name> <user_name> <basedir>
{
typeset group=$1
typeset user=$2
typeset basedir=$3
# Check to see if the user exists.
if id $user > /dev/null 2>&1; then
return 0
fi
# Assign 1000 as the base uid
typeset -i uid=1000
while true; do
typeset -i ret
pw useradd -u $uid -g $group -d $basedir/$user -m -n $user
ret=$?
case $ret in
0) break ;;
# The uid is not unique
65) ((uid += 1)) ;;
*) return 1 ;;
esac
if [[ $uid == 65000 ]]; then
log_fail "No user id available under 65000 for $user"
fi
done
# Silence MOTD
touch $basedir/$user/.hushlogin
return 0
}
#
# Delete the specified user.
#
# $1 login name
#
function del_user_freebsd #<logname>
{
typeset user=$1
if id $user > /dev/null 2>&1; then
log_must pw userdel $user
fi
return 0
}
#
# Select valid gid and create specified group.
#
# $1 group name
#
function add_group_freebsd #<group_name>
{
typeset group=$1
# See if the group already exists.
if pw groupshow $group >/dev/null 2>&1; then
return 0
fi
# Assign 1000 as the base gid
typeset -i gid=1000
while true; do
pw groupadd -g $gid -n $group > /dev/null 2>&1
typeset -i ret=$?
case $ret in
0) return 0 ;;
# The gid is not unique
65) ((gid += 1)) ;;
*) return 1 ;;
esac
if [[ $gid == 65000 ]]; then
log_fail "No user id available under 65000 for $group"
fi
done
}
#
# Delete the specified group.
#
# $1 group name
#
function del_group_freebsd #<group_name>
{
typeset group=$1
pw groupdel -n $group > /dev/null 2>&1
typeset -i ret=$?
case $ret in
# Group does not exist, or was deleted successfully.
0|6|65) return 0 ;;
# Name already exists as a group name
9) log_must pw groupdel $group ;;
*) return 1 ;;
esac
return 0
}
function add_user_illumos #<group_name> <user_name> <basedir>
{
typeset group=$1
typeset user=$2
typeset basedir=$3
log_must useradd -g $group -d $basedir/$user -m $user
return 0
}
function del_user_illumos #<user_name>
{
typeset user=$1
if id $user > /dev/null 2>&1; then
log_must_retry "currently used" 6 userdel $user
fi
return 0
}
function add_group_illumos #<group_name>
{
typeset group=$1
typeset -i gid=100
while true; do
groupadd -g $gid $group > /dev/null 2>&1
typeset -i ret=$?
case $ret in
0) return 0 ;;
# The gid is not unique
4) ((gid += 1)) ;;
*) return 1 ;;
esac
done
}
function del_group_illumos #<group_name>
{
typeset group=$1
groupmod -n $grp $grp > /dev/null 2>&1
typeset -i ret=$?
case $ret in
# Group does not exist.
6) return 0 ;;
# Name already exists as a group name
9) log_must groupdel $grp ;;
*) return 1 ;;
esac
}
function add_user_linux #<group_name> <user_name> <basedir>
{
typeset group=$1
typeset user=$2
typeset basedir=$3
log_must useradd -g $group -d $basedir/$user -m $user
# Add new users to the same group and the command line utils.
# This allows them to be run out of the original users home
# directory as long as it permissioned to be group readable.
cmd_group=$(stat --format="%G" $(which zfs))
log_must usermod -a -G $cmd_group $user
return 0
}
function del_user_linux #<user_name>
{
typeset user=$1
if id $user > /dev/null 2>&1; then
log_must_retry "currently used" 6 userdel $user
fi
return 0
}
function add_group_linux #<group_name>
{
typeset group=$1
# Assign 100 as the base gid, a larger value is selected for
# Linux because for many distributions 1000 and under are reserved.
while true; do
groupadd $group > /dev/null 2>&1
typeset -i ret=$?
case $ret in
0) return 0 ;;
*) return 1 ;;
esac
done
}
function del_group_linux #<group_name>
{
typeset group=$1
getent group $group > /dev/null 2>&1
typeset -i ret=$?
case $ret in
# Group does not exist.
2) return 0 ;;
# Name already exists as a group name
0) log_must groupdel $group ;;
*) return 1 ;;
esac
return 0
}
# #
# Add specified user to specified group # Add specified user to specified group
# #
@ -2334,26 +2620,29 @@ EOF
# #
function add_user #<group_name> <user_name> <basedir> function add_user #<group_name> <user_name> <basedir>
{ {
typeset gname=$1 typeset group=$1
typeset uname=$2 typeset user=$2
typeset basedir=${3:-"/var/tmp"} typeset basedir=${3:-"/var/tmp"}
if ((${#gname} == 0 || ${#uname} == 0)); then if ((${#group} == 0 || ${#user} == 0)); then
log_fail "group name or user name are not defined." log_fail "group name or user name are not defined."
fi fi
log_must useradd -g $gname -d $basedir/$uname -m $uname case $(uname) in
echo "export PATH=\"$STF_PATH\"" >>$basedir/$uname/.profile FreeBSD)
echo "export PATH=\"$STF_PATH\"" >>$basedir/$uname/.bash_profile add_user_freebsd "$group" "$user" "$basedir"
echo "export PATH=\"$STF_PATH\"" >>$basedir/$uname/.login ;;
Linux)
add_user_linux "$group" "$user" "$basedir"
;;
*)
add_user_illumos "$group" "$user" "$basedir"
;;
esac
# Add new users to the same group and the command line utils. echo "export PATH=\"$STF_PATH\"" >>$basedir/$user/.profile
# This allows them to be run out of the original users home echo "export PATH=\"$STF_PATH\"" >>$basedir/$user/.bash_profile
# directory as long as it permissioned to be group readable. echo "export PATH=\"$STF_PATH\"" >>$basedir/$user/.login
if is_linux; then
cmd_group=$(stat --format="%G" $(which zfs))
log_must usermod -a -G $cmd_group $uname
fi
return 0 return 0
} }
@ -2373,9 +2662,17 @@ function del_user #<logname> <basedir>
log_fail "login name is necessary." log_fail "login name is necessary."
fi fi
if id $user > /dev/null 2>&1; then case $(uname) in
log_must_retry "currently used" 6 userdel $user FreeBSD)
fi del_user_freebsd "$user"
;;
Linux)
del_user_linux "$user"
;;
*)
del_user_illumos "$user"
;;
esac
[[ -d $basedir/$user ]] && rm -fr $basedir/$user [[ -d $basedir/$user ]] && rm -fr $basedir/$user
@ -2395,30 +2692,19 @@ function add_group #<group_name>
log_fail "group name is necessary." log_fail "group name is necessary."
fi fi
# Assign 100 as the base gid, a larger value is selected for case $(uname) in
# Linux because for many distributions 1000 and under are reserved. FreeBSD)
if is_linux; then add_group_freebsd "$group"
while true; do ;;
groupadd $group > /dev/null 2>&1 Linux)
typeset -i ret=$? add_group_linux "$group"
case $ret in ;;
0) return 0 ;; *)
*) return 1 ;; add_group_illumos "$group"
esac ;;
done esac
else
typeset -i gid=100 return 0
while true; do
groupadd -g $gid $group > /dev/null 2>&1
typeset -i ret=$?
case $ret in
0) return 0 ;;
# The gid is not unique
4) ((gid += 1)) ;;
*) return 1 ;;
esac
done
fi
} }
# #
@ -2428,32 +2714,23 @@ function add_group #<group_name>
# #
function del_group #<group_name> function del_group #<group_name>
{ {
typeset grp=$1 typeset group=$1
if ((${#grp} == 0)); then
if ((${#group} == 0)); then
log_fail "group name is necessary." log_fail "group name is necessary."
fi fi
if is_linux; then case $(uname) in
getent group $grp > /dev/null 2>&1 FreeBSD)
typeset -i ret=$? del_group_freebsd "$group"
case $ret in ;;
# Group does not exist. Linux)
2) return 0 ;; del_group_linux "$group"
# Name already exists as a group name ;;
0) log_must groupdel $grp ;; *)
*) return 1 ;; del_group_illumos "$group"
esac ;;
else esac
groupmod -n $grp $grp > /dev/null 2>&1
typeset -i ret=$?
case $ret in
# Group does not exist.
6) return 0 ;;
# Name already exists as a group name
9) log_must groupdel $grp ;;
*) return 1 ;;
esac
fi
return 0 return 0
} }
@ -2800,7 +3077,7 @@ function labelvtoc
typeset label_file=/var/tmp/labelvtoc.$$ typeset label_file=/var/tmp/labelvtoc.$$
typeset arch=$(uname -p) typeset arch=$(uname -p)
if is_linux; then if is_linux || is_freebsd; then
log_note "Currently unsupported by the test framework" log_note "Currently unsupported by the test framework"
return 1 return 1
fi fi
@ -2858,7 +3135,9 @@ function get_rootfs
{ {
typeset rootfs="" typeset rootfs=""
if ! is_linux; then if is_freebsd; then
rootfs=$(mount -p | awk '$2 == "/" && $3 == "zfs" {print $1}')
elif ! is_linux; then
rootfs=$(awk '{if ($2 == "/" && $3 == "zfs") print $1}' \ rootfs=$(awk '{if ($2 == "/" && $3 == "zfs") print $1}' \
/etc/mnttab) /etc/mnttab)
fi fi
@ -2883,7 +3162,9 @@ function get_rootpool
typeset rootfs="" typeset rootfs=""
typeset rootpool="" typeset rootpool=""
if ! is_linux; then if is_freebsd; then
rootfs=$(mount -p | awk '$2 == "/" && $3 == "zfs" {print $1}')
elif ! is_linux; then
rootfs=$(awk '{if ($2 == "/" && $3 =="zfs") print $1}' \ rootfs=$(awk '{if ($2 == "/" && $3 =="zfs") print $1}' \
/etc/mnttab) /etc/mnttab)
fi fi
@ -2892,23 +3173,12 @@ function get_rootpool
fi fi
zfs list $rootfs > /dev/null 2>&1 zfs list $rootfs > /dev/null 2>&1
if (($? == 0)); then if (($? == 0)); then
rootpool=`echo $rootfs | awk -F\/ '{print $1}'` echo ${rootfs%%/*}
echo $rootpool
else else
log_fail "This is not a zfsroot system." log_fail "This is not a zfsroot system."
fi fi
} }
#
# Get the package name
#
function get_package_name
{
typeset dirpath=${1:-$STC_NAME}
echo "SUNWstc-${dirpath}" | /usr/bin/sed -e "s/\//-/g"
}
# #
# Get the word numbers from a string separated by white space # Get the word numbers from a string separated by white space
# #
@ -2971,6 +3241,8 @@ function is_mp
{ {
if is_linux; then if is_linux; then
(($(nproc) > 1)) (($(nproc) > 1))
elif is_freebsd; then
sysctl -n kern.smp.cpus
else else
(($(psrinfo | wc -l) > 1)) (($(psrinfo | wc -l) > 1))
fi fi
@ -2982,6 +3254,8 @@ function get_cpu_freq
{ {
if is_linux; then if is_linux; then
lscpu | awk '/CPU MHz/ { print $3 }' lscpu | awk '/CPU MHz/ { print $3 }'
elif is_freebsd; then
cat /var/run/dmesg.boot | grep '^CPU:' | cut -d '(' -f 2 | cut -d ')' -f 1
else else
psrinfo -v 0 | awk '/processor operates at/ {print $6}' psrinfo -v 0 | awk '/processor operates at/ {print $6}'
fi fi
@ -2994,8 +3268,13 @@ function user_run
shift shift
log_note "user:$user $@" log_note "user:$user $@"
eval su - \$user -c \"$@\" > $TEST_BASE_DIR/out 2>$TEST_BASE_DIR/err if is_freebsd; then
return $? eval "su \$user -c \"$@\"" > $TEST_BASE_DIR/out 2>$TEST_BASE_DIR/err
return $?
else
eval su - \$user -c \"$@\" > $TEST_BASE_DIR/out 2>$TEST_BASE_DIR/err
return $?
fi
} }
# #
@ -3121,7 +3400,11 @@ function get_objnum
typeset objnum typeset objnum
[[ -e $pathname ]] || log_fail "No such file or directory: $pathname" [[ -e $pathname ]] || log_fail "No such file or directory: $pathname"
objnum=$(stat -c %i $pathname) if is_freebsd; then
objnum=$(stat -f "%i" $pathname)
else
objnum=$(stat -c %i $pathname)
fi
echo $objnum echo $objnum
} }
@ -3214,7 +3497,7 @@ function zed_rc_restore
function zed_setup function zed_setup
{ {
if ! is_linux; then if ! is_linux; then
return log_unsupported "No zed on $(uname)"
fi fi
if [[ ! -d $ZEDLET_DIR ]]; then if [[ ! -d $ZEDLET_DIR ]]; then
@ -3376,6 +3659,8 @@ function is_swap_inuse
if is_linux; then if is_linux; then
swapon -s | grep -w $(readlink -f $device) > /dev/null 2>&1 swapon -s | grep -w $(readlink -f $device) > /dev/null 2>&1
elif is_freebsd; then
swapctl -l | grep -w $device
else else
swap -l | grep -w $device > /dev/null 2>&1 swap -l | grep -w $device > /dev/null 2>&1
fi fi
@ -3393,6 +3678,8 @@ function swap_setup
if is_linux; then if is_linux; then
log_must eval "mkswap $swapdev > /dev/null 2>&1" log_must eval "mkswap $swapdev > /dev/null 2>&1"
log_must swapon $swapdev log_must swapon $swapdev
elif is_freebsd; then
log_must swapctl -a $swapdev
else else
log_must swap -a $swapdev log_must swap -a $swapdev
fi fi
@ -3410,6 +3697,8 @@ function swap_cleanup
if is_swap_inuse $swapdev; then if is_swap_inuse $swapdev; then
if is_linux; then if is_linux; then
log_must swapoff $swapdev log_must swapoff $swapdev
elif is_freebsd; then
log_must swapoff $swapdev
else else
log_must swap -d $swapdev log_must swap -d $swapdev
fi fi
@ -3458,6 +3747,10 @@ function set_tunable_impl
cat >"$zfs_tunables/$tunable" <<<"$value" cat >"$zfs_tunables/$tunable" <<<"$value"
return $? return $?
;; ;;
FreeBSD)
sysctl vfs.zfs.$tunable=$value
return "$?"
;;
SunOS) SunOS)
[[ "$module" -eq "zfs" ]] || return 1 [[ "$module" -eq "zfs" ]] || return 1
echo "${tunable}/${mdb_cmd}0t${value}" | mdb -kw echo "${tunable}/${mdb_cmd}0t${value}" | mdb -kw
@ -3490,6 +3783,9 @@ function get_tunable_impl
cat $zfs_tunables/$tunable cat $zfs_tunables/$tunable
return $? return $?
;; ;;
FreeBSD)
sysctl -n vfs.zfs.$tunable
;;
SunOS) SunOS)
[[ "$module" -eq "zfs" ]] || return 1 [[ "$module" -eq "zfs" ]] || return 1
;; ;;
@ -3567,7 +3863,14 @@ function md5digest
{ {
typeset file=$1 typeset file=$1
md5sum -b $file | awk '{ print $1 }' case $(uname) in
FreeBSD)
md5 -q $file
;;
*)
md5sum -b $file | awk '{ print $1 }'
;;
esac
} }
# #
@ -3578,5 +3881,38 @@ function sha256digest
{ {
typeset file=$1 typeset file=$1
sha256sum -b $file | awk '{ print $1 }' case $(uname) in
FreeBSD)
sha256 -q $file
;;
*)
sha256sum -b $file | awk '{ print $1 }'
;;
esac
}
function new_fs #<args>
{
case $(uname) in
FreeBSD)
newfs "$@"
;;
*)
echo y | newfs -v "$@"
;;
esac
}
function stat_size #<path>
{
typeset path=$1
case $(uname) in
FreeBSD)
stat -f %z "$path"
;;
*)
stat -c %s "$path"
;;
esac
} }

View File

@ -80,8 +80,13 @@ function get_rand_large_recsize
# #
# Functions to toggle on/off properties # Functions to toggle on/off properties
# #
typeset -a binary_props=('atime' 'devices' 'exec' 'readonly' 'setuid' 'xattr' typeset -a binary_props=('atime' 'devices' 'exec' 'readonly' 'setuid' 'xattr')
'zoned')
if is_freebsd; then
binary_props+=('jailed')
else
binary_props+=('zoned')
fi
if is_linux; then if is_linux; then
# Only older kernels support non-blocking mandatory locks # Only older kernels support non-blocking mandatory locks

View File

@ -42,7 +42,7 @@ log_must display_status "$TESTPOOL"
log_must zfs create -o dedup=on -V 2G $TESTPOOL/$TESTVOL log_must zfs create -o dedup=on -V 2G $TESTPOOL/$TESTVOL
log_must echo y | newfs $ZVOL_DEVDIR/$TESTPOOL/$TESTVOL >/dev/null 2>&1 log_must eval "new_fs $ZVOL_DEVDIR/$TESTPOOL/$TESTVOL >/dev/null 2>&1"
sync_pool sync_pool
log_must zpool list -v $TESTPOOL log_must zpool list -v $TESTPOOL

View File

@ -47,6 +47,9 @@ function check_atime_updated
if is_linux; then if is_linux; then
typeset before=$(stat -c %X $filename) typeset before=$(stat -c %X $filename)
sleep 2 sleep 2
elif is_freebsd; then
typeset before=$(ls -luD "%Y-%m-%d %R.%s" $filename | awk '{print $7}')
sleep 2
else else
typeset before=$(ls -Eu $filename | awk '{print $7}') typeset before=$(ls -Eu $filename | awk '{print $7}')
fi fi
@ -55,6 +58,8 @@ function check_atime_updated
if is_linux; then if is_linux; then
typeset after=$(stat -c %X $filename) typeset after=$(stat -c %X $filename)
elif is_freebsd; then
typeset after=$(ls -luD "%Y-%m-%d %R.%s" $filename | awk '{print $7}')
else else
typeset after=$(ls -Eu $filename | awk '{print $7}') typeset after=$(ls -Eu $filename | awk '{print $7}')
fi fi

View File

@ -117,7 +117,7 @@ verify_bootfs $TESTPOOL
log_must zpool create $TESTPOOL mirror $VDEV1 $VDEV2 spare $VDEV3 log_must zpool create $TESTPOOL mirror $VDEV1 $VDEV2 spare $VDEV3
verify_bootfs $TESTPOOL verify_bootfs $TESTPOOL
if is_linux; then if is_linux || is_freebsd; then
# stripe # stripe
log_must zpool create $TESTPOOL $VDEV1 $VDEV2 log_must zpool create $TESTPOOL $VDEV1 $VDEV2
verify_bootfs $TESTPOOL verify_bootfs $TESTPOOL

View File

@ -141,24 +141,16 @@ function log_program_construct_args
pool=$1 pool=$1
shift shift
# infile=$1
# Catch HERE document if it exists and save it within our shift
# temp file. The reason we do this is that since the
# log_must_program wrapper calls zfs-program twice (once
# for open context and once for syncing) the HERE doc
# is consumed in the first invocation and the second one
# does not have a program to run.
#
test -s /dev/stdin && cat > $tmpin
# #
# If $tmpin has contents it means that we consumed a HERE # Copy the contents of the original channel program to $tmpin.
# doc and $1 currently holds "-" (a dash). If there is no
# HERE doc and $tmpin is empty, then we copy the contents
# of the original channel program to $tmpin.
# #
[[ -s $tmpin ]] || cp $1 $tmpin # If $infile currently holds "-" (a dash) it means that we consume a
shift # HERE doc from stdin, otherwise $infile is a file path.
#
cat $infile > $tmpin
lua_args=$@ lua_args=$@

View File

@ -37,7 +37,7 @@ function test_instr_limit
error=$(zfs program -t $lim $TESTPOOL $ZCP_ROOT/lua_core/tst.timeout.zcp 2>&1) error=$(zfs program -t $lim $TESTPOOL $ZCP_ROOT/lua_core/tst.timeout.zcp 2>&1)
[[ $? -ne 0 ]] || log_fail "Channel program with limit $lim exited 0: $error" [[ $? -ne 0 ]] || log_fail "Channel program with limit $lim exited 0: $error"
instrs_run=$(echo $error | sed -n 's/.\+ \([0-9]*\) Lua instructions/\1/p') instrs_run=$(echo $error | awk -F "chunk" '{print $2}' | awk '{print $1}')
if [[ $instrs_run -lt $(( $lim - 100 )) ]]; then if [[ $instrs_run -lt $(( $lim - 100 )) ]]; then
log_fail "Runtime (${instrs_run} instr) < limit (${lim} - 100 instr)" log_fail "Runtime (${instrs_run} instr) < limit (${lim} - 100 instr)"
elif [[ $instrs_run -gt $(( $lim + 100 )) ]]; then elif [[ $instrs_run -gt $(( $lim + 100 )) ]]; then

View File

@ -35,6 +35,7 @@ log_onexit cleanup
log_must zfs create -o version=5 $fs log_must zfs create -o version=5 $fs
create_snapshot $fs $TESTSNAP create_snapshot $fs $TESTSNAP
log_must_program $TESTPOOL $ZCP_ROOT/synctask_core/tst.get_index_props.zcp $fs $snap os=$(uname)
log_must_program $TESTPOOL $ZCP_ROOT/synctask_core/tst.get_index_props.zcp $fs $snap $os
log_pass "Getting index props should work correctly." log_pass "Getting index props should work correctly."

View File

@ -16,6 +16,7 @@
arg = ... arg = ...
fs = arg["argv"][1] fs = arg["argv"][1]
snap = arg["argv"][2] snap = arg["argv"][2]
os = arg["argv"][3]
props = {} props = {}
@ -26,7 +27,11 @@ props['checksum'] = {{'on', 'default'}, {nil, nil}}
props['dedup'] = {{'off', 'default'}, {nil, nil}} props['dedup'] = {{'off', 'default'}, {nil, nil}}
props['compression'] = {{'off', 'default'}, {nil, nil}} props['compression'] = {{'off', 'default'}, {nil, nil}}
props['snapdir'] = {{'hidden', 'default'}, {nil, nil}} props['snapdir'] = {{'hidden', 'default'}, {nil, nil}}
props['acltype'] = {{'off', 'default'}, {'off', 'default'}} if os == "Linux" then
props['acltype'] = {{'off', 'default'}, {'off', 'default'}}
elseif os == "FreeBSD" then
props['aclmode'] = {{'discard', 'default'}, {'discard', 'default'}}
end
props['aclinherit'] = {{'restricted','default'}, {nil, nil}} props['aclinherit'] = {{'restricted','default'}, {nil, nil}}
props['copies'] = {{'1', 'default'}, {nil, nil}} props['copies'] = {{'1', 'default'}, {nil, nil}}
props['primarycache'] = {{'all', 'default'}, {'all', 'default'}} props['primarycache'] = {{'all', 'default'}, {'all', 'default'}}
@ -37,7 +42,11 @@ props['devices'] = {{'on', 'default'}, {'on', 'default'}}
props['exec'] = {{'on', 'default'}, {'on', 'default'}} props['exec'] = {{'on', 'default'}, {'on', 'default'}}
props['setuid'] = {{'on', 'default'}, {'on', 'default'}} props['setuid'] = {{'on', 'default'}, {'on', 'default'}}
props['readonly'] = {{'off', 'default'}, {nil, nil}} props['readonly'] = {{'off', 'default'}, {nil, nil}}
props['zoned'] = {{'off', 'default'}, {nil, nil}} if os == "FreeBSD" then
props['jailed'] = {{'off', 'default'}, {nil, nil}}
else
props['zoned'] = {{'off', 'default'}, {nil, nil}}
end
props['vscan'] = {{'off', 'default'}, {nil, nil}} props['vscan'] = {{'off', 'default'}, {nil, nil}}
props['nbmand'] = {{'off', 'default'}, {'off', 'default'}} props['nbmand'] = {{'off', 'default'}, {'off', 'default'}}
props['version'] = {{'5', nil}, {'5', nil}} props['version'] = {{'5', nil}, {'5', nil}}

View File

@ -48,22 +48,37 @@ set -A files writable immutable append
function cleanup function cleanup
{ {
for i in ${files[*]}; do for i in ${files[*]}; do
log_must chattr -ia $TESTDIR/$i if is_freebsd ; then
log_must rm -f $TESTDIR/$i log_must chflags noschg $TESTDIR/$i
log_must rm -f $TESTDIR/$i
else
log_must chattr -ia $TESTDIR/$i
log_must rm -f $TESTDIR/$i
fi
done done
} }
log_onexit cleanup log_onexit cleanup
log_assert "Check whether chattr works as expected" if is_freebsd ; then
log_assert "Check whether chflags works as expected"
else
log_assert "Check whether chattr works as expected"
fi
log_must touch $TESTDIR/writable log_must touch $TESTDIR/writable
log_must touch $TESTDIR/immutable log_must touch $TESTDIR/immutable
log_must touch $TESTDIR/append log_must touch $TESTDIR/append
log_must chattr -i $TESTDIR/writable if is_freebsd ; then
log_must chattr +i $TESTDIR/immutable log_must chflags noschg $TESTDIR/writable
log_must chattr +a $TESTDIR/append log_must chflags schg $TESTDIR/immutable
log_must chflags sappnd $TESTDIR/append
else
log_must chattr -i $TESTDIR/writable
log_must chattr +i $TESTDIR/immutable
log_must chattr +a $TESTDIR/append
fi
log_must eval "echo test > $TESTDIR/writable" log_must eval "echo test > $TESTDIR/writable"
log_must eval "echo test >> $TESTDIR/writable" log_must eval "echo test >> $TESTDIR/writable"
@ -72,4 +87,8 @@ log_mustnot eval "echo test >> $TESTDIR/immutable"
log_mustnot eval "echo test > $TESTDIR/append" log_mustnot eval "echo test > $TESTDIR/append"
log_must eval "echo test >> $TESTDIR/append" log_must eval "echo test >> $TESTDIR/append"
log_pass "chattr works as expected" if is_freebsd ; then
log_pass "chflags works as expected"
else
log_pass "chattr works as expected"
fi

View File

@ -75,6 +75,11 @@ firstvdev=${array[0]}
typeset -i i=1 typeset -i i=1
while [[ $i -lt ${#CHECKSUM_TYPES[*]} ]]; do while [[ $i -lt ${#CHECKSUM_TYPES[*]} ]]; do
type=${CHECKSUM_TYPES[i]} type=${CHECKSUM_TYPES[i]}
# edonr not supported on FreeBSD
if is_freebsd && [[ "$type" == "edonr" ]] ; then
(( i = i + 1 ))
continue
fi
log_must zfs set checksum=$type $TESTPOOL log_must zfs set checksum=$type $TESTPOOL
log_must file_write -o overwrite -f $TESTDIR/test_$type \ log_must file_write -o overwrite -f $TESTDIR/test_$type \
-b $WRITESZ -c 5 -d R -b $WRITESZ -c 5 -d R
@ -96,6 +101,11 @@ log_assert "Test corrupting the files and seeing checksum errors"
typeset -i j=1 typeset -i j=1
while [[ $j -lt ${#CHECKSUM_TYPES[*]} ]]; do while [[ $j -lt ${#CHECKSUM_TYPES[*]} ]]; do
type=${CHECKSUM_TYPES[$j]} type=${CHECKSUM_TYPES[$j]}
# edonr not supported on FreeBSD
if is_freebsd && [[ "$type" == "edonr" ]] ; then
(( j = j + 1 ))
continue
fi
log_must zfs set checksum=$type $TESTPOOL log_must zfs set checksum=$type $TESTPOOL
log_must file_write -o overwrite -f $TESTDIR/test_$type \ log_must file_write -o overwrite -f $TESTDIR/test_$type \
-b $WRITESZ -c 5 -d R -b $WRITESZ -c 5 -d R

View File

@ -34,8 +34,17 @@ log_onexit cleanup
function cleanup function cleanup
{ {
datasetexists $TESTPOOL && destroy_pool $TESTPOOL datasetexists $TESTPOOL && destroy_pool $TESTPOOL
if is_freebsd ; then
log_must sysctl kern.geom.debugflags=$saved_debugflags
fi
} }
if is_freebsd ; then
# FreeBSD won't allow writing to an in-use device without this set
saved_debugflags=$(sysctl -n kern.geom.debugflags)
log_must sysctl kern.geom.debugflags=16
fi
verify_runnable "global" verify_runnable "global"
verify_disk_count "$DISKS" 2 verify_disk_count "$DISKS" 2

View File

@ -40,12 +40,25 @@ function cleanup
for DISK in $DISKS; do for DISK in $DISKS; do
zpool labelclear -f $DEV_RDSKDIR/$DISK zpool labelclear -f $DEV_RDSKDIR/$DISK
done done
if is_freebsd ; then
log_must sysctl kern.geom.debugflags=$saved_debugflags
fi
} }
if is_freebsd ; then
# FreeBSD won't allow writing to an in-use device without this set
saved_debugflags=$(sysctl -n kern.geom.debugflags)
log_must sysctl kern.geom.debugflags=16
fi
verify_runnable "global" verify_runnable "global"
verify_disk_count "$DISKS" 2 verify_disk_count "$DISKS" 2
set -A DISK $DISKS set -A DISK $DISKS
WHOLE_DISK=${DISK[0]} if is_freebsd ; then
WHOLE_DISK=/dev/${DISK[0]}
else
WHOLE_DISK=${DISK[0]}
fi
default_mirror_setup_noexit $DISKS default_mirror_setup_noexit $DISKS
DEVS=$(get_pool_devices ${TESTPOOL} ${DEV_RDSKDIR}) DEVS=$(get_pool_devices ${TESTPOOL} ${DEV_RDSKDIR})
@ -57,10 +70,16 @@ log_must zpool export $TESTPOOL
log_must dd if=$DEV_RDSKDIR/${DISK[0]} of=$DEV_RDSKDIR/${DISK[1]} bs=1K count=256 conv=notrunc log_must dd if=$DEV_RDSKDIR/${DISK[0]} of=$DEV_RDSKDIR/${DISK[1]} bs=1K count=256 conv=notrunc
ubs=$(zdb -lu ${DISK[1]} | grep -e LABEL -e Uberblock -e 'labels = ') if is_freebsd; then
DISK1="/dev/${DISK[1]}"
else
DISK1="${DISK[1]}"
fi
ubs=$(zdb -lu ${DISK1} | grep -e LABEL -e Uberblock -e 'labels = ')
log_note "vdev 1: ubs $ubs" log_note "vdev 1: ubs $ubs"
ub_dump_counts=$(zdb -lu ${DISK[1]} | \ ub_dump_counts=$(zdb -lu ${DISK1} | \
awk ' /LABEL/ {label=$NF; blocks[label]=0}; awk ' /LABEL/ {label=$NF; blocks[label]=0};
/Uberblock/ {blocks[label]++}; /Uberblock/ {blocks[label]++};
END {print blocks[0],blocks[1],blocks[2],blocks[3]}') END {print blocks[0],blocks[1],blocks[2],blocks[3]}')

View File

@ -37,8 +37,17 @@ function cleanup
{ {
datasetexists $TESTPOOL && destroy_pool $TESTPOOL datasetexists $TESTPOOL && destroy_pool $TESTPOOL
rm -f $TEMPFILE rm -f $TEMPFILE
if is_freebsd ; then
log_must sysctl kern.geom.debugflags=$saved_debugflags
fi
} }
if is_freebsd ; then
# FreeBSD won't allow writing to an in-use device without this set
saved_debugflags=$(sysctl -n kern.geom.debugflags)
log_must sysctl kern.geom.debugflags=16
fi
verify_runnable "global" verify_runnable "global"
verify_disk_count "$DISKS" 2 verify_disk_count "$DISKS" 2

View File

@ -48,6 +48,10 @@ function cleanup
{ {
unset ZFS_ABORT unset ZFS_ABORT
if is_freebsd && [[ -n $savedcorefile ]]; then
sysctl kern.corefile=$savedcorefile
fi
if [[ -d $corepath ]]; then if [[ -d $corepath ]]; then
rm -rf $corepath rm -rf $corepath
fi fi
@ -63,7 +67,9 @@ log_assert "With ZFS_ABORT set, all zfs commands can abort and generate a " \
log_onexit cleanup log_onexit cleanup
# Preparation work for testing # Preparation work for testing
savedcorefile=""
corepath=$TESTDIR/core corepath=$TESTDIR/core
corefile=$corepath/core.zfs
if [[ -d $corepath ]]; then if [[ -d $corepath ]]; then
rm -rf $corepath rm -rf $corepath
fi fi
@ -91,9 +97,13 @@ typeset badparams=("" "create" "destroy" "snapshot" "rollback" "clone" \
if is_linux; then if is_linux; then
ulimit -c unlimited ulimit -c unlimited
echo "$corepath/core.zfs" >/proc/sys/kernel/core_pattern echo "$corefile" >/proc/sys/kernel/core_pattern
echo 0 >/proc/sys/kernel/core_uses_pid echo 0 >/proc/sys/kernel/core_uses_pid
export ASAN_OPTIONS="abort_on_error=1:disable_coredump=0" export ASAN_OPTIONS="abort_on_error=1:disable_coredump=0"
elif is_freebsd; then
ulimit -c unlimited
savedcorefile=$(sysctl -n kern.corefile)
log_must sysctl kern.corefile=$corepath/core.%N
else else
log_must coreadm -p ${corepath}/core.%f log_must coreadm -p ${corepath}/core.%f
fi fi
@ -102,7 +112,6 @@ log_must export ZFS_ABORT=yes
for subcmd in "${cmds[@]}" "${badparams[@]}"; do for subcmd in "${cmds[@]}" "${badparams[@]}"; do
zfs $subcmd >/dev/null 2>&1 && log_fail "$subcmd passed incorrectly." zfs $subcmd >/dev/null 2>&1 && log_fail "$subcmd passed incorrectly."
corefile=${corepath}/core.zfs
if [[ ! -e $corefile ]]; then if [[ ! -e $corefile ]]; then
log_fail "zfs $subcmd cannot generate core file with " \ log_fail "zfs $subcmd cannot generate core file with " \
"ZFS_ABORT set." "ZFS_ABORT set."

View File

@ -91,18 +91,32 @@ function do_vol_test
case "$type" in case "$type" in
"ext2") "ext2")
log_must eval "echo y | newfs $vol_r_path >/dev/null 2>&1" if is_freebsd; then
log_unsupported "ext2 test not implemented for freebsd"
fi
log_must eval "new_fs $vol_r_path >/dev/null 2>&1"
log_must mount -o rw $vol_b_path $mntp log_must mount -o rw $vol_b_path $mntp
;; ;;
"ufs") "ufs")
if is_linux; then if is_linux; then
log_unsupported "ufs test not implemented for linux" log_unsupported "ufs test not implemented for linux"
fi fi
log_must eval "newfs $vol_r_path >/dev/null 2>&1" log_must eval "new_fs $vol_r_path >/dev/null 2>&1"
log_must mount $vol_b_path $mntp log_must mount $vol_b_path $mntp
;; ;;
"zfs") "zfs")
log_must zpool create $TESTPOOL1 $vol_b_path if is_freebsd; then
# Pool creation on zvols is forbidden by default.
# Save and restore the current setting.
typeset _saved=$(get_tunable vol.recursive)
log_must set_tunable64 vol.recursive 1 # Allow
zpool create $TESTPOOL1 $vol_b_path
typeset _zpool_create_result=$?
log_must set_tunable64 vol.recursive $_saved # Restore
log_must test $_zpool_create_result = 0
else
log_must zpool create $TESTPOOL1 $vol_b_path
fi
log_must zfs create $TESTPOOL1/$TESTFS1 log_must zfs create $TESTPOOL1/$TESTFS1
;; ;;
*) *)

View File

@ -81,7 +81,7 @@ for val in 1 2 3; do
done done
log_note "Verify 'ls -s' can correctly list the space charged." log_note "Verify 'ls -s' can correctly list the space charged."
if is_linux; then if is_linux || is_freebsd; then
blksize=1024 blksize=1024
else else
blksize=512 blksize=512
@ -94,16 +94,25 @@ done
log_note "Verify df(1M) can correctly display the space charged." log_note "Verify df(1M) can correctly display the space charged."
for val in 1 2 3; do for val in 1 2 3; do
used=`df -F zfs -k /$TESTPOOL/fs_$val/$FILE | grep $TESTPOOL/fs_$val \ if is_freebsd; then
| awk '{print $3}'` used=`df -m /$TESTPOOL/fs_$val | grep $TESTPOOL/fs_$val \
(( used = used * 1024 )) # kb -> bytes | awk -v fs=fs_$val '$4 ~ fs {print $3}'`
else
used=`df -F zfs -k /$TESTPOOL/fs_$val/$FILE | grep $TESTPOOL/fs_$val \
| awk '{print $3}'`
(( used = used * 1024 )) # kb -> bytes
fi
check_used $used $val check_used $used $val
done done
log_note "Verify du(1) can correctly display the space charged." log_note "Verify du(1) can correctly display the space charged."
for val in 1 2 3; do for val in 1 2 3; do
used=`du -k /$TESTPOOL/fs_$val/$FILE | awk '{print $1}'` if is_freebsd; then
(( used = used * 1024 )) # kb -> bytes used=`du -h /$TESTPOOL/fs_$val/$FILE | awk '{print $1}'`
else
used=`du -k /$TESTPOOL/fs_$val/$FILE | awk '{print $1}'`
(( used = used * 1024 )) # kb -> bytes
fi
check_used $used $val check_used $used $val
done done

View File

@ -36,9 +36,9 @@ function cleanup
{ {
log_must zfs destroy -Rf $TESTPOOL/$TESTFS1 log_must zfs destroy -Rf $TESTPOOL/$TESTFS1
# reset the livelist sublist size to the original value # reset the livelist sublist size to the original value
set_tunable64 zfs_livelist_max_entries $ORIGINAL_MAX set_tunable64 $LIVELIST_MAX_ENTRIES $ORIGINAL_MAX
# reset the minimum percent shared to 75 # reset the minimum percent shared to 75
set_tunable32 zfs_livelist_min_percent_shared $ORIGINAL_MIN set_tunable32 $LIVELIST_MIN_PERCENT_SHARED $ORIGINAL_MIN
} }
function check_ll_len function check_ll_len
@ -58,9 +58,9 @@ function test_condense
{ {
# set the max livelist entries to a small value to more easily # set the max livelist entries to a small value to more easily
# trigger a condense # trigger a condense
set_tunable64 zfs_livelist_max_entries 20 set_tunable64 $LIVELIST_MAX_ENTRIES 20
# set a small percent shared threshold so the livelist is not disabled # set a small percent shared threshold so the livelist is not disabled
set_tunable32 zfs_livelist_min_percent_shared 10 set_tunable32 $LIVELIST_MIN_PERCENT_SHARED 10
clone_dataset $TESTFS1 snap $TESTCLONE clone_dataset $TESTFS1 snap $TESTCLONE
# sync between each write to make sure a new entry is created # sync between each write to make sure a new entry is created
@ -86,7 +86,7 @@ function test_condense
function test_deactivated function test_deactivated
{ {
# Threshold set to 50 percent # Threshold set to 50 percent
set_tunable32 zfs_livelist_min_percent_shared 50 set_tunable32 $LIVELIST_MIN_PERCENT_SHARED 50
clone_dataset $TESTFS1 snap $TESTCLONE clone_dataset $TESTFS1 snap $TESTCLONE
log_must mkfile 5m /$TESTPOOL/$TESTCLONE/$TESTFILE0 log_must mkfile 5m /$TESTPOOL/$TESTCLONE/$TESTFILE0
@ -97,7 +97,7 @@ function test_deactivated
log_must zfs destroy -R $TESTPOOL/$TESTCLONE log_must zfs destroy -R $TESTPOOL/$TESTCLONE
# Threshold set to 20 percent # Threshold set to 20 percent
set_tunable32 zfs_livelist_min_percent_shared 20 set_tunable32 $LIVELIST_MIN_PERCENT_SHARED 20
clone_dataset $TESTFS1 snap $TESTCLONE clone_dataset $TESTFS1 snap $TESTCLONE
log_must mkfile 5m /$TESTPOOL/$TESTCLONE/$TESTFILE0 log_must mkfile 5m /$TESTPOOL/$TESTCLONE/$TESTFILE0
@ -112,8 +112,8 @@ function test_deactivated
log_must zfs destroy -R $TESTPOOL/$TESTCLONE log_must zfs destroy -R $TESTPOOL/$TESTCLONE
} }
ORIGINAL_MAX=$(get_tunable zfs_livelist_max_entries) ORIGINAL_MAX=$(get_tunable $LIVELIST_MAX_ENTRIES)
ORIGINAL_MIN=$(get_tunable zfs_livelist_min_percent_shared) ORIGINAL_MIN=$(get_tunable $LIVELIST_MIN_PERCENT_SHARED)
log_onexit cleanup log_onexit cleanup
log_must zfs create $TESTPOOL/$TESTFS1 log_must zfs create $TESTPOOL/$TESTFS1

View File

@ -32,15 +32,16 @@
# then export the pool. # then export the pool.
. $STF_SUITE/include/libtest.shlib . $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/cli_root/zfs_destroy/zfs_destroy_common.kshlib
function cleanup function cleanup
{ {
log_must zfs destroy -Rf $TESTPOOL/$TESTFS1 log_must zfs destroy -Rf $TESTPOOL/$TESTFS1
# reset the livelist sublist size to the original value # reset the livelist sublist size to the original value
set_tunable64 zfs_livelist_max_entries $ORIGINAL_MAX set_tunable64 $LIVELIST_MAX_ENTRIES $ORIGINAL_MAX
# reset the condense tests to 0 # reset the condense tests to 0
set_tunable32 zfs_livelist_condense_zthr_pause 0 set_tunable32 $LIVELIST_CONDENSE_ZTHR_PAUSE 0
set_tunable32 zfs_livelist_condense_sync_pause 0 set_tunable32 $LIVELIST_CONDENSE_SYNC_PAUSE 0
} }
function delete_race function delete_race
@ -88,7 +89,7 @@ function disable_race
log_must zfs destroy $TESTPOOL/$TESTCLONE log_must zfs destroy $TESTPOOL/$TESTCLONE
} }
ORIGINAL_MAX=$(get_tunable zfs_livelist_max_entries) ORIGINAL_MAX=$(get_tunable $LIVELIST_MAX_ENTRIES)
log_onexit cleanup log_onexit cleanup
@ -98,19 +99,19 @@ log_must zpool sync $TESTPOOL
log_must zfs snapshot $TESTPOOL/$TESTFS1@snap log_must zfs snapshot $TESTPOOL/$TESTFS1@snap
# Reduce livelist size to trigger condense more easily # Reduce livelist size to trigger condense more easily
set_tunable64 zfs_livelist_max_entries 20 set_tunable64 $LIVELIST_MAX_ENTRIES 20
# Test cancellation path in the zthr # Test cancellation path in the zthr
set_tunable32 zfs_livelist_condense_zthr_pause 1 set_tunable32 $LIVELIST_CONDENSE_ZTHR_PAUSE 1
set_tunable32 zfs_livelist_condense_sync_pause 0 set_tunable32 $LIVELIST_CONDENSE_SYNC_PAUSE 0
disable_race "zfs_livelist_condense_zthr_cancel" disable_race $LIVELIST_CONDENSE_ZTHR_CANCEL
delete_race "zfs_livelist_condense_zthr_cancel" delete_race $LIVELIST_CONDENSE_ZTHR_CANCEL
export_race "zfs_livelist_condense_zthr_cancel" export_race $LIVELIST_CONDENSE_ZTHR_CANCEL
# Test cancellation path in the synctask # Test cancellation path in the synctask
set_tunable32 zfs_livelist_condense_zthr_pause 0 set_tunable32 $LIVELIST_CONDENSE_ZTHR_PAUSE 0
set_tunable32 zfs_livelist_condense_sync_pause 1 set_tunable32 $LIVELIST_CONDENSE_SYNC_PAUSE 1
disable_race "zfs_livelist_condense_sync_cancel" disable_race $LIVELIST_CONDENSE_SYNC_CANCEL
delete_race "zfs_livelist_condense_sync_cancel" delete_race $LIVELIST_CONDENSE_SYNC_CANCEL
log_pass "Clone livelist condense race conditions passed." log_pass "Clone livelist condense race conditions passed."

View File

@ -37,3 +37,20 @@ export FSSNAP=$FS@$TESTSNAP
export VOLSNAP=$VOL@$TESTSNAP export VOLSNAP=$VOL@$TESTSNAP
export FSCLONE=$TESTPOOL/$TESTFSCLONE export FSCLONE=$TESTPOOL/$TESTFSCLONE
export VOLCLONE=$TESTPOOL/$TESTVOLCLONE export VOLCLONE=$TESTPOOL/$TESTVOLCLONE
if is_freebsd; then
export LIVELIST_MAX_ENTRIES=livelist.max_entries
export LIVELIST_MIN_PERCENT_SHARED=livelist.min_percent_shared
export LIVELIST_CONDENSE_NEW_ALLOC=livelist.condense.new_alloc
export LIVELIST_CONDENSE_ZTHR_CANCEL=livelist.condense.zthr_cancel
export LIVELIST_CONDENSE_SYNC_CANCEL=livelist.condense.sync_cancel
export LIVELIST_CONDENSE_ZTHR_PAUSE=livelist.condense.zthr_pause
export LIVELIST_CONDENSE_SYNC_PAUSE=livelist.condense.sync_pause
else
export LIVELIST_MAX_ENTRIES=zfs_livelist_max_entries
export LIVELIST_MIN_PERCENT_SHARED=zfs_livelist_min_percent_shared
export LIVELIST_CONDENSE_NEW_ALLOC=zfs_livelist_condense_new_alloc
export LIVELIST_CONDENSE_ZTHR_CANCEL=zfs_livelist_condense_zthr_cancel
export LIVELIST_CONDENSE_SYNC_CANCEL=zfs_livelist_condense_sync_cancel
export LIVELIST_CONDENSE_ZTHR_PAUSE=zfs_livelist_condense_zthr_pause
export LIVELIST_CONDENSE_SYNC_PAUSE=zfs_livelist_condense_sync_pause
fi

View File

@ -40,7 +40,7 @@ function cleanup
{ {
datasetexists $TESTPOOL/$TESTFS1 && zfs destroy -R $TESTPOOL/$TESTFS1 datasetexists $TESTPOOL/$TESTFS1 && zfs destroy -R $TESTPOOL/$TESTFS1
# reset the livelist sublist size to its original value # reset the livelist sublist size to its original value
set_tunable64 zfs_livelist_max_entries $ORIGINAL_MAX set_tunable64 $LIVELIST_MAX_ENTRIES $ORIGINAL_MAX
} }
function clone_write_file function clone_write_file
@ -120,7 +120,7 @@ function test_promote
log_must zfs destroy -R $TESTPOOL/$TESTCLONE log_must zfs destroy -R $TESTPOOL/$TESTCLONE
} }
ORIGINAL_MAX=$(get_tunable zfs_livelist_max_entries) ORIGINAL_MAX=$(get_tunable $LIVELIST_MAX_ENTRIES)
log_onexit cleanup log_onexit cleanup
log_must zfs create $TESTPOOL/$TESTFS1 log_must zfs create $TESTPOOL/$TESTFS1
@ -128,7 +128,7 @@ log_must mkfile 20m /$TESTPOOL/$TESTFS1/atestfile
log_must zfs snapshot $TESTPOOL/$TESTFS1@snap log_must zfs snapshot $TESTPOOL/$TESTFS1@snap
# set a small livelist entry size to more easily test multiple entry livelists # set a small livelist entry size to more easily test multiple entry livelists
set_tunable64 zfs_livelist_max_entries 20 set_tunable64 $LIVELIST_MAX_ENTRIES 20
test_one_empty test_one_empty
test_one test_one

View File

@ -61,12 +61,7 @@ function setup_testenv #[dtst]
log_must zfs create -V $VOLSIZE $VOL log_must zfs create -V $VOLSIZE $VOL
block_device_wait block_device_wait
echo "y" | newfs $ZVOL_DEVDIR/$VOL > /dev/null 2>&1 log_must new_fs $ZVOL_DEVDIR/$VOL
if (( $? == 0 )); then
log_note "SUCCESS: newfs $ZVOL_DEVDIR/$VOL>/dev/null"
else
log_fail "newfs $ZVOL_DEVDIR/$VOL > /dev/null"
fi
if [[ ! -d $TESTDIR1 ]]; then if [[ ! -d $TESTDIR1 ]]; then
log_must mkdir $TESTDIR1 log_must mkdir $TESTDIR1

View File

@ -32,20 +32,21 @@
. $STF_SUITE/include/libtest.shlib . $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/removal/removal.kshlib . $STF_SUITE/tests/functional/removal/removal.kshlib
. $STF_SUITE/tests/functional/cli_root/zfs_destroy/zfs_destroy.cfg
function cleanup function cleanup
{ {
poolexists $TESTPOOL2 && zpool destroy $TESTPOOL2 poolexists $TESTPOOL2 && zpool destroy $TESTPOOL2
# reset livelist max size # reset livelist max size
set_tunable64 zfs_livelist_max_entries $ORIGINAL_MAX set_tunable64 $LIVELIST_MAX_ENTRIES $ORIGINAL_MAX
[[ -f $VIRTUAL_DISK1 ]] && log_must rm $VIRTUAL_DISK1 [[ -f $VIRTUAL_DISK1 ]] && log_must rm $VIRTUAL_DISK1
[[ -f $VIRTUAL_DISK2 ]] && log_must rm $VIRTUAL_DISK2 [[ -f $VIRTUAL_DISK2 ]] && log_must rm $VIRTUAL_DISK2
} }
log_onexit cleanup log_onexit cleanup
ORIGINAL_MAX=$(get_tunable zfs_livelist_max_entries) ORIGINAL_MAX=$(get_tunable $LIVELIST_MAX_ENTRIES)
set_tunable64 zfs_livelist_max_entries 20 set_tunable64 $LIVELIST_MAX_ENTRIES 20
VIRTUAL_DISK1=/var/tmp/disk1 VIRTUAL_DISK1=/var/tmp/disk1
VIRTUAL_DISK2=/var/tmp/disk2 VIRTUAL_DISK2=/var/tmp/disk2
@ -65,14 +66,14 @@ log_must zfs clone $TESTPOOL2/$TESTFS@snap $TESTPOOL2/$TESTCLONE
log_must mkfile 10m /$TESTPOOL2/$TESTCLONE/A log_must mkfile 10m /$TESTPOOL2/$TESTCLONE/A
log_must mkfile 1m /$TESTPOOL2/$TESTCLONE/B log_must mkfile 1m /$TESTPOOL2/$TESTCLONE/B
log_must zpool sync $TESTPOOL2 log_must zpool sync $TESTPOOL2
set_tunable32 zfs_livelist_condense_sync_pause 1 set_tunable32 $LIVELIST_CONDENSE_SYNC_PAUSE 1
# Add a new dev and remove the old one # Add a new dev and remove the old one
log_must zpool add $TESTPOOL2 $VIRTUAL_DISK2 log_must zpool add $TESTPOOL2 $VIRTUAL_DISK2
log_must zpool remove $TESTPOOL2 $VIRTUAL_DISK1 log_must zpool remove $TESTPOOL2 $VIRTUAL_DISK1
wait_for_removal $TESTPOOL2 wait_for_removal $TESTPOOL2
set_tunable32 zfs_livelist_condense_new_alloc 0 set_tunable32 $LIVELIST_CONDENSE_NEW_ALLOC 0
# Trigger a condense # Trigger a condense
log_must mkfile 10m /$TESTPOOL2/$TESTCLONE/A log_must mkfile 10m /$TESTPOOL2/$TESTCLONE/A
log_must zpool sync $TESTPOOL2 log_must zpool sync $TESTPOOL2
@ -82,10 +83,10 @@ log_must zpool sync $TESTPOOL2
log_must mkfile 1m /$TESTPOOL2/$TESTCLONE/B log_must mkfile 1m /$TESTPOOL2/$TESTCLONE/B
# Resume condense thr # Resume condense thr
set_tunable32 zfs_livelist_condense_sync_pause 0 set_tunable32 $LIVELIST_CONDENSE_SYNC_PAUSE 0
log_must zpool sync $TESTPOOL2 log_must zpool sync $TESTPOOL2
# Check that we've added new ALLOC blkptrs during the condense # Check that we've added new ALLOC blkptrs during the condense
[[ "0" < "$(get_tunable zfs_livelist_condense_new_alloc)" ]] || \ [[ "0" < "$(get_tunable $LIVELIST_CONDENSE_NEW_ALLOC)" ]] || \
log_fail "removal/condense test failed" log_fail "removal/condense test failed"
log_must zfs destroy $TESTPOOL2/$TESTCLONE log_must zfs destroy $TESTPOOL2/$TESTCLONE

View File

@ -22,6 +22,7 @@
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
/* ARGSUSED */ /* ARGSUSED */
int int

View File

@ -84,7 +84,11 @@ do
continue; continue;
fi fi
filetime="$(stat -c '%Z' $file)" if is_freebsd; then
filetime="$(stat -f "%c" $file)"
else
filetime="$(stat -c '%Z' $file)"
fi
if [[ "$filetime" != "$ctime" ]]; then if [[ "$filetime" != "$ctime" ]]; then
log_fail "Unexpected ctime for file $file ($filetime != $ctime)" log_fail "Unexpected ctime for file $file ($filetime != $ctime)"
else else

View File

@ -70,8 +70,13 @@ DATASET="$TESTPOOL/$TESTFS/fs"
TESTSNAP1="$DATASET@snap1" TESTSNAP1="$DATASET@snap1"
TESTSNAP2="$DATASET@snap2" TESTSNAP2="$DATASET@snap2"
FILEDIFF="$TESTDIR/zfs-diff.txt" FILEDIFF="$TESTDIR/zfs-diff.txt"
MAJOR=$(stat -c %t /dev/null) if is_freebsd; then
MINOR=$(stat -c %T /dev/null) MAJOR=$(stat -f %Hr /dev/null)
MINOR=$(stat -f %Lr /dev/null)
else
MAJOR=$(stat -c %t /dev/null)
MINOR=$(stat -c %T /dev/null)
fi
# 1. Prepare a dataset # 1. Prepare a dataset
log_must zfs create $DATASET log_must zfs create $DATASET
@ -106,7 +111,11 @@ verify_object_class "$MNTPOINT/cdev" "C"
# 2. | (Named pipe) # 2. | (Named pipe)
log_must zfs snapshot "$TESTSNAP1" log_must zfs snapshot "$TESTSNAP1"
log_must mknod "$MNTPOINT/fifo" p if is_freebsd; then
log_must mkfifo "$MNTPOINT/fifo"
else
log_must mknod "$MNTPOINT/fifo" p
fi
log_must zfs snapshot "$TESTSNAP2" log_must zfs snapshot "$TESTSNAP2"
verify_object_class "$MNTPOINT/fifo" "|" verify_object_class "$MNTPOINT/fifo" "|"

View File

@ -58,14 +58,19 @@ done
typeset zfs_props=("type" used available creation volsize referenced \ typeset zfs_props=("type" used available creation volsize referenced \
compressratio mounted origin recordsize quota reservation mountpoint \ compressratio mounted origin recordsize quota reservation mountpoint \
sharenfs checksum compression atime devices exec readonly setuid zoned \ sharenfs checksum compression atime devices exec readonly setuid \
snapdir acltype aclinherit canmount primarycache secondarycache \ snapdir aclinherit canmount primarycache secondarycache version \
usedbychildren usedbydataset usedbyrefreservation usedbysnapshots \ usedbychildren usedbydataset usedbyrefreservation usedbysnapshots)
version) if is_freebsd; then
typeset zfs_props_os=(jailed aclmode)
else
typeset zfs_props_os=(zoned acltype)
fi
typeset userquota_props=(userquota@root groupquota@root userused@root \ typeset userquota_props=(userquota@root groupquota@root userused@root \
groupused@root) groupused@root)
typeset all_props=("${zfs_props[@]}" "${userquota_props[@]}") typeset all_props=("${zfs_props[@]}" \
"${zfs_props_os[@]}" \
"${userquota_props[@]}")
typeset dataset=($TESTPOOL/$TESTCTR $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \ typeset dataset=($TESTPOOL/$TESTCTR $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \
$TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTVOL@$TESTSNAP) $TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTVOL@$TESTSNAP)

View File

@ -49,13 +49,19 @@ typeset options=(" " p r H)
typeset zfs_props=("type" used available creation volsize referenced \ typeset zfs_props=("type" used available creation volsize referenced \
compressratio mounted origin recordsize quota reservation mountpoint \ compressratio mounted origin recordsize quota reservation mountpoint \
sharenfs checksum compression atime devices exec readonly setuid zoned \ sharenfs checksum compression atime devices exec readonly setuid \
snapdir acltype aclinherit canmount primarycache secondarycache \ snapdir aclinherit canmount primarycache secondarycache version \
usedbychildren usedbydataset usedbyrefreservation usedbysnapshots version) usedbychildren usedbydataset usedbyrefreservation usedbysnapshots)
if is_freebsd; then
typeset zfs_props_os=(jailed aclmode)
else
typeset zfs_props_os=(zoned acltype)
fi
typeset userquota_props=(userquota@root groupquota@root userused@root \ typeset userquota_props=(userquota@root groupquota@root userused@root \
groupused@root) groupused@root)
typeset props=("${zfs_props[@]}" "${userquota_props[@]}") typeset props=("${zfs_props[@]}" \
"${zfs_props_os[@]}" \
"${userquota_props[@]}")
typeset dataset=($TESTPOOL/$TESTCTR $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \ typeset dataset=($TESTPOOL/$TESTCTR $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \
$TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTVOL@$TESTSNAP) $TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTVOL@$TESTSNAP)

View File

@ -47,13 +47,19 @@ verify_runnable "both"
typeset val_opts=(p r H) typeset val_opts=(p r H)
typeset v_props=(type used available creation volsize referenced compressratio \ typeset v_props=(type used available creation volsize referenced compressratio \
mounted origin recordsize quota reservation mountpoint sharenfs checksum \ mounted origin recordsize quota reservation mountpoint sharenfs checksum \
compression atime devices exec readonly setuid zoned snapdir acltype \ compression atime devices exec readonly setuid snapdir version \
aclinherit canmount primarycache secondarycache \ aclinherit canmount primarycache secondarycache \
usedbychildren usedbydataset usedbyrefreservation usedbysnapshots version) usedbychildren usedbydataset usedbyrefreservation usedbysnapshots)
if is_freebsd; then
typeset v_props_os=(jailed aclmode)
else
typeset v_props_os=(zoned acltype)
fi
typeset userquota_props=(userquota@root groupquota@root userused@root \ typeset userquota_props=(userquota@root groupquota@root userused@root \
groupused@root) groupused@root)
typeset val_props=("${v_props[@]}" "${userquota_props[@]}") typeset val_props=("${v_props[@]}" \
"${v_props_os[@]}" \
"${userquota_props[@]}")
set -f # Force shell does not parse '?' and '*' as the wildcard set -f # Force shell does not parse '?' and '*' as the wildcard
typeset inval_opts=(P R h ? *) typeset inval_opts=(P R h ? *)
typeset inval_props=(Type 0 ? * -on --on readonl time USED RATIO MOUNTED) typeset inval_props=(Type 0 ? * -on --on readonl time USED RATIO MOUNTED)

View File

@ -52,14 +52,19 @@ set -A options " " "-r" "-H" "-p" "-rHp" "-o name" \
set -A props type used available creation volsize referenced compressratio \ set -A props type used available creation volsize referenced compressratio \
mounted origin recordsize quota reservation mountpoint sharenfs \ mounted origin recordsize quota reservation mountpoint sharenfs \
checksum compression atime devices exec readonly setuid zoned snapdir \ checksum compression atime devices exec readonly setuid snapdir \
acltype aclinherit canmount primarycache secondarycache \ aclinherit canmount primarycache secondarycache \
usedbychildren usedbydataset usedbyrefreservation usedbysnapshots \ usedbychildren usedbydataset usedbyrefreservation usedbysnapshots \
userquota@root groupquota@root userused@root groupused@root userquota@root groupquota@root userused@root groupused@root
if is_freebsd; then
set -A props ${props[*]} jailed aclmode
else
set -A props ${props[*]} zoned acltype
fi
zfs upgrade -v > /dev/null 2>&1 zfs upgrade -v > /dev/null 2>&1
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
set -A all_props ${all_props[*]} version set -A props ${props[*]} version
fi fi
set -A dataset $TESTPOOL/$TESTCTR $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \ set -A dataset $TESTPOOL/$TESTCTR $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \

View File

@ -55,9 +55,14 @@ log_onexit depth_fs_cleanup
set -A all_props type used available creation volsize referenced \ set -A all_props type used available creation volsize referenced \
compressratio mounted origin recordsize quota reservation mountpoint \ compressratio mounted origin recordsize quota reservation mountpoint \
sharenfs checksum compression atime devices exec readonly setuid \ sharenfs checksum compression atime devices exec readonly setuid \
zoned snapdir acltype aclinherit canmount primarycache secondarycache \ snapdir aclinherit canmount primarycache secondarycache \
usedbychildren usedbydataset usedbyrefreservation usedbysnapshots \ usedbychildren usedbydataset usedbyrefreservation usedbysnapshots \
userquota@root groupquota@root userused@root groupused@root userquota@root groupquota@root userused@root groupused@root
if is_freebsd; then
set -A all_props ${all_props[*]} jailed aclmode
else
set -A all_props ${all_props[*]} zoned acltype
fi
zfs upgrade -v > /dev/null 2>&1 zfs upgrade -v > /dev/null 2>&1
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then

View File

@ -44,13 +44,15 @@
# 2. Apply 'zfs set mountpoint=path <filesystem>'. # 2. Apply 'zfs set mountpoint=path <filesystem>'.
# 3. Change directory to that given mountpoint. # 3. Change directory to that given mountpoint.
# 3. Invoke 'zfs mount <filesystem>'. # 3. Invoke 'zfs mount <filesystem>'.
# 4. Verify that mount succeeds on Linux and fails for other platforms. # 4. Verify that mount succeeds on Linux and FreeBSD and fails for other
# platforms.
# #
verify_runnable "both" verify_runnable "both"
function cleanup function cleanup
{ {
[[ "$PWD" = "$TESTDIR" ]] && cd -
log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
log_must force_unmount $TESTPOOL/$TESTFS log_must force_unmount $TESTPOOL/$TESTFS
return 0 return 0
@ -74,7 +76,7 @@ cd $TESTDIR || \
zfs $mountcmd $TESTPOOL/$TESTFS zfs $mountcmd $TESTPOOL/$TESTFS
ret=$? ret=$?
if is_linux; then if is_linux || is_freebsd; then
(( ret == 0 )) || \ (( ret == 0 )) || \
log_fail "'zfs $mountcmd $TESTPOOL/$TESTFS' " \ log_fail "'zfs $mountcmd $TESTPOOL/$TESTFS' " \
"unexpected return code of $ret." "unexpected return code of $ret."
@ -85,7 +87,7 @@ else
fi fi
log_note "Make sure the filesystem $TESTPOOL/$TESTFS is unmounted" log_note "Make sure the filesystem $TESTPOOL/$TESTFS is unmounted"
if is_linux; then if is_linux || is_freebsd; then
mounted $TESTPOOL/$TESTFS || \ mounted $TESTPOOL/$TESTFS || \
log_fail Filesystem $TESTPOOL/$TESTFS is unmounted log_fail Filesystem $TESTPOOL/$TESTFS is unmounted
else else

View File

@ -123,7 +123,8 @@ for property in ${properties[@]}; do
# Set filesystem property temporarily # Set filesystem property temporarily
reverse_opt=$(get_reverse_option $fs $property) reverse_opt=$(get_reverse_option $fs $property)
log_must zfs mount -o remount,$reverse_opt $fs log_must zfs unmount $fs
log_must zfs mount -o $reverse_opt $fs
cur_val=$(get_prop $property $fs) cur_val=$(get_prop $property $fs)
(($? != 0)) && log_fail "get_prop $property $fs" (($? != 0)) && log_fail "get_prop $property $fs"
@ -135,7 +136,7 @@ for property in ${properties[@]}; do
"be enabled in LZ" "be enabled in LZ"
fi fi
elif [[ $orig_val == $cur_val ]]; then elif [[ $orig_val == $cur_val ]]; then
log_fail "zfs mount -o remount,$reverse_opt " \ log_fail "zfs mount -o $reverse_opt " \
"doesn't change property." "doesn't change property."
fi fi
@ -146,7 +147,7 @@ for property in ${properties[@]}; do
cur_val=$(get_prop $property $fs) cur_val=$(get_prop $property $fs)
(($? != 0)) && log_fail "get_prop $property $fs" (($? != 0)) && log_fail "get_prop $property $fs"
if [[ $orig_val != $cur_val ]]; then if [[ $orig_val != $cur_val ]]; then
log_fail "zfs mount -o remount,$reverse_opt " \ log_fail "zfs mount -o $reverse_opt " \
"change the property that is stored on disks" "change the property that is stored on disks"
fi fi
done done

View File

@ -65,7 +65,7 @@ mpt=$(get_prop mountpoint $fs)
log_must zfs umount $fs log_must zfs umount $fs
curpath=`dirname $0` curpath=`dirname $0`
cd $mpt cd $mpt
if is_linux; then if is_linux || is_freebsd; then
log_must zfs mount $fs log_must zfs mount $fs
else else
log_mustnot zfs mount $fs log_mustnot zfs mount $fs

View File

@ -18,7 +18,12 @@
# #
# DESCRIPTION: # DESCRIPTION:
# Verify that zfs mount should fail with a non-empty directory # Linux:
# Verify that zfs mount fails with a non-empty directory
# FreeSD:
# Verify that zfs mount succeeds with a non-empty directory
#
# #
# STRATEGY: # STRATEGY:
# 1. Unmount the dataset # 1. Unmount the dataset
@ -34,7 +39,13 @@
verify_runnable "both" verify_runnable "both"
log_assert "zfs mount fails with non-empty directory" if is_linux; then
behaves="fails"
else
behaves="succeeds"
fi
log_assert "zfs mount $behaves with non-empty directory"
fs=$TESTPOOL/$TESTFS fs=$TESTPOOL/$TESTFS
@ -44,7 +55,12 @@ log_must zfs set mountpoint=$TESTDIR $fs
log_must zfs mount $fs log_must zfs mount $fs
log_must zfs umount $fs log_must zfs umount $fs
log_must touch $TESTDIR/testfile.$$ log_must touch $TESTDIR/testfile.$$
log_mustnot zfs mount $fs if is_linux; then
log_mustnot zfs mount $fs
else
log_must zfs mount $fs
log_must zfs umount $fs
fi
log_must rm -rf $TESTDIR log_must rm -rf $TESTDIR
log_pass "zfs mount fails non-empty directory as expected." log_pass "zfs mount $behaves with non-empty directory as expected."

View File

@ -30,7 +30,8 @@
# 1. Create zfs filesystems # 1. Create zfs filesystems
# 2. Unmount a leaf filesystem # 2. Unmount a leaf filesystem
# 3. Create a file in the above filesystem's mountpoint # 3. Create a file in the above filesystem's mountpoint
# 4. Verify that 'zfs mount -a' fails to mount the above # 4. Verify that 'zfs mount -a' fails to mount the above if on Linux
# or succeeds if on FreeBSD
# 5. Verify that all other filesystems were mounted # 5. Verify that all other filesystems were mounted
# #
@ -82,15 +83,22 @@ done
# Create a stray file in one filesystem's mountpoint # Create a stray file in one filesystem's mountpoint
touch $path/0/strayfile touch $path/0/strayfile
# Verify that zfs mount -a fails # Verify that zfs mount -a fails on Linux or succeeds on FreeBSD
export __ZFS_POOL_RESTRICT="$TESTPOOL" export __ZFS_POOL_RESTRICT="$TESTPOOL"
log_mustnot zfs $mountall if is_linux; then
log_mustnot zfs $mountall
log_mustnot mounted "$TESTPOOL/0"
typeset behaved="failed"
else
log_must zfs $mountall
log_must mounted "$TESTPOOL/0"
typeset behaved="succeeded"
fi
unset __ZFS_POOL_RESTRICT unset __ZFS_POOL_RESTRICT
# All filesystems except for "0" should be mounted # All other filesystems should be mounted
log_mustnot mounted "$TESTPOOL/0"
for ((i=1; i<$fscount; i++)); do for ((i=1; i<$fscount; i++)); do
log_must mounted "$TESTPOOL/$i" log_must mounted "$TESTPOOL/$i"
done done
log_pass "'zfs $mountall' failed as expected." log_pass "'zfs $mountall' $behaved as expected."

View File

@ -53,6 +53,14 @@ function cleanup
return 0 return 0
} }
if is_freebsd; then
typeset RO="-t zfs -ur"
typeset RW="-t zfs -uw"
else
typeset RO="-o remount,ro"
typeset RW="-o remount,rw"
fi
# #
# Verify the $filesystem is mounted readonly # Verify the $filesystem is mounted readonly
# This is preferred over "log_mustnot touch $fs" because we actually want to # This is preferred over "log_mustnot touch $fs" because we actually want to
@ -76,8 +84,13 @@ function checkmount # dataset option
{ {
typeset dataset="$1" typeset dataset="$1"
typeset option="$2" typeset option="$2"
typeset options=""
options="$(awk -v ds="$dataset" '$1 == ds { print $4 }' /proc/mounts)" if is_freebsd; then
options=$(mount -p | awk -v ds="$dataset" '$1 == ds { print $4 }')
else
options=$(awk -v ds="$dataset" '$1 == ds { print $4 }' /proc/mounts)
fi
if [[ "$options" == '' ]]; then if [[ "$options" == '' ]]; then
log_fail "Dataset $dataset is not mounted" log_fail "Dataset $dataset is not mounted"
elif [[ ! -z "${options##*$option*}" ]]; then elif [[ ! -z "${options##*$option*}" ]]; then
@ -105,21 +118,23 @@ log_must mkdir -p $MNTPSNAP
# 2. Verify we can (re)mount the dataset readonly/read-write # 2. Verify we can (re)mount the dataset readonly/read-write
log_must touch $MNTPFS/file.dat log_must touch $MNTPFS/file.dat
checkmount $TESTFS 'rw' checkmount $TESTFS 'rw'
log_must mount -o remount,ro $TESTFS $MNTPFS log_must mount $RO $TESTFS $MNTPFS
readonlyfs $MNTPFS readonlyfs $MNTPFS
checkmount $TESTFS 'ro' checkmount $TESTFS 'ro'
log_must mount -o remount,rw $TESTFS $MNTPFS log_must mount $RW $TESTFS $MNTPFS
log_must touch $MNTPFS/file.dat log_must touch $MNTPFS/file.dat
checkmount $TESTFS 'rw' checkmount $TESTFS 'rw'
# 3. Verify we can (re)mount the snapshot readonly if is_linux; then
log_must mount -t zfs $TESTSNAP $MNTPSNAP # 3. Verify we can (re)mount the snapshot readonly
readonlyfs $MNTPSNAP log_must mount -t zfs $TESTSNAP $MNTPSNAP
checkmount $TESTSNAP 'ro' readonlyfs $MNTPSNAP
log_must mount -o remount,ro $TESTSNAP $MNTPSNAP checkmount $TESTSNAP 'ro'
readonlyfs $MNTPSNAP log_must mount $RO $TESTSNAP $MNTPSNAP
checkmount $TESTSNAP 'ro' readonlyfs $MNTPSNAP
log_must umount $MNTPSNAP checkmount $TESTSNAP 'ro'
log_must umount $MNTPSNAP
fi
# 4. Verify we can't remount a snapshot read-write # 4. Verify we can't remount a snapshot read-write
# The "mount -o rw" command will succeed but the snapshot is mounted readonly. # The "mount -o rw" command will succeed but the snapshot is mounted readonly.
@ -127,7 +142,7 @@ log_must umount $MNTPSNAP
log_must mount -t zfs -o rw $TESTSNAP $MNTPSNAP log_must mount -t zfs -o rw $TESTSNAP $MNTPSNAP
readonlyfs $MNTPSNAP readonlyfs $MNTPSNAP
checkmount $TESTSNAP 'ro' checkmount $TESTSNAP 'ro'
log_mustnot mount -o remount,rw $TESTSNAP $MNTPSNAP log_mustnot mount $RW $TESTSNAP $MNTPSNAP
readonlyfs $MNTPSNAP readonlyfs $MNTPSNAP
checkmount $TESTSNAP 'ro' checkmount $TESTSNAP 'ro'
log_must umount $MNTPSNAP log_must umount $MNTPSNAP
@ -138,7 +153,7 @@ log_must eval "echo 'password' | zfs create -o sync=disabled \
-o encryption=on -o keyformat=passphrase $TESTFS/crypt" -o encryption=on -o keyformat=passphrase $TESTFS/crypt"
CRYPT_MNTPFS="$(get_prop mountpoint $TESTFS/crypt)" CRYPT_MNTPFS="$(get_prop mountpoint $TESTFS/crypt)"
log_must touch $CRYPT_MNTPFS/file.dat log_must touch $CRYPT_MNTPFS/file.dat
log_must mount -o remount,ro $TESTFS/crypt $CRYPT_MNTPFS log_must mount $RO $TESTFS/crypt $CRYPT_MNTPFS
log_must umount -f $CRYPT_MNTPFS log_must umount -f $CRYPT_MNTPFS
zpool sync $TESTPOOL zpool sync $TESTPOOL
@ -149,7 +164,7 @@ log_must zpool import -o readonly=on $TESTPOOL
# 7. Verify we can't remount its filesystem read-write # 7. Verify we can't remount its filesystem read-write
readonlyfs $MNTPFS readonlyfs $MNTPFS
checkmount $TESTFS 'ro' checkmount $TESTFS 'ro'
log_mustnot mount -o remount,rw $MNTPFS log_mustnot mount $RW $MNTPFS
readonlyfs $MNTPFS readonlyfs $MNTPFS
checkmount $TESTFS 'ro' checkmount $TESTFS 'ro'

View File

@ -59,7 +59,12 @@ log_must mkfile 128k $FILENAME
log_must exec 9<> $FILENAME # open file log_must exec 9<> $FILENAME # open file
# 3. Lazy umount # 3. Lazy umount
log_must umount -l $MNTPFS if is_freebsd; then
# FreeBSD does not support lazy unmount
log_must umount $MNTPFS
else
log_must umount -l $MNTPFS
fi
if [ -f $FILENAME ]; then if [ -f $FILENAME ]; then
log_fail "Lazy unmount failed" log_fail "Lazy unmount failed"
fi fi

View File

@ -77,7 +77,7 @@ log_must eval "zfs send -w $snap1 | zfs receive $TESTPOOL/$TESTFS2"
log_must eval "echo $passphrase2 | zfs change-key $TESTPOOL/$TESTFS1" log_must eval "echo $passphrase2 | zfs change-key $TESTPOOL/$TESTFS1"
log_must eval "zfs send -w -i $snap1 $snap2 > $ibackup" log_must eval "zfs send -w -i $snap1 $snap2 > $ibackup"
typeset trunc_size=$(stat -c %s $ibackup) typeset trunc_size=$(stat_size $ibackup)
trunc_size=$(expr $trunc_size - 64) trunc_size=$(expr $trunc_size - 64)
log_must cp $ibackup $ibackup_trunc log_must cp $ibackup $ibackup_trunc
log_must truncate -s $trunc_size $ibackup_trunc log_must truncate -s $trunc_size $ibackup_trunc

View File

@ -76,8 +76,7 @@ function setup_snap_env
# mount it. Otherwise, only check if this ufs|ext file system # mount it. Otherwise, only check if this ufs|ext file system
# was mounted. # was mounted.
# #
log_must eval "echo "y" | \ log_must new_fs $ZVOL_DEVDIR/$VOL
newfs -v $ZVOL_DEVDIR/$VOL > /dev/null 2>&1"
[[ ! -d $TESTDIR1 ]] && log_must mkdir $TESTDIR1 [[ ! -d $TESTDIR1 ]] && log_must mkdir $TESTDIR1

View File

@ -89,7 +89,7 @@ test_pool ()
} }
test_pool $TESTPOOL test_pool $TESTPOOL
log_must truncate --size=1G $vdev log_must truncate -s 1G $vdev
log_must zpool create -o version=1 tmp_pool $vdev log_must zpool create -o version=1 tmp_pool $vdev
test_pool tmp_pool test_pool tmp_pool
log_must zpool destroy tmp_pool log_must zpool destroy tmp_pool

View File

@ -57,8 +57,8 @@ function write_compare_files # <sendfs> <recvfs> <offset>
# compare sparse files # compare sparse files
recvfile="$(get_prop mountpoint $recvfs)/data.bin" recvfile="$(get_prop mountpoint $recvfs)/data.bin"
log_must cmp $sendfile $recvfile $offset $offset log_must cmp $sendfile $recvfile $offset $offset
sendsz=$(stat -c '%s' $sendfile) sendsz=$(stat_size $sendfile)
recvsz=$(stat -c '%s' $recvfile) recvsz=$(stat_size $recvfile)
if [[ $sendsz -ne $recvsz ]]; then if [[ $sendsz -ne $recvsz ]]; then
log_fail "$sendfile ($sendsz) and $recvfile ($recvsz) differ." log_fail "$sendfile ($sendsz) and $recvfile ($recvsz) differ."
fi fi

View File

@ -46,7 +46,10 @@
verify_runnable "both" verify_runnable "both"
set -A dataset "$TESTPOOL" "$TESTPOOL/$TESTFS" "$TESTPOOL/$TESTVOL" set -A dataset "$TESTPOOL" "$TESTPOOL/$TESTFS" "$TESTPOOL/$TESTVOL"
set -A values "on" "off" "fletcher2" "fletcher4" "sha256" "sha512" "skein" "edonr" "noparity" set -A values "on" "off" "fletcher2" "fletcher4" "sha256" "sha512" "skein" "noparity"
if is_linux; then
values+=("edonr")
fi
log_assert "Setting a valid checksum on a file system, volume," \ log_assert "Setting a valid checksum on a file system, volume," \
"it should be successful." "it should be successful."

View File

@ -76,6 +76,14 @@ if is_linux; then
if [[ $(linux_version) -lt $(linux_version "4.4") ]]; then if [[ $(linux_version) -lt $(linux_version "4.4") ]]; then
args+=("mand" "nomand") args+=("mand" "nomand")
fi fi
elif is_freebsd; then
# 'xattr' and 'devices' are not supported on FreeBSD
# Perhaps more options need to be added.
set -A args \
"noexec" "exec" \
"ro" "rw" \
"nosuid" "suid" \
"atime" "noatime"
else else
set -A args \ set -A args \
"devices" "/devices/" "nodevices" "/nodevices/" \ "devices" "/devices/" "nodevices" "/nodevices/" \
@ -96,11 +104,11 @@ log_must zfs set mountpoint=legacy $testfs
typeset i=0 typeset i=0
while ((i < ${#args[@]})); do while ((i < ${#args[@]})); do
if is_linux; then if is_linux || is_freebsd; then
log_must mount -t zfs -o ${args[$i]} $testfs $tmpmnt log_must mount -t zfs -o ${args[$i]} $testfs $tmpmnt
msg=$(mount | grep "$tmpmnt ") msg=$(mount | grep "$tmpmnt ")
echo $msg | grep "${args[((i))]}" > /dev/null 2>&1 echo $msg | grep "${args[((i))]}" > /dev/null 2>&1
if (($? != 0)) ; then if (($? != 0)) ; then
echo $msg | grep "${args[((i-1))]}" > /dev/null 2>&1 echo $msg | grep "${args[((i-1))]}" > /dev/null 2>&1

View File

@ -51,7 +51,12 @@ function cleanup
log_onexit cleanup log_onexit cleanup
set -A props "atime" "readonly" "setuid" "zoned" set -A props "atime" "readonly" "setuid"
if is_freebsd; then
props+=("jailed")
else
props+=("zoned")
fi
set -A values "on" "off" set -A values "on" "off"
if is_global_zone ; then if is_global_zone ; then

View File

@ -113,7 +113,7 @@ function verify_readonly # $1 dataset, $2 on|off
fi fi
;; ;;
volume) volume)
$expect eval "echo 'y' | newfs \ $expect eval "new_fs \
${ZVOL_DEVDIR}/$dataset > /dev/null 2>&1" ${ZVOL_DEVDIR}/$dataset > /dev/null 2>&1"
;; ;;
*) *)

View File

@ -64,7 +64,14 @@ log_must zfs create -o encryption=on -o keyformat=passphrase \
-o keylocation=file:///$TESTPOOL/pkey $TESTPOOL/$TESTFS1 -o keylocation=file:///$TESTPOOL/pkey $TESTPOOL/$TESTFS1
log_mustnot zfs set keylocation=none $TESTPOOL/$TESTFS1 log_mustnot zfs set keylocation=none $TESTPOOL/$TESTFS1
log_mustnot zfs set keylocation=/$TESTPOOL/pkey $TESTPOOL/$TESTFS1 if is_linux; then
log_mustnot zfs set keylocation=/$TESTPOOL/pkey $TESTPOOL/$TESTFS1
else
# file:///$TESTPOOL/pkey and /$TESTPOOL/pkey are equivalent on FreeBSD
# thanks to libfetch. Eventually we want to make the other platforms
# work this way as well, either by porting libfetch or by other means.
log_must zfs set keylocation=/$TESTPOOL/pkey $TESTPOOL/$TESTFS1
fi
log_must zfs set keylocation=file:///$TESTPOOL/pkey $TESTPOOL/$TESTFS1 log_must zfs set keylocation=file:///$TESTPOOL/pkey $TESTPOOL/$TESTFS1
log_must verify_keylocation $TESTPOOL/$TESTFS1 "file:///$TESTPOOL/pkey" log_must verify_keylocation $TESTPOOL/$TESTFS1 "file:///$TESTPOOL/pkey"

View File

@ -27,4 +27,8 @@
. $STF_SUITE/include/libtest.shlib . $STF_SUITE/include/libtest.shlib
if ! is_linux ; then
log_unsupported "sysfs is linux-only"
fi
default_cleanup default_cleanup

View File

@ -27,6 +27,10 @@
. $STF_SUITE/include/libtest.shlib . $STF_SUITE/include/libtest.shlib
if ! is_linux ; then
log_unsupported "sysfs is linux-only"
fi
DISK=${DISKS%% *} DISK=${DISKS%% *}
default_container_volume_setup $DISK default_container_volume_setup $DISK

View File

@ -133,7 +133,7 @@ done
# Testing legacy mounted filesystem # Testing legacy mounted filesystem
log_must zfs set mountpoint=legacy $fs1 log_must zfs set mountpoint=legacy $fs1
if is_linux; then if is_linux || is_freebsd; then
log_must mount -t zfs $fs1 /tmp/$dir log_must mount -t zfs $fs1 /tmp/$dir
else else
log_must mount -F zfs $fs1 /tmp/$dir log_must mount -F zfs $fs1 /tmp/$dir

View File

@ -90,6 +90,10 @@ if is_linux; then
echo "$corepath/core.zpool" >/proc/sys/kernel/core_pattern echo "$corepath/core.zpool" >/proc/sys/kernel/core_pattern
echo 0 >/proc/sys/kernel/core_uses_pid echo 0 >/proc/sys/kernel/core_uses_pid
export ASAN_OPTIONS="abort_on_error=1:disable_coredump=0" export ASAN_OPTIONS="abort_on_error=1:disable_coredump=0"
elif is_freebsd; then
ulimit -c unlimited
log_must sysctl kern.corefile=$corepath/core.zpool
export ASAN_OPTIONS="abort_on_error=1:disable_coredump=0"
else else
coreadm -p ${corepath}/core.%f coreadm -p ${corepath}/core.%f
fi fi

View File

@ -65,6 +65,10 @@ if is_linux; then
echo "core" >/proc/sys/kernel/core_pattern echo "core" >/proc/sys/kernel/core_pattern
echo 0 >/proc/sys/kernel/core_uses_pid echo 0 >/proc/sys/kernel/core_uses_pid
export ASAN_OPTIONS="abort_on_error=1:disable_coredump=0" export ASAN_OPTIONS="abort_on_error=1:disable_coredump=0"
elif is_freebsd; then
ulimit -c unlimited
log_must sysctl kern.corefile=$corepath/core.zpool
export ASAN_OPTIONS="abort_on_error=1:disable_coredump=0"
fi fi
ZFS_ABORT=1; export ZFS_ABORT ZFS_ABORT=1; export ZFS_ABORT

View File

@ -77,7 +77,7 @@ do
for cmdval in ${ashifts[@]} for cmdval in ${ashifts[@]}
do do
log_must zpool create -o ashift=$ashift $TESTPOOL $disk1 log_must zpool create -o ashift=$ashift $TESTPOOL $disk1
log_must zpool add $TESTPOOL -o ashift=$cmdval $disk2 log_must zpool add -o ashift=$cmdval $TESTPOOL $disk2
verify_ashift $disk2 $cmdval verify_ashift $disk2 $cmdval
if [[ $? -ne 0 ]] if [[ $? -ne 0 ]]
then then

View File

@ -63,7 +63,7 @@ set_disks
export SIZE="$(((MINVDEVSIZE / (1024 * 1024)) * 2))m" export SIZE="$(((MINVDEVSIZE / (1024 * 1024)) * 2))m"
if is_linux; then if is_linux || is_freebsd; then
set_device_dir set_device_dir
set_slice_prefix set_slice_prefix
export SLICE0=1 export SLICE0=1

View File

@ -40,7 +40,7 @@ function find_vfstab_dev
typeset vfstabdevs="" typeset vfstabdevs=""
typeset line typeset line
if is_linux; then if is_freebsd || is_linux; then
vfstab="/etc/fstab" vfstab="/etc/fstab"
tmpfile="$TEST_BASE_DIR/fstab.tmp" tmpfile="$TEST_BASE_DIR/fstab.tmp"
else else
@ -69,7 +69,12 @@ function find_mnttab_dev
typeset mnttabdevs="" typeset mnttabdevs=""
typeset line typeset line
if is_linux; then if is_freebsd; then
# FreeBSD doesn't have a mnttab file.
mount -p | awk -v dir="^${DEV_DSKDIR}" \
'$1 ~ dir { print $1 }' | xargs
return 0
elif is_linux; then
typeset mnttab="/etc/mtab" typeset mnttab="/etc/mtab"
typeset tmpfile="$TEST_BASE_DIR/mtab.tmp" typeset tmpfile="$TEST_BASE_DIR/mtab.tmp"
else else
@ -97,7 +102,9 @@ function save_dump_dev
typeset dumpdev typeset dumpdev
if is_linux; then if is_freebsd; then
dumpdev=$(dumpon -l)
elif is_linux; then
dumpdev="" dumpdev=""
else else
typeset fnd="Dump device" typeset fnd="Dump device"

View File

@ -56,7 +56,11 @@ function cleanup
destroy_pool "$TESTPOOL1" destroy_pool "$TESTPOOL1"
if [[ -n $saved_dump_dev ]]; then if [[ -n $saved_dump_dev ]]; then
log_must eval "dumpadm -u -d $saved_dump_dev > /dev/null" if is_freebsd; then
log_must eval "dumpon $saved_dump_dev > /dev/null"
else
log_must eval "dumpadm -u -d $saved_dump_dev > /dev/null"
fi
fi fi
partition_cleanup partition_cleanup
@ -87,8 +91,12 @@ else
fi fi
if ! is_linux; then if ! is_linux; then
log_must echo "y" | newfs ${DEV_DSKDIR}/$dump_dev > /dev/null 2>&1 log_must eval "new_fs ${DEV_DSKDIR}/$dump_dev > /dev/null 2>&1"
log_must dumpadm -u -d ${DEV_DSKDIR}/$dump_dev > /dev/null if is_freebsd; then
log_must eval "dumpon ${DEV_DSKDIR}/$dump_dev > /dev/null"
else
log_must eval "dumpadm -u -d ${DEV_DSKDIR}/$dump_dev > /dev/null"
fi
log_mustnot zpool add -f "$TESTPOOL" $dump_dev log_mustnot zpool add -f "$TESTPOOL" $dump_dev
fi fi

View File

@ -74,9 +74,7 @@ function create_blockfile
log_must mkdir -p $dir log_must mkdir -p $dir
fi fi
echo "y" | newfs ${DEV_RDSKDIR}/$disk >/dev/null 2>&1 log_must eval "new_fs ${DEV_RDSKDIR}/$disk >/dev/null 2>&1"
(( $? != 0 )) &&
log_fail "Create file system fail."
log_must mount ${DEV_DSKDIR}/$disk $dir log_must mount ${DEV_DSKDIR}/$disk $dir
log_must truncate -s $size $file log_must truncate -s $size $file
@ -125,7 +123,7 @@ function find_vfstab_dev
typeset vfstabdevs="" typeset vfstabdevs=""
typeset line typeset line
if is_linux; then if is_freebsd || is_linux; then
vfstab="/etc/fstab" vfstab="/etc/fstab"
tmpfile="$TEST_BASE_DIR/fstab.tmp" tmpfile="$TEST_BASE_DIR/fstab.tmp"
else else
@ -152,7 +150,9 @@ function save_dump_dev
{ {
typeset dumpdev typeset dumpdev
if is_linux; then if is_freebsd; then
dumpdev=$(dumpon -l)
elif is_linux; then
dumpdev="" dumpdev=""
else else
typeset fnd="Dump device" typeset fnd="Dump device"

View File

@ -76,8 +76,8 @@ else
disk=$DISK0 disk=$DISK0
fi fi
create_pool "$TESTPOOL" "${disk}${SLICE_PREFIX}${SLICE0}" create_pool "$TESTPOOL" "${disk}${SLICE_PREFIX}${SLICE0}"
log_must echo "y" | newfs \ log_must eval "new_fs \
${DEV_RDSKDIR}/${disk}${SLICE_PREFIX}${SLICE1} >/dev/null 2>&1 ${DEV_RDSKDIR}/${disk}${SLICE_PREFIX}${SLICE1} >/dev/null 2>&1"
create_blockfile $FILESIZE $TESTDIR0/$FILEDISK0 ${disk}${SLICE_PREFIX}${SLICE4} create_blockfile $FILESIZE $TESTDIR0/$FILEDISK0 ${disk}${SLICE_PREFIX}${SLICE4}
create_blockfile $FILESIZE1 $TESTDIR1/$FILEDISK1 ${disk}${SLICE_PREFIX}${SLICE5} create_blockfile $FILESIZE1 $TESTDIR1/$FILEDISK1 ${disk}${SLICE_PREFIX}${SLICE5}
log_must truncate -s $SIZE $TEST_BASE_DIR/$FILEDISK0 log_must truncate -s $SIZE $TEST_BASE_DIR/$FILEDISK0

View File

@ -55,7 +55,11 @@ function cleanup
done done
if [[ -n $saved_dump_dev ]]; then if [[ -n $saved_dump_dev ]]; then
log_must dumpadm -u -d $saved_dump_dev if is_freebsd; then
log_must dumpon $saved_dump_dev
else
log_must dumpadm -u -d $saved_dump_dev
fi
fi fi
partition_disk $SIZE $disk 7 partition_disk $SIZE $disk 7
@ -128,7 +132,11 @@ if ! is_linux; then
log_must zpool create -f $TESTPOOL3 $disk log_must zpool create -f $TESTPOOL3 $disk
log_must zpool destroy -f $TESTPOOL3 log_must zpool destroy -f $TESTPOOL3
log_must dumpadm -d ${DEV_DSKDIR}/$specified_dump_dev if is_freebsd; then
log_must dumpon ${DEV_DSKDIR}/$specified_dump_dev
else
log_must dumpadm -d ${DEV_DSKDIR}/$specified_dump_dev
fi
log_mustnot zpool create -f $TESTPOOL1 "$specified_dump_dev" log_mustnot zpool create -f $TESTPOOL1 "$specified_dump_dev"
# Also check to see that in-use checking prevents us from creating # Also check to see that in-use checking prevents us from creating

View File

@ -82,7 +82,7 @@ typeset TMP_FILE=$mntp/tmpfile.$$
create_pool $TESTPOOL $pool_dev create_pool $TESTPOOL $pool_dev
log_must zfs create -V 100m $vol_name log_must zfs create -V 100m $vol_name
block_device_wait block_device_wait
log_must echo "y" | newfs ${ZVOL_DEVDIR}/$vol_name > /dev/null 2>&1 log_must eval "new_fs ${ZVOL_DEVDIR}/$vol_name > /dev/null 2>&1"
log_must mount ${ZVOL_DEVDIR}/$vol_name $mntp log_must mount ${ZVOL_DEVDIR}/$vol_name $mntp
log_must mkfile 50m $TMP_FILE log_must mkfile 50m $TMP_FILE

View File

@ -82,8 +82,7 @@ typeset -a properties=(
"feature@log_spacemap" "feature@log_spacemap"
) )
# Additional properties added for Linux. if is_linux || is_freebsd; then
if is_linux; then
properties+=( properties+=(
"ashift" "ashift"
"feature@large_dnode" "feature@large_dnode"

View File

@ -47,7 +47,7 @@ done
typeset -i i=0 typeset -i i=0
while (( i <= $GROUP_NUM )); do while (( i <= $GROUP_NUM )); do
if ! is_linux; then if ! is_linux && ! is_freebsd; then
if (( i == 2 )); then if (( i == 2 )); then
(( i = i + 1 )) (( i = i + 1 ))
continue continue

View File

@ -62,6 +62,13 @@ case "${#disk_array[*]}" in
else else
log_fail "$ZFS_DISK1 not supported for partitioning." log_fail "$ZFS_DISK1 not supported for partitioning."
fi fi
elif is_freebsd; then
SLICE_PREFIX="p"
PRIMARY_SLICE=1
DISK_COUNT=1
ZFS_DISK1=${disk_array[0]}
ZFS_DISK2=${disk_array[0]}
ZFSSIDE_DISK1=${ZFS_DISK1}p1
else else
export DEV_DSKDIR="/dev" export DEV_DSKDIR="/dev"
PRIMARY_SLICE=2 PRIMARY_SLICE=2
@ -93,6 +100,12 @@ case "${#disk_array[*]}" in
log_fail "$ZFS_DISK1 not supported for partitioning." log_fail "$ZFS_DISK1 not supported for partitioning."
fi fi
ZFS_DISK2=${disk_array[1]} ZFS_DISK2=${disk_array[1]}
elif is_freebsd; then
SLICE_PREFIX="p"
PRIMARY_SLICE=1
DISK_COUNT=2
ZFS_DISK1=${disk_array[0]}
ZFSSIDE_DISK1=${ZFS_DISK1}p1
else else
export DEV_DSKDIR="/dev" export DEV_DSKDIR="/dev"
PRIMARY_SLICE=2 PRIMARY_SLICE=2

View File

@ -16,6 +16,13 @@
. $STF_SUITE/include/libtest.shlib . $STF_SUITE/include/libtest.shlib
typeset disks=(${DISKS[*]}) typeset disks=(${DISKS[*]})
typeset disk1=${disks[0]}
typeset disk2=${disks[1]} if is_freebsd; then
typeset disk3=${disks[2]} typeset disk1=/dev/${disks[0]}
typeset disk2=/dev/${disks[1]}
typeset disk3=/dev/${disks[2]}
else
typeset disk1=${disks[0]}
typeset disk2=${disks[1]}
typeset disk3=${disks[2]}
fi

View File

@ -34,7 +34,7 @@
verify_runnable "global" verify_runnable "global"
if ! $(is_physical_device $DISKS) ; then if ! is_physical_device $DISKS ; then
log_unsupported "This directory cannot be run on raw files." log_unsupported "This directory cannot be run on raw files."
fi fi

View File

@ -20,6 +20,10 @@
verify_runnable "global" verify_runnable "global"
if ! is_linux; then
log_unsupported "scsi debug module unsupported"
fi
cleanup_devices $DISKS cleanup_devices $DISKS
# Unplug the disk and remove scsi_debug module # Unplug the disk and remove scsi_debug module

View File

@ -125,7 +125,7 @@ do
add_config="$(awk '{$1= "";print $0}' <<< $config)" add_config="$(awk '{$1= "";print $0}' <<< $config)"
log_must zpool create $TESTPOOL $(pool_config $create_config) log_must zpool create $TESTPOOL $(pool_config $create_config)
for vdev in $add_config; do for vdev in $add_config; do
log_must zpool add $TESTPOOL -f $(pool_config $vdev) log_must zpool add -f $TESTPOOL $(pool_config $vdev)
done done
log_must zpool split -R $altroot $TESTPOOL $TESTPOOL2 log_must zpool split -R $altroot $TESTPOOL $TESTPOOL2
log_must poolexists $TESTPOOL2 log_must poolexists $TESTPOOL2
@ -140,7 +140,7 @@ do
add_config="$(awk '{$1= "";print $0}' <<< $config)" add_config="$(awk '{$1= "";print $0}' <<< $config)"
log_must zpool create $TESTPOOL $(pool_config $create_config) log_must zpool create $TESTPOOL $(pool_config $create_config)
for vdev in $add_config; do for vdev in $add_config; do
log_must zpool add $TESTPOOL -f $(pool_config $vdev) log_must zpool add -f $TESTPOOL $(pool_config $vdev)
done done
log_mustnot zpool split -R $altroot $TESTPOOL $TESTPOOL2 log_mustnot zpool split -R $altroot $TESTPOOL $TESTPOOL2
log_mustnot poolexists $TESTPOOL2 log_mustnot poolexists $TESTPOOL2

View File

@ -54,6 +54,32 @@ if is_linux; then
off /tmp/zfstest 100M off \ off /tmp/zfstest 100M off \
512 10m off \ 512 10m off \
hidden" hidden"
elif is_freebsd; then
PROP_NAMES="\
acltype atime \
checksum compression devices \
exec mountpoint quota readonly \
recordsize reservation setuid \
snapdir"
# these are a set of values we apply, for use when testing the
# zfs get/set subcommands - ordered as per the list above so we
# can iterate over both sets in an array
PROP_VALS="\
posixacl on \
fletcher2 on on \
on legacy none on \
128K none on \
visible"
# these are an alternate set of property values
PROP_ALTVALS="\
noacl off \
fletcher4 lzjb off \
off /tmp/zfstest 100M off \
512 10m off \
hidden"
else else
# these are the set of setable ZFS properties # these are the set of setable ZFS properties
PROP_NAMES="\ PROP_NAMES="\

View File

@ -45,7 +45,7 @@
verify_runnable "global" verify_runnable "global"
if is_linux; then if is_linux || is_freebsd; then
log_unsupported "Requires additional dependencies" log_unsupported "Requires additional dependencies"
fi fi

View File

@ -45,7 +45,7 @@
verify_runnable "global" verify_runnable "global"
if is_linux; then if is_linux || is_freebsd; then
log_unsupported "Requires additional dependencies" log_unsupported "Requires additional dependencies"
fi fi

View File

@ -31,7 +31,9 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifndef __FreeBSD__
#include <sys/xattr.h> #include <sys/xattr.h>
#endif
#include <utime.h> #include <utime.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -251,6 +253,7 @@ do_chown(const char *pfile)
return (ret); return (ret);
} }
#ifndef __FreeBSD__
static int static int
do_xattr(const char *pfile) do_xattr(const char *pfile)
{ {
@ -268,6 +271,7 @@ do_xattr(const char *pfile)
} }
return (ret); return (ret);
} }
#endif
static void static void
cleanup(void) cleanup(void)
@ -289,7 +293,9 @@ static timetest_t timetest_table[] = {
{ ST_CTIME, "st_ctime", do_chown }, { ST_CTIME, "st_ctime", do_chown },
{ ST_CTIME, "st_ctime", do_link }, { ST_CTIME, "st_ctime", do_link },
{ ST_CTIME, "st_ctime", do_utime }, { ST_CTIME, "st_ctime", do_utime },
#ifndef __FreeBSD__
{ ST_CTIME, "st_ctime", do_xattr }, { ST_CTIME, "st_ctime", do_xattr },
#endif
}; };
#define NCOMMAND (sizeof (timetest_table) / sizeof (timetest_table[0])) #define NCOMMAND (sizeof (timetest_table) / sizeof (timetest_table[0]))

View File

@ -43,6 +43,10 @@ if ! is_linux; then
fi fi
fi fi
if is_freebsd; then
log_must sysctl vfs.usermount=0
fi
if is_linux; then if is_linux; then
log_must set_tunable64 zfs_admin_snapshot 0 log_must set_tunable64 zfs_admin_snapshot 0
fi fi

View File

@ -483,6 +483,7 @@ function verify_userprop
typeset stamp=${perm}.${user}.$(date +'%F-%T-%N') typeset stamp=${perm}.${user}.$(date +'%F-%T-%N')
user_run $user zfs set "$user:ts=$stamp" $dtst user_run $user zfs set "$user:ts=$stamp" $dtst
zpool sync ${dtst%%/*}
if [[ $stamp != $(get_prop "$user:ts" $dtst) ]]; then if [[ $stamp != $(get_prop "$user:ts" $dtst) ]]; then
return 1 return 1
fi fi
@ -684,7 +685,7 @@ function verify_fs_destroy
# Verify that given the correct delegation, a regular user can: # Verify that given the correct delegation, a regular user can:
# Take a snapshot of an unmounted dataset # Take a snapshot of an unmounted dataset
# Take a snapshot of an mounted dataset # Take a snapshot of a mounted dataset
# Create a snapshot by making a directory in the .zfs/snapshot directory # Create a snapshot by making a directory in the .zfs/snapshot directory
function verify_fs_snapshot function verify_fs_snapshot
{ {
@ -716,12 +717,15 @@ function verify_fs_snapshot
fi fi
log_must zfs destroy $snap log_must zfs destroy $snap
typeset snapdir=${mntpt}/.zfs/snapshot/snap.$stamp # Creating snaps via mkdir is not supported on FreeBSD
user_run $user mkdir $snapdir if ! is_freebsd; then
if ! datasetexists $snap ; then typeset snapdir=${mntpt}/.zfs/snapshot/snap.$stamp
return 1 user_run $user mkdir $snapdir
if ! datasetexists $snap ; then
return 1
fi
log_must zfs destroy $snap
fi fi
log_must zfs destroy $snap
return 0 return 0
} }

View File

@ -44,6 +44,11 @@ if ! is_linux; then
fi fi
fi fi
if is_freebsd; then
# To pass user mount tests
log_must sysctl vfs.usermount=1
fi
cleanup_user_group cleanup_user_group
# Create staff group and add two user to it # Create staff group and add two user to it

View File

@ -83,7 +83,7 @@ if ! cat /etc/group | awk -F: '{print $1}' | \
grep -w 'everyone' > /dev/null 2>&1 grep -w 'everyone' > /dev/null 2>&1
then then
group_added="TRUE" group_added="TRUE"
log_must groupadd everyone log_must add_group everyone
fi fi
for dtst in $DATASETS ; do for dtst in $DATASETS ; do
@ -92,7 +92,7 @@ for dtst in $DATASETS ; do
done done
log_must restore_root_datasets log_must restore_root_datasets
if [[ $group_added == "TRUE" ]]; then if [[ $group_added == "TRUE" ]]; then
log_must groupdel everyone log_must del_group everyone
fi fi
log_pass "everyone is always interpreted as keyword passed." log_pass "everyone is always interpreted as keyword passed."

View File

@ -87,6 +87,47 @@ set -A perms create true false \
promote true true \ promote true true \
xattr true false \ xattr true false \
receive true false receive true false
elif is_freebsd; then
# Results in Results in
# Permission Filesystem Volume
#
# Removed for FreeBSD
# - zoned - zones are not supported
# - sharenfs - sharing requires superuser privileges
# - share - sharing requires superuser privileges
# - xattr - Not supported on FreeBSD
#
set -A perms create true false \
snapshot true true \
mount true false \
send true true \
allow true true \
quota true false \
reservation true true \
dnodesize true false \
recordsize true false \
mountpoint true false \
checksum true true \
compression true true \
canmount true false \
atime true false \
devices true false \
exec true false \
volsize false true \
setuid true false \
readonly true true \
snapdir true false \
userprop true true \
aclmode true false \
aclinherit true false \
rollback true true \
clone true true \
rename true true \
promote true true \
receive true false \
destroy true true
else else
set -A perms create true false \ set -A perms create true false \

View File

@ -61,6 +61,12 @@ set -A perms create snapshot mount send allow quota reservation \
devices exec volsize setuid readonly snapdir userprop \ devices exec volsize setuid readonly snapdir userprop \
rollback clone rename promote dnodesize \ rollback clone rename promote dnodesize \
zoned xattr receive destroy zoned xattr receive destroy
elif is_freebsd; then
set -A perms create snapshot mount send allow quota reservation \
recordsize mountpoint checksum compression canmount atime \
devices exec volsize setuid readonly snapdir userprop \
aclmode aclinherit rollback clone rename promote dnodesize \
zoned receive destroy
else else
set -A perms create snapshot mount send allow quota reservation \ set -A perms create snapshot mount send allow quota reservation \
recordsize mountpoint checksum compression canmount atime \ recordsize mountpoint checksum compression canmount atime \

View File

@ -42,83 +42,190 @@ function create_dev_file
typeset filetype=$1 typeset filetype=$1
typeset filename=$2 typeset filename=$2
case $(uname) in
FreeBSD)
create_dev_file_freebsd "$filetype" "$filename"
;;
Linux)
create_dev_file_linux "$filetype" "$filename"
;;
*)
create_dev_file_illumos "$filetype" "$filename"
;;
esac
return 0
}
function create_dev_file_freebsd
{
typeset filetype=$1
typeset filename=$2
case $filetype in case $filetype in
b) b)
if is_linux; then devtype=$(df -T / | grep -v "Type" | awk '{print $2}')
major=$(awk '/[hsv]d/ { print $1; exit }' \ case $devtype in
/proc/partitions) zfs)
minor=$(awk '/[hsv]d/ { print $2; exit }' \ rootpool=$(df / | grep -v "Filesystem" | \
/proc/partitions) awk '{print $2}')
log_must mknod $filename b $major $minor rootpool=${rootpool#\(}
return 0 rootpool=${rootpool%%/*}
fi
devtype=$(df -n / | awk '{print $3}') devstr=$(get_disklist $rootpool)
case $devtype in devstr=$(echo "$devstr" | \
zfs) awk '{print $1}')
rootpool=$(df / | \ [[ -z $devstr ]] && \
awk '{print $2}') log_fail "Can not get block device file."
rootpool=${rootpool#\(} devstr=/dev/${devstr}
rootpool=${rootpool%%/*}
devstr=$(get_disklist $rootpool)
devstr=$(echo "$devstr" | \
awk '{print $1}')
[[ -z $devstr ]] && \
log_fail "Can not get block device file."
devstr=$DEV_DSKDIR/${devstr}
;;
ufs)
#
# Get the existing block device file in current system.
# And bring out the first one.
#
devstr=$(df-lhF ufs | \
grep "^${DEV_DSKDIR}" | \
awk '{print $1}')
devstr=$(echo "$devstr" | \
awk '{print $1}')
[[ -z $devstr ]] && \
log_fail "Can not get block device file."
;;
*)
log_unsupported "Unsupported fstype " \
"for / ($devtype)," \
"only ufs|zfs is supported."
;;
esac
#
# Get the device file information. i.e:
# $DEV_DSKDIR/c0t0d0s0: block special (28/768)
#
devstr=$(file $devstr)
#
# Bring out major and minor number.
#
major=${devstr##*\(}
major=${major%%/*}
minor=${devstr##*/}
minor=${minor%\)}
log_must mknod $filename b $major $minor
;; ;;
c) ufs)
# #
# Create device file '/dev/null' # Get the existing block device file in current system.
# # And bring out the first one.
if is_linux; then #
major=$(stat -c %t /dev/null) devstr=$(df -t ufs | \
minor=$(stat -c %T /dev/null) grep "^/dev/" | \
log_must mknod $filename c $major $minor head -n 1 | \
else awk '{print $1}')
log_must mknod $filename c $(getmajor mm) 2 devstr=$(echo "$devstr" | \
fi awk '{print $1}')
[[ -z $devstr ]] && \
log_fail "Can not get block device file."
;; ;;
*) *)
log_fail "'$filetype' is wrong." log_unsupported "Unsupported fstype " \
"for / ($devtype)," \
"only ufs|zfs is supported."
;; ;;
esac
#
# Get the device file information. i.e:
# /dev/c0t0d0s0: block special (28/768)
#
devstr=$(file $devstr)
#
# Bring out major and minor number.
#
major=${devstr##*\(}
major=${major%%/*}
minor=${devstr##*/}
minor=${minor%\)}
log_must mknod $filename b $major $minor
;;
c)
#
# Create device file '/dev/null'
#
log_must mknod $filename c 13 2
;;
*)
log_fail "'$filetype' is wrong."
;;
esac
return 0
}
function create_dev_file_illumos
{
typeset filetype=$1
typeset filename=$2
case $filetype in
b)
devtype=$(df -n / | awk '{print $3}')
case $devtype in
zfs)
rootpool=$(df / | \
awk '{print $2}')
rootpool=${rootpool#\(}
rootpool=${rootpool%%/*}
devstr=$(get_disklist $rootpool)
devstr=$(echo "$devstr" | \
awk '{print $1}')
[[ -z $devstr ]] && \
log_fail "Can not get block device file."
devstr=$DEV_DSKDIR/${devstr}
;;
ufs)
#
# Get the existing block device file in current system.
# And bring out the first one.
#
devstr=$(df-lhF ufs | \
grep "^${DEV_DSKDIR}" | \
awk '{print $1}')
devstr=$(echo "$devstr" | \
awk '{print $1}')
[[ -z $devstr ]] && \
log_fail "Can not get block device file."
;;
*)
log_unsupported "Unsupported fstype " \
"for / ($devtype)," \
"only ufs|zfs is supported."
;;
esac
#
# Get the device file information. i.e:
# $DEV_DSKDIR/c0t0d0s0: block special (28/768)
#
devstr=$(file $devstr)
#
# Bring out major and minor number.
#
major=${devstr##*\(}
major=${major%%/*}
minor=${devstr##*/}
minor=${minor%\)}
log_must mknod $filename b $major $minor
;;
c)
#
# Create device file '/dev/null'
#
log_must mknod $filename c $(getmajor mm) 2
;;
*)
log_fail "'$filetype' is wrong."
;;
esac
return 0
}
create_dev_file_linux
{
typeset filetype=$1
typeset filename=$2
case $filetype in
b)
major=$(awk '/[hsv]d/ { print $1; exit }' \
/proc/partitions)
minor=$(awk '/[hsv]d/ { print $2; exit }' \
/proc/partitions)
log_must mknod $filename b $major $minor
;;
c)
#
# Create device file '/dev/null'
#
major=$(stat -c %t /dev/null)
minor=$(stat -c %T /dev/null)
log_must mknod $filename c $major $minor
;;
*)
log_fail "'$filetype' is wrong."
;;
esac esac
return 0 return 0

View File

@ -50,8 +50,11 @@ log_assert "Testing automated auto-spare FMA test"
log_onexit cleanup log_onexit cleanup
# Clear events from previous runs # Events not supported on FreeBSD
zed_events_drain if ! is_freebsd; then
# Clear events from previous runs
zed_events_drain
fi
TESTFILE="/$TESTPOOL/$TESTFS/testfile" TESTFILE="/$TESTPOOL/$TESTFS/testfile"

View File

@ -53,8 +53,11 @@ function cleanup
log_assert "ZED should be able to handle multiple faulted devices" log_assert "ZED should be able to handle multiple faulted devices"
log_onexit cleanup log_onexit cleanup
# Clear events from previous runs # Events not supported on FreeBSD
zed_events_drain if ! is_freebsd; then
# Clear events from previous runs
zed_events_drain
fi
FAULT_DEV1="$TEST_BASE_DIR/fault-dev1" FAULT_DEV1="$TEST_BASE_DIR/fault-dev1"
FAULT_DEV2="$TEST_BASE_DIR/fault-dev2" FAULT_DEV2="$TEST_BASE_DIR/fault-dev2"

View File

@ -31,9 +31,15 @@
log_assert "Testing that injected decompression errors are handled correctly" log_assert "Testing that injected decompression errors are handled correctly"
if is_freebsd; then
COMPRESSION=compressed_arc_enabled
else
COMPRESSION=zfs_compressed_arc_enabled
fi
function cleanup function cleanup
{ {
log_must set_tunable64 zfs_compressed_arc_enabled 1 log_must set_tunable64 $COMPRESSION 1
log_must zinject -c all log_must zinject -c all
default_cleanup_noexit default_cleanup_noexit
} }
@ -41,15 +47,18 @@ function cleanup
log_onexit cleanup log_onexit cleanup
default_mirror_setup_noexit $DISK1 $DISK2 default_mirror_setup_noexit $DISK1 $DISK2
log_must set_tunable64 zfs_compressed_arc_enabled 0 log_must set_tunable64 $COMPRESSION 0
log_must zfs create -o compression=on $TESTPOOL/fs log_must zfs create -o compression=on $TESTPOOL/fs
mntpt=$(get_prop mountpoint $TESTPOOL/fs) mntpt=$(get_prop mountpoint $TESTPOOL/fs)
write_compressible $mntpt 32m 1 0 "testfile" write_compressible $mntpt 32m 1 1024k "testfile"
log_must sync log_must sync
log_must zfs umount $TESTPOOL/fs log_must zfs umount $TESTPOOL/fs
log_must zfs mount $TESTPOOL/fs log_must zfs mount $TESTPOOL/fs
log_must zinject -a -t data -e decompress -f 20 $mntpt/testfile.0 log_must zinject -a -t data -e decompress -f 20 $mntpt/testfile.0
log_mustnot eval "cat $mntpt/testfile.0 > /dev/null" log_mustnot eval "cat $mntpt/testfile.0 > /dev/null"
log_must eval "zpool events $TESTPOOL | grep -q 'data'" if ! is_freebsd; then
# Events are not supported on FreeBSD
log_must eval "zpool events $TESTPOOL | grep -q 'data'"
fi
log_pass "Injected decompression errors are handled correctly" log_pass "Injected decompression errors are handled correctly"

View File

@ -50,6 +50,9 @@ log_must zfs umount $TESTPOOL/fs
log_must zfs mount $TESTPOOL/fs log_must zfs mount $TESTPOOL/fs
log_mustnot eval "cat $mntpt/file1 > /dev/null" log_mustnot eval "cat $mntpt/file1 > /dev/null"
log_must eval "zpool events $TESTPOOL | grep -q 'authentication'" # Events are not supported on FreeBSD
if ! is_freebsd; then
log_must eval "zpool events $TESTPOOL | grep -q 'authentication'"
fi
log_pass "Injected decryption errors are handled correctly" log_pass "Injected decryption errors are handled correctly"

View File

@ -88,6 +88,31 @@ props=(
compression gzip compression gzip-$((RANDOM%9 + 1)) compression gzip compression gzip-$((RANDOM%9 + 1))
copies $((RANDOM%3 + 1)) copies $((RANDOM%3 + 1))
) )
elif is_freebsd; then
# property value property value
#
props=(
quota 64M recordsize 512
reservation 32M reservation none
mountpoint /history.$$ mountpoint legacy
mountpoint none sharenfs on
sharenfs off
compression on compression off
compression lzjb aclmode discard
aclmode groupmask aclmode passthrough
atime on atime off
devices on devices off
exec on exec off
setuid on setuid off
readonly on readonly off
zoned on zoned off
snapdir hidden snapdir visible
aclinherit discard aclinherit noallow
aclinherit secure aclinherit passthrough
canmount off canmount on
compression gzip compression gzip-$((RANDOM%9 + 1))
copies $((RANDOM%3 + 1))
)
else else
# property value property value # property value property value
# #

View File

@ -73,7 +73,7 @@ for arch in "i386" "sparc"; do
cat $orig_cmds_f | grep -v "^$" > $orig_cmds_f1 cat $orig_cmds_f | grep -v "^$" > $orig_cmds_f1
log_must cp $tst_dir/${arch}.migratedpool.DAT.Z $import_dir log_must cp $tst_dir/${arch}.migratedpool.DAT.Z $import_dir
log_must uncompress $import_dir/${arch}.migratedpool.DAT.Z log_must uncompress -f $import_dir/${arch}.migratedpool.DAT.Z
# destroy the pool with same name, so that import operation succeeds. # destroy the pool with same name, so that import operation succeeds.
poolexists $migratedpoolname && \ poolexists $migratedpoolname && \

View File

@ -43,8 +43,8 @@
verify_runnable "global" verify_runnable "global"
if is_linux; then if is_linux || is_freebsd; then
log_unsupported "Test case isn't applicable to Linux" log_unsupported "Test case isn't applicable to Linux/FreeBSD"
fi fi
function cleanup function cleanup

View File

@ -50,8 +50,8 @@
verify_runnable "global" verify_runnable "global"
if is_linux; then if is_linux || is_freebsd; then
log_unsupported "Test case isn't applicable to Linux" log_unsupported "Test case isn't applicable to Linux/FreeBSD"
fi fi
function cleanup function cleanup
@ -109,7 +109,7 @@ for num in 0 1 2; do
done done
log_note "Make a ufs filesystem on source $rawdisk1" log_note "Make a ufs filesystem on source $rawdisk1"
echo "y" | newfs -v $rawdisk1 > /dev/null 2>&1 new_fs $rawdisk1 > /dev/null 2>&1
(($? != 0)) && log_untested "Unable to create ufs filesystem on $rawdisk1" (($? != 0)) && log_untested "Unable to create ufs filesystem on $rawdisk1"
log_must mkdir -p $UFSMP log_must mkdir -p $UFSMP

View File

@ -72,6 +72,9 @@ function mini_format
if is_linux; then if is_linux; then
parted $disk -s -- mklabel gpt parted $disk -s -- mklabel gpt
typeset -i retval=$? typeset -i retval=$?
elif is_freebsd; then
gpart create -s gpt $disk
typeset -i retval=$?
else else
typeset format_file=$TEST_BASE_DIR/format_in.$$.1 typeset format_file=$TEST_BASE_DIR/format_in.$$.1
echo "partition" > $format_file echo "partition" > $format_file

View File

@ -63,10 +63,10 @@ function verify_assertion #slices
typeset targets=$1 typeset targets=$1
for t in $targets; do for t in $targets; do
echo "y" | newfs -v $t > /dev/null 2>&1 if new_fs $t; then
(( $? !=0 )) || \
log_fail "newfs over active pool " \ log_fail "newfs over active pool " \
"unexpected return code of 0" "unexpected return code of 0"
fi
done done
return 0 return 0

View File

@ -44,8 +44,8 @@
verify_runnable "global" verify_runnable "global"
if is_linux; then if is_linux || is_freebsd; then
log_unsupported "Test case isn't applicable to Linux" log_unsupported "Test case isn't applicable to Linux/FreeBSD"
fi fi
function cleanup function cleanup

View File

@ -45,8 +45,8 @@
verify_runnable "global" verify_runnable "global"
if is_linux; then if is_linux || is_freebsd; then
log_unsupported "Test case isn't applicable to Linux" log_unsupported "Test case isn't applicable to Linux/FreeBSD"
fi fi
function cleanup function cleanup

View File

@ -66,10 +66,10 @@ function verify_assertion #slices
typeset targets=$1 typeset targets=$1
for t in $targets; do for t in $targets; do
echo "y" | newfs -v $t > /dev/null 2>&1 if ! new_fs $t; then
(( $? !=0 )) && \
log_fail "newfs over exported pool " \ log_fail "newfs over exported pool " \
"fails unexpectedly." "fails unexpectedly."
fi
done done
return 0 return 0

Some files were not shown because too many files have changed in this diff Show More