diff --git a/tests/zfs-tests/include/blkdev.shlib b/tests/zfs-tests/include/blkdev.shlib index 2269131a4..e459e9e46 100644 --- a/tests/zfs-tests/include/blkdev.shlib +++ b/tests/zfs-tests/include/blkdev.shlib @@ -577,6 +577,11 @@ function corrupt_blocks_at_level # input_file corrupt_level [[ -f $input_file ]] || log_fail "Couldn't find $input_file" + if is_freebsd; then + # Temporarily allow corrupting an inuse device. + debugflags=$(sysctl -n kern.geom.debugflags) + sysctl kern.geom.debugflags=16 + fi log_must list_file_blocks $input_file | \ while read level path offset length; do @@ -586,6 +591,10 @@ function corrupt_blocks_at_level # input_file corrupt_level fi done + if is_freebsd; then + sysctl kern.geom.debugflags=$debugflags + fi + # This is necessary for pools made of loop devices. sync } diff --git a/tests/zfs-tests/include/commands.cfg b/tests/zfs-tests/include/commands.cfg index 71b05dda0..4498f1a53 100644 --- a/tests/zfs-tests/include/commands.cfg +++ b/tests/zfs-tests/include/commands.cfg @@ -113,6 +113,7 @@ export SYSTEM_FILES_COMMON='arp export SYSTEM_FILES_FREEBSD='chflags compress + diskinfo dumpon env fsck diff --git a/tests/zfs-tests/tests/functional/checksum/filetest_001_pos.ksh b/tests/zfs-tests/tests/functional/checksum/filetest_001_pos.ksh index 27dad0726..0cad8047c 100755 --- a/tests/zfs-tests/tests/functional/checksum/filetest_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/checksum/filetest_001_pos.ksh @@ -54,9 +54,7 @@ verify_runnable "both" function cleanup { - echo cleanup - [[ -e $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 + rm -fr $TESTDIR/* } log_assert "Create and read back files with using different checksum algorithms" diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_rewind_device_replaced.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_rewind_device_replaced.ksh index 9a2f0c673..94d1cb25d 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_rewind_device_replaced.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_rewind_device_replaced.ksh @@ -60,7 +60,7 @@ ZFS_TXG_TIMEOUT="" function custom_cleanup { # Revert zfs_txg_timeout to defaults - [[ -n ZFS_TXG_TIMEOUT ]] && + [[ -n $ZFS_TXG_TIMEOUT ]] && log_must set_zfs_txg_timeout $ZFS_TXG_TIMEOUT log_must rm -rf $BACKUP_DEVICE_DIR log_must set_tunable32 SCAN_SUSPEND_PROGRESS 0 diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib index 201c3803a..48794c982 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib @@ -346,42 +346,11 @@ function set_zfs_max_missing_tvds } # -# Use mdb to find the last txg that was synced in an active pool. +# Use zdb to find the last txg that was synced in an active pool. # function get_last_txg_synced { typeset pool=$1 - if is_linux; then - txg=$(tail "/proc/spl/kstat/zfs/$pool/txgs" | - awk '$3=="C" {print $1}' | tail -1) - [[ "$txg" ]] || txg=0 - echo $txg - return 0 - fi - - typeset spas - spas=$(mdb -k -e "::spa") - [[ $? -ne 0 ]] && return 1 - - typeset spa="" - print "$spas\n" | while read line; do - typeset poolname=$(echo "$line" | awk '{print $3}') - typeset addr=$(echo "$line" | awk '{print $1}') - if [[ $poolname == $pool ]]; then - spa=$addr - break - fi - done - if [[ -z $spa ]]; then - log_fail "Couldn't find pool '$pool'" - return 1 - fi - typeset mdbcmd="$spa::print spa_t spa_ubsync.ub_txg | ::eval '.=E'" - typeset -i txg - txg=$(mdb -k -e "$mdbcmd") - [[ $? -ne 0 ]] && return 1 - - echo $txg - return 0 + zdb -u $pool | awk '$1 == "txg" { print $3 }' | sort -n | tail -n 1 } diff --git a/tests/zfs-tests/tests/functional/history/history.cfg b/tests/zfs-tests/tests/functional/history/history.cfg index bbbd612a6..e9200a2b5 100644 --- a/tests/zfs-tests/tests/functional/history/history.cfg +++ b/tests/zfs-tests/tests/functional/history/history.cfg @@ -37,7 +37,11 @@ export TMP_HISTORY=$TEST_BASE_DIR/tmp_history.$$ export NEW_HISTORY=$TEST_BASE_DIR/new_history.$$ export MIGRATEDPOOLNAME=${MIGRATEDPOOLNAME:-history_pool} -export TIMEZONE=${TIMEZONE:-US/Mountain} +if is_freebsd; then + export TIMEZONE=${TIMEZONE:-America/Denver} +else + export TIMEZONE=${TIMEZONE:-US/Mountain} +fi export HIST_USER="huser" export HIST_GROUP="hgroup" diff --git a/tests/zfs-tests/tests/functional/large_files/large_files_002_pos.ksh b/tests/zfs-tests/tests/functional/large_files/large_files_002_pos.ksh index f4d4e5afb..b9289ed5e 100755 --- a/tests/zfs-tests/tests/functional/large_files/large_files_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/large_files/large_files_002_pos.ksh @@ -49,7 +49,11 @@ log_must rm $TESTDIR/ulimit_write_file $TESTDIR/ulimit_trunc_file # Verify 'ulimit -f ' works log_must ulimit -f 1024 log_mustnot sh -c 'dd if=/dev/zero of=$TESTDIR/ulimit_write_file bs=1M count=2' -log_mustnot sh -c 'truncate -s2M $TESTDIR/ulimit_trunc_file' -log_must rm $TESTDIR/ulimit_write_file $TESTDIR/ulimit_trunc_file +log_must rm $TESTDIR/ulimit_write_file +# FreeBSD allows the sparse file because space has not been allocated. +if !is_freebsd; then + log_mustnot sh -c 'truncate -s2M $TESTDIR/ulimit_trunc_file' + log_must rm $TESTDIR/ulimit_trunc_file +fi log_pass "Successfully enforced 'ulimit -f' maximum file size" diff --git a/tests/zfs-tests/tests/functional/removal/removal_cancel.ksh b/tests/zfs-tests/tests/functional/removal/removal_cancel.ksh index fdcaef635..e97dc5e77 100755 --- a/tests/zfs-tests/tests/functional/removal/removal_cancel.ksh +++ b/tests/zfs-tests/tests/functional/removal/removal_cancel.ksh @@ -66,21 +66,16 @@ log_must randwritecomp $SAMPLEFILE 25000 # log_must zpool add -f $TESTPOOL $NOTREMOVEDISK -# -# Start removal. -# -log_must zpool remove $TESTPOOL $REMOVEDISK - -# -# Sleep a bit and hopefully allow removal to copy some data. -# -log_must sleep 1 - # # Block removal. # log_must set_tunable32 REMOVAL_SUSPEND_PROGRESS 1 +# +# Start removal. +# +log_must zpool remove $TESTPOOL $REMOVEDISK + # # Only for debugging purposes in test logs. # diff --git a/tests/zfs-tests/tests/functional/resilver/resilver_restart_001.ksh b/tests/zfs-tests/tests/functional/resilver/resilver_restart_001.ksh index 6c37dc4e5..0a51f1ef2 100755 --- a/tests/zfs-tests/tests/functional/resilver/resilver_restart_001.ksh +++ b/tests/zfs-tests/tests/functional/resilver/resilver_restart_001.ksh @@ -70,9 +70,10 @@ function verify_restarts # [[ -z "$defer" ]] && return # use zdb to find which vdevs have the resilver defer flag - VDEV_DEFERS=$(zdb -C $TESTPOOL | \ - sed -n -e '/^ *children\[[0-9]\].*$/{h}' \ - -e '/ *com.datto:resilver_defer$/{g;p}') + VDEV_DEFERS=$(zdb -C $TESTPOOL | awk ' + /children/ { gsub(/[^0-9]/, ""); child = $0 } + /com\.datto:resilver_defer$/ { print child } + ') if [[ "$defer" == "-" ]] then @@ -81,7 +82,7 @@ function verify_restarts # return fi - [[ "x${VDEV_DEFERS}x" =~ "x +children[$defer]:x" ]] || + [[ $VDEV_DEFERS -eq $defer ]] || log_fail "resilver deferred set on unexpected vdev: $VDEV_DEFERS" }