Skip to content

Commit 3d5ba1c

Browse files
author
Ryan Moeller
authored
ZTS: Misc fixes for FreeBSD
* Set geom debug flags in corrupt_blocks_at_level * Use the right time zone for history tests * Add missing commands.cfg entry for diskinfo * Rewrite get_last_txg_synced to use zdb * Don't check ulimits for sparse files * Suspend removal before removing a vdev, not after Reviewed-by: John Kennedy <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Closes #10054
1 parent ab96461 commit 3d5ba1c

File tree

9 files changed

+34
-53
lines changed

9 files changed

+34
-53
lines changed

tests/zfs-tests/include/blkdev.shlib

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,11 @@ function corrupt_blocks_at_level # input_file corrupt_level
577577

578578
[[ -f $input_file ]] || log_fail "Couldn't find $input_file"
579579

580+
if is_freebsd; then
581+
# Temporarily allow corrupting an inuse device.
582+
debugflags=$(sysctl -n kern.geom.debugflags)
583+
sysctl kern.geom.debugflags=16
584+
fi
580585

581586
log_must list_file_blocks $input_file | \
582587
while read level path offset length; do
@@ -586,6 +591,10 @@ function corrupt_blocks_at_level # input_file corrupt_level
586591
fi
587592
done
588593

594+
if is_freebsd; then
595+
sysctl kern.geom.debugflags=$debugflags
596+
fi
597+
589598
# This is necessary for pools made of loop devices.
590599
sync
591600
}

tests/zfs-tests/include/commands.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ export SYSTEM_FILES_COMMON='arp
113113

114114
export SYSTEM_FILES_FREEBSD='chflags
115115
compress
116+
diskinfo
116117
dumpon
117118
env
118119
fsck

tests/zfs-tests/tests/functional/checksum/filetest_001_pos.ksh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ verify_runnable "both"
5454

