diff options
Diffstat (limited to 'sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs')
3 files changed, 21 insertions, 44 deletions
diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs/Makefile.am deleted file mode 100644 index 8b0ee276a3b0..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_001_neg.ksh \ - zfs_002_pos.ksh \ - zfs_003_neg.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs/zfs_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs/zfs_002_pos.ksh index 796b38928ec7..044ccb185c48 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs/zfs_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs/zfs_002_pos.ksh @@ -48,33 +48,23 @@ function cleanup { unset ZFS_ABORT - if is_freebsd && [[ -n $savedcorefile ]]; then - sysctl kern.corefile=$savedcorefile - fi + log_must pop_coredump_pattern "$coresavepath" - if [[ -d $corepath ]]; then - rm -rf $corepath - fi for ds in $fs1 $fs $ctr; do datasetexists $ds && destroy_dataset $ds -rRf done } -log_assert "With ZFS_ABORT set, all zfs commands can abort and generate a " \ - "core file." +log_assert "With ZFS_ABORT set, all zfs commands can abort and generate a core file." log_onexit cleanup +ctr=$TESTPOOL/$TESTCTR +log_must zfs create -p $ctr + # Preparation work for testing -savedcorefile="" -corepath=$TESTDIR/core +corepath=/$ctr corefile=$corepath/core.zfs -if [[ -d $corepath ]]; then - rm -rf $corepath -fi -log_must mkdir $corepath - -ctr=$TESTPOOL/$TESTCTR -log_must zfs create $ctr +coresavepath=$corepath/save fs=$ctr/$TESTFS fs1=$ctr/$TESTFS1 @@ -93,24 +83,12 @@ typeset badparams=("" "create" "destroy" "snapshot" "rollback" "clone" \ "promote" "rename" "list -*" "set" "get -*" "inherit" "mount -A" \ "unmount" "share" "unshare" "send" "receive") -if is_linux; then - ulimit -c unlimited - echo "$corefile" >/proc/sys/kernel/core_pattern - echo 0 >/proc/sys/kernel/core_uses_pid -elif is_freebsd; then - ulimit -c unlimited - savedcorefile=$(sysctl -n kern.corefile) - log_must sysctl kern.corefile=$corepath/core.%N -else - log_must coreadm -p ${corepath}/core.%f -fi - +log_must eval "push_coredump_pattern \"$corepath\" > \"$coresavepath\"" log_must export ZFS_ABORT=yes for subcmd in "${cmds[@]}" "${badparams[@]}"; do - log_mustnot eval "zfs $subcmd >/dev/null 2>&1" - log_must rm $corefile + log_mustnot eval "zfs $subcmd" + log_must rm "$corefile" done -log_pass "With ZFS_ABORT set, zfs command can abort and generate core file " \ - "as expected." +log_pass "With ZFS_ABORT set, zfs command can abort and generate core file as expected." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs/zfs_003_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs/zfs_003_neg.ksh index 0438bae8f6ce..6c85e0c13ab4 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs/zfs_003_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs/zfs_003_neg.ksh @@ -45,7 +45,15 @@ verify_runnable "global" +function cleanup +{ + for file in $ZFS_DEV $MNTTAB; do + log_must eval "[ -e ${file} ] || mv ${file}.bak $file" + done +} + log_assert "zfs fails with unexpected scenario." +log_onexit cleanup #verify zfs failed if ZFS_DEV cannot be opened ZFS_DEV=/dev/zfs @@ -56,13 +64,11 @@ if is_linux; then fi for file in $ZFS_DEV $MNTTAB; do - if [[ -e $file ]]; then - mv $file ${file}.bak - fi + log_must mv $file ${file}.bak for cmd in "" "list" "get all" "mount"; do log_mustnot eval "zfs $cmd >/dev/null 2>&1" done - mv ${file}.bak $file + log_must mv ${file}.bak $file done log_pass "zfs fails with unexpected scenario as expected." |