Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZTS: Standardize use of destroy_dataset in cleanup #12663

Merged
merged 7 commits into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions tests/zfs-tests/tests/functional/bootfs/bootfs_002_neg.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,9 @@
verify_runnable "global"

function cleanup {
if datasetexists $TESTPOOL/vol
then
log_must zfs destroy $TESTPOOL/vol
fi
if poolexists $TESTPOOL
then
log_must zpool destroy $TESTPOOL
fi
datasetexists $TESTPOOL/vol && destroy_dataset $TESTPOOL/vol
poolexists $TESTPOOL && log_must zpool destroy $TESTPOOL

if [[ -f $VDEV ]]; then
log_must rm -f $VDEV
fi
Expand Down
2 changes: 1 addition & 1 deletion tests/zfs-tests/tests/functional/casenorm/casenorm.kshlib
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function create_testfs
function destroy_testfs
{
if datasetexists $TESTPOOL/$TESTFS ; then
log_must zfs destroy -f $TESTPOOL/$TESTFS
destroy_dataset $TESTPOOL/$TESTFS -f
rm -rf $TESTDIR || log_unresolved Could not remove $TESTDIR
fi
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ create_clone
function cleanup
{
datasetexists $TESTPOOL/$TESTFS@$TESTSNAP && \
log_must zfs destroy -R $TESTPOOL/$TESTFS@$TESTSNAP
destroy_dataset $TESTPOOL/$TESTFS@$TESTSNAP -R
}

log_must_program $TESTPOOL $ZCP_ROOT/lua_core/tst.exists.zcp \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fs=$TESTPOOL/$TESTFS/testchild

function cleanup
{
datasetexists $fs && log_must zfs destroy -R $fs
datasetexists $fs && destroy_dataset $fs -R
}

log_onexit cleanup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ clone=$TESTPOOL/$TESTCLONE

function cleanup
{
datasetexists $clone && log_must zfs destroy $clone
datasetexists $fs && log_must zfs destroy -R $fs
datasetexists $clone && destroy_dataset $clone
datasetexists $fs && destroy_dataset $fs -R
}

log_onexit cleanup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ limit=50000000

function cleanup
{
datasetexists $rootfs && log_must zfs destroy -R $rootfs
datasetexists $rootfs && destroy_dataset $rootfs -R
}

log_onexit cleanup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ function cleanup
rm -rf $corepath
fi
for ds in $fs1 $fs $ctr; do
if datasetexists $ds; then
log_must zfs destroy -rRf $ds
fi
datasetexists $ds && destroy_dataset $ds -rRf
done
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,14 @@ verify_runnable "both"

function cleanup
{
if snapexists "$DATASET@$TESTSNAP"; then
log_must zfs destroy "$DATASET@$TESTSNAP"
fi
if bkmarkexists "$DATASET#$TESTBM"; then
log_must zfs destroy "$DATASET#$TESTBM"
fi
if bkmarkexists "$DATASET#$TESTBMCOPY"; then
log_must zfs destroy "$DATASET#$TESTBMCOPY"
fi
snapexists "$DATASET@$TESTSNAP" && \
destroy_dataset "$DATASET@$TESTSNAP"

bkmarkexists "$DATASET#$TESTBM" && \
destroy_dataset "$DATASET#$TESTBM"

bkmarkexists "$DATASET#$TESTBMCOPY" && \
destroy_dataset "$DATASET#$TESTBMCOPY"
}

log_assert "'zfs bookmark' should work only when passed valid arguments."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ verify_runnable "both"
function cleanup
{
datasetexists $TESTPOOL/$TESTFS1 && \
log_must zfs destroy -f $TESTPOOL/$TESTFS1
destroy_dataset $TESTPOOL/$TESTFS1 -f
}
log_onexit cleanup

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ verify_runnable "both"
function cleanup
{
datasetexists $TESTPOOL/$TESTFS1 && \
log_must zfs destroy -r $TESTPOOL/$TESTFS1
destroy_dataset $TESTPOOL/$TESTFS1 -r
}

log_onexit cleanup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ verify_runnable "both"
function cleanup
{
datasetexists $TESTPOOL/$TESTFS1 && \
log_must zfs destroy -Rf $TESTPOOL/$TESTFS1
destroy_dataset $TESTPOOL/$TESTFS1 -Rf
}

log_onexit cleanup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ verify_runnable "both"
function cleanup
{
datasetexists $TESTPOOL/$TESTFS1 && \
log_must zfs destroy -f $TESTPOOL/$TESTFS1
destroy_dataset $TESTPOOL/$TESTFS1 -f
}
log_onexit cleanup

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ verify_runnable "both"
function cleanup
{
datasetexists $TESTPOOL/$TESTFS1 && \
log_must zfs destroy -r $TESTPOOL/$TESTFS1
destroy_dataset $TESTPOOL/$TESTFS1 -r
}
log_onexit cleanup

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ verify_runnable "both"
function cleanup
{
datasetexists $TESTPOOL/$TESTFS1 && \
log_must zfs destroy -f $TESTPOOL/$TESTFS1
destroy_dataset $TESTPOOL/$TESTFS1 -f
}
log_onexit cleanup

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ verify_runnable "both"
function cleanup
{
datasetexists $TESTPOOL/$TESTFS1 && \
log_must zfs destroy -f $TESTPOOL/$TESTFS1
destroy_dataset $TESTPOOL/$TESTFS1 -f
}
log_onexit cleanup

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function verify_pbkdf2iters
function cleanup
{
datasetexists $TESTPOOL/$TESTFS1 && \
log_must zfs destroy -f $TESTPOOL/$TESTFS1
destroy_dataset $TESTPOOL/$TESTFS1 -f
}
log_onexit cleanup

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ function setup_all
function cleanup_all
{
for fs in $targets; do
datasetexists $fs && log_must zfs destroy -f $fs
datasetexists $fs && destroy_dataset $fs -f
done

for snap in $SNAPFS $SNAPFS1 ; do
snapexists $snap && log_must zfs destroy -Rf $snap
snapexists $snap && destroy_dataset $snap -Rf
done

return 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,10 @@ function setup_all
function cleanup_all
{

if datasetexists $TESTPOOL/notexist ; then
log_must zfs destroy -rRf $TESTPOOL/notexist
fi
datasetexists $TESTPOOL/notexist && destroy_dataset $TESTPOOL/notexist -rRf

for snap in $SNAPFS $SNAPFS1 ; do
if snapexists $snap ; then
log_must zfs destroy -Rf $snap
fi
snapexists $snap && destroy_dataset $snap -Rf
done

return 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ verify_runnable "both"

function cleanup
{
if snapexists $SNAPFS ; then
log_must zfs destroy -Rf $SNAPFS
fi
snapexists $SNAPFS && destroy_dataset $SNAPFS -Rf
}

log_onexit cleanup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ verify_runnable "both"

function cleanup
{
if snapexists $SNAPFS ; then
log_must zfs destroy -Rf $SNAPFS
fi
snapexists $SNAPFS && destroy_dataset $SNAPFS -Rf
}

log_onexit cleanup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ verify_runnable "global"

function cleanup
{
if snapexists $SNAPFS1 ; then
log_must zfs destroy -Rf $SNAPFS1
fi
snapexists $SNAPFS1 && destroy_dataset $SNAPFS1 -Rf
}

log_onexit cleanup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ verify_runnable "global"

function cleanup
{
if snapexists $SNAPFS1 ; then
log_must_busy zfs destroy -Rf $SNAPFS1
fi
snapexists $SNAPFS1 && destroy_dataset $SNAPFS1 -Rf
}

log_onexit cleanup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ verify_runnable "both"

function cleanup
{
if snapexists $SNAPFS ; then
log_must zfs destroy -Rf $SNAPFS
fi
snapexists $SNAPFS && destroy_dataset $SNAPFS -Rf
}

log_onexit cleanup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ verify_runnable "both"

function cleanup
{
if snapexists $SNAPFS ; then
log_must zfs destroy -Rf $SNAPFS
fi
snapexists $SNAPFS && destroy_dataset $SNAPFS -Rf
}

log_onexit cleanup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ verify_runnable "global"

function cleanup
{
if snapexists $SNAPFS1 ; then
log_must zfs destroy -Rf $SNAPFS1
fi
snapexists $SNAPFS1 && destroy_dataset $SNAPFS1 -Rf
}

log_onexit cleanup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ function local_cleanup
typeset -i i=1
for ds in $datasets; do
datasetexists $ds/$TESTCLONE.$i && \
log_must zfs destroy -rf $ds/$TESTCLONE.$i
datasetexists $ds && log_must zfs destroy -Rf $ds
destroy_dataset $ds/$TESTCLONE.$i -rf
datasetexists $ds && destroy_dataset $ds -Rf
((i=i+1))
done
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ verify_runnable "both"
function cleanup
{
datasetexists $TESTPOOL/$TESTFS2 && \
log_must zfs destroy -f $TESTPOOL/$TESTFS2
destroy_dataset $TESTPOOL/$TESTFS2 -f
datasetexists $TESTPOOL/$TESTFS1 && \
log_must zfs destroy -r $TESTPOOL/$TESTFS1
destroy_dataset $TESTPOOL/$TESTFS1 -r
}
log_onexit cleanup

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ function cleanup
typeset ds

for ds in $fs1 $fs2 $vol1 $vol2; do
if datasetexists $ds; then
log_must zfs destroy $ds
fi
datasetexists $ds && destroy_dataset $ds
done
}

Expand Down Expand Up @@ -94,13 +92,13 @@ for val in 1 2 3; do
fi
for ds in $fs2 $vol2; do
cmp_prop $ds $val2
log_must zfs destroy $ds
destroy_dataset $ds
block_device_wait
done
done

for ds in $fs1 $vol1; do
log_must zfs destroy $ds
destroy_dataset $ds
block_device_wait
done

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ function cleanup
typeset val

for val in 1 2 3; do
if datasetexists $TESTPOOL/fs_$val; then
log_must zfs destroy $TESTPOOL/fs_$val
fi
datasetexists $TESTPOOL/fs_$val && \
destroy_dataset $TESTPOOL/fs_$val
done
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ function cleanup
destroy_pool $TESTPOOL1
fi

if datasetexists $vol; then
log_must zfs destroy $vol
fi
datasetexists $vol && destroy_dataset $vol
}

log_assert "Verify that ZFS volume space used by multiple copies is charged correctly."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ function cleanup
log_must umount $mntp
fi

if datasetexists $vol; then
log_must zfs destroy $vol
fi
datasetexists $vol && destroy_dataset $vol

if [[ -d $mntp ]]; then
rm -rf $mntp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function cleanup
typeset -i i=0
while (( $i < ${#datasets[*]} )); do
datasetexists ${datasets[$i]} && \
log_must zfs destroy -f ${datasets[$i]}
destroy_dataset ${datasets[$i]} -f
((i = i + 1))
done

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ verify_runnable "global"

function cleanup
{
datasetexists $vol && \
log_must zfs destroy -f $vol
datasetexists $vol && destroy_dataset $vol -f
}

log_assert "Verify creating volume with specified blocksize works."
Expand Down
Loading