5555
function cleanup
5656
{
57-
echo cleanup
58-
[[ -e $TESTDIR ]] && \
59-
log_must rm -rf $TESTDIR/* > /dev/null 2>&1
57+
rm -fr $TESTDIR/*
6058
}
6159

6260
log_assert "Create and read back files with using different checksum algorithms"

tests/zfs-tests/tests/functional/cli_root/zpool_import/import_rewind_device_replaced.ksh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ ZFS_TXG_TIMEOUT=""
6060
function custom_cleanup
6161
{
6262
# Revert zfs_txg_timeout to defaults
63-
[[ -n ZFS_TXG_TIMEOUT ]] &&
63+
[[ -n $ZFS_TXG_TIMEOUT ]] &&
6464
log_must set_zfs_txg_timeout $ZFS_TXG_TIMEOUT
6565
log_must rm -rf $BACKUP_DEVICE_DIR
6666
log_must set_tunable32 SCAN_SUSPEND_PROGRESS 0

tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -346,42 +346,11 @@ function set_zfs_max_missing_tvds
346346
}
347347

348348
#
349-
# Use mdb to find the last txg that was synced in an active pool.
349+
# Use zdb to find the last txg that was synced in an active pool.
350350
#
351351
function get_last_txg_synced
352352
{
353353
typeset pool=$1
354354

355-
if is_linux; then
356-
txg=$(tail "/proc/spl/kstat/zfs/$pool/txgs" |
357-
awk '$3=="C" {print $1}' | tail -1)
358-
[[ "$txg" ]] || txg=0
359-
echo $txg
360-
return 0
361-
fi
362-
363-
typeset spas
364-
spas=$(mdb -k -e "::spa")
365-
[[ $? -ne 0 ]] && return 1
366-
367-
typeset spa=""
368-
print "$spas\n" | while read line; do
369-
typeset poolname=$(echo "$line" | awk '{print $3}')
370-
typeset addr=$(echo "$line" | awk '{print $1}')
371-
if [[ $poolname == $pool ]]; then
372-
spa=$addr
373-
break
374-
fi
375-
done
376-
if [[ -z $spa ]]; then
377-
log_fail "Couldn't find pool '$pool'"
378-
return 1
379-
fi
380-
typeset mdbcmd="$spa::print spa_t spa_ubsync.ub_txg | ::eval '.=E'"
381-
typeset -i txg
382-
txg=$(mdb -k -e "$mdbcmd")
383-
[[ $? -ne 0 ]] && return 1
384-
385-
echo $txg
386-
return 0
355+
zdb -u $pool | awk '$1 == "txg" { print $3 }' | sort -n | tail -n 1
387356
}

tests/zfs-tests/tests/functional/history/history.cfg

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ export TMP_HISTORY=$TEST_BASE_DIR/tmp_history.$$
3737
export NEW_HISTORY=$TEST_BASE_DIR/new_history.$$
3838

3939
export MIGRATEDPOOLNAME=${MIGRATEDPOOLNAME:-history_pool}
40-
export TIMEZONE=${TIMEZONE:-US/Mountain}
40+
if is_freebsd; then
41+
export TIMEZONE=${TIMEZONE:-America/Denver}
42+
else
43+
export TIMEZONE=${TIMEZONE:-US/Mountain}
44+
fi
4145

4246
export HIST_USER="huser"
4347
export HIST_GROUP="hgroup"

tests/zfs-tests/tests/functional/large_files/large_files_002_pos.ksh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ log_must rm $TESTDIR/ulimit_write_file $TESTDIR/ulimit_trunc_file
4949
# Verify 'ulimit -f <size>' works
5050
log_must ulimit -f 1024
5151
log_mustnot sh -c 'dd if=/dev/zero of=$TESTDIR/ulimit_write_file bs=1M count=2'
52-
log_mustnot sh -c 'truncate -s2M $TESTDIR/ulimit_trunc_file'
53-
log_must rm $TESTDIR/ulimit_write_file $TESTDIR/ulimit_trunc_file
52+
log_must rm $TESTDIR/ulimit_write_file
53+
# FreeBSD allows the sparse file because space has not been allocated.
54+
if !is_freebsd; then
55+
log_mustnot sh -c 'truncate -s2M $TESTDIR/ulimit_trunc_file'
56+
log_must rm $TESTDIR/ulimit_trunc_file
57+
fi
5458

5559
log_pass "Successfully enforced 'ulimit -f' maximum file size"

tests/zfs-tests/tests/functional/removal/removal_cancel.ksh

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,14 @@ log_must randwritecomp $SAMPLEFILE 25000
6767
log_must zpool add -f $TESTPOOL $NOTREMOVEDISK
6868

6969
#
70-
# Start removal.
71-
#
72-
log_must zpool remove $TESTPOOL $REMOVEDISK
73-
74-
#
75-
# Sleep a bit and hopefully allow removal to copy some data.
70+
# Block removal.
7671
#
77-
log_must sleep 1
72+
log_must set_tunable32 REMOVAL_SUSPEND_PROGRESS 1
7873

7974
#
80-
# Block removal.
75+
# Start removal.
8176
#
82-
log_must set_tunable32 REMOVAL_SUSPEND_PROGRESS 1
77+
log_must zpool remove $TESTPOOL $REMOVEDISK
8378

8479
#
8580
# Only for debugging purposes in test logs.

tests/zfs-tests/tests/functional/resilver/resilver_restart_001.ksh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@ function verify_restarts # <msg> <cnt> <defer>
7070
[[ -z "$defer" ]] && return
7171

7272
# use zdb to find which vdevs have the resilver defer flag
73-
VDEV_DEFERS=$(zdb -C $TESTPOOL | \
74-
sed -n -e '/^ *children\[[0-9]\].*$/{h}' \
75-
-e '/ *com.datto:resilver_defer$/{g;p}')
73+
VDEV_DEFERS=$(zdb -C $TESTPOOL | awk '
74+
/children/ { gsub(/[^0-9]/, ""); child = $0 }
75+
/com\.datto:resilver_defer$/ { print child }
76+
')
7677

7778
if [[ "$defer" == "-" ]]
7879
then
@@ -81,7 +82,7 @@ function verify_restarts # <msg> <cnt> <defer>
8182
return
8283
fi
8384

84-
[[ "x${VDEV_DEFERS}x" =~ "x +children[$defer]:x" ]] ||
85+
[[ $VDEV_DEFERS -eq $defer ]] ||
8586
log_fail "resilver deferred set on unexpected vdev: $VDEV_DEFERS"
8687
}
8788

0 commit comments

Comments
 (0)