Update and enable zfs_destroy_0[08-13]_*.ksh.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: cao.xuewen <cao.xuewen@zte.com.cn>
Closes #5068
# DISABLED:
# zfs_destroy_005_neg - busy mountpoint behavior
-# zfs_destroy_008_pos - busy mountpoint behavior
-# zfs_destroy_009_pos - busy mountpoint behavior
-# zfs_destroy_010_pos - busy mountpoint behavior
-# zfs_destroy_011_pos - busy mountpoint behavior
-# zfs_destroy_012_pos - busy mountpoint behavior
-# zfs_destroy_013_neg - busy mountpoint behavior
[tests/functional/cli_root/zfs_destroy]
tests = ['zfs_destroy_001_pos', 'zfs_destroy_002_pos', 'zfs_destroy_003_pos',
- 'zfs_destroy_004_pos', 'zfs_destroy_006_neg', 'zfs_destroy_007_neg',
- 'zfs_destroy_014_pos', 'zfs_destroy_015_pos', 'zfs_destroy_016_pos']
+ 'zfs_destroy_004_pos','zfs_destroy_006_neg', 'zfs_destroy_007_neg',
+ 'zfs_destroy_008_pos','zfs_destroy_009_pos', 'zfs_destroy_010_pos',
+ 'zfs_destroy_011_pos','zfs_destroy_012_pos', 'zfs_destroy_013_neg',
+ 'zfs_destroy_014_pos','zfs_destroy_015_pos', 'zfs_destroy_016_pos']
# DISABLED:
# zfs_get_004_pos - nested pools
. $STF_SUITE/tests/functional/cli_root/zfs_destroy/zfs_destroy_common.kshlib
-cleanup_testenv
-
default_cleanup
#
################################################################################
+function test_s_run
+{
+ typeset snap=$1
+
+ log_must $ZFS destroy -d $snap
+ log_mustnot datasetexists $snap
+}
+
log_assert "'zfs destroy -d <snap>' destroys snapshot if there is no clone"
log_onexit cleanup_testenv
setup_testenv snap
for snap in $FSSNAP $VOLSNAP; do
- log_must $ZFS destroy -d $snap
- log_mustnot datasetexists $snap
+ if [[ $snap == $VOLSNAP ]]; then
+ if is_global_zone; then
+ test_s_run $snap
+ fi
+ else
+ test_s_run $snap
+ fi
done
log_pass "'zfs destroy -d <snap>' destroys snapshot if there is no clone"
#
################################################################################
-log_assert "'zfs destroy -d <snap>' marks cloned snapshot for deferred destroy"
-log_onexit cleanup_testenv
-
-setup_testenv clone
+function test_c_run
+{
+ typeset dstype=$1
-for dstype in FS VOL; do
snap=$(eval echo \$${dstype}SNAP)
clone=$(eval echo \$${dstype}CLONE)
log_must $ZFS destroy -d $snap
log_must $ZFS destroy $clone
log_mustnot datasetexists $snap
log_mustnot datasetexists $clone
+}
+
+log_assert "'zfs destroy -d <snap>' marks cloned snapshot for deferred destroy"
+log_onexit cleanup_testenv
+
+setup_testenv clone
+
+for dstype in FS VOL; do
+ if [[ $dstype == VOL ]]; then
+ if is_global_zone; then
+ test_c_run $dstype
+ fi
+ else
+ test_c_run $dstype
+ fi
done
log_pass "'zfs destroy -d <snap>' marks cloned snapshot for deferred destroy"
#
################################################################################
-log_assert "'zfs destroy -R' works on deferred destroyed snapshots"
-log_onexit cleanup_testenv
-
-setup_testenv clone
-log_must $UMOUNT -f $TESTDIR1
+function test_clone_run
+{
+ typeset dstype=$1
-for dstype in FS VOL; do
ds=$(eval echo \$${dstype})
snap=$(eval echo \$${dstype}SNAP)
clone=$(eval echo \$${dstype}CLONE)
log_must $ZFS destroy -d $snap
log_must datasetexists $snap
- log_must $ZFS destroy -R $ds
+ log_must $ZFS destroy -R $clone
log_mustnot datasetexists $snap
log_mustnot datasetexists $clone
+}
+
+log_assert "'zfs destroy -R' works on deferred destroyed snapshots"
+log_onexit cleanup_testenv
+
+setup_testenv clone
+
+for dstype in FS VOL; do
+ if [[ $dstype == VOL ]]; then
+ if is_global_zone; then
+ test_clone_run $dstype
+ fi
+ else
+ test_clone_run $dstype
+ fi
done
log_pass "'zfs destroy -R' works on deferred destroyed snapshots"
#
################################################################################
-log_assert "'zfs destroy -d <snap>' marks held snapshot for deferred destroy"
-log_onexit cleanup_testenv
-
-setup_testenv snap
+function test_snap_run
+{
+ typeset dstype=$1
-for dstype in FS VOL; do
snap=$(eval echo \$${dstype}SNAP)
log_must $ZFS hold zfstest $snap
log_must $ZFS destroy -d $snap
log_must eval "[[ $(get_prop defer_destroy $snap) == 'on' ]]"
log_must $ZFS release zfstest $snap
log_mustnot datasetexists $snap
+}
+
+log_assert "'zfs destroy -d <snap>' marks held snapshot for deferred destroy"
+log_onexit cleanup_testenv
+
+setup_testenv snap
+
+for dstype in FS VOL; do
+ if [[ $dstype == VOL ]]; then
+ if is_global_zone; then
+ test_snap_run $dstype
+ fi
+ else
+ test_snap_run $dstype
+ fi
done
log_pass "'zfs destroy -d <snap>' marks held snapshot for deferred destroy"
#
################################################################################
-log_assert "deferred destroyed snapshots remain until last hold is released"
-log_onexit cleanup_testenv
-
-setup_testenv snap
+function test_snap_run
+{
+ typeset dstype=$1
-for dstype in FS VOL; do
snap=$(eval echo \$${dstype}SNAP)
log_must $ZFS hold zfstest1 $snap
log_must $ZFS destroy -d $snap
log_must $ZFS release zfstest2 $snap
log_mustnot datasetexists $snap
+}
+
+log_assert "deferred destroyed snapshots remain until last hold is released"
+log_onexit cleanup_testenv
+
+setup_testenv snap
+
+for dstype in FS VOL; do
+ if [[ $dstype == VOL ]]; then
+ if is_global_zone; then
+ test_snap_run $dstype
+ fi
+ else
+ test_snap_run $dstype
+ fi
done
log_pass "deferred destroyed snapshots remain until last hold is released"
#
################################################################################
-log_assert "zfs destroy of held snapshots fails"
-log_onexit cleanup_testenv
-
-setup_testenv snap
+function test_snap_run
+{
+ typeset dstype=$1
-for dstype in FS VOL; do
snap=$(eval echo \$${dstype}SNAP)
log_must $ZFS hold zfstest $snap
log_mustnot $ZFS destroy $snap
log_must $ZFS release zfstest $snap
log_must $ZFS destroy $snap
log_mustnot datasetexists $snap
+}
+
+log_assert "zfs destroy of held snapshots fails"
+log_onexit cleanup_testenv
+
+setup_testenv snap
+
+for dstype in FS VOL; do
+ if [[ $dstype == VOL ]]; then
+ if is_global_zone; then
+ test_snap_run $dstype
+ fi
+ else
+ test_snap_run $dstype
+ fi
done
log_pass "zfs destroy of held snapshots fails"
#
function cleanup_testenv
{
- if is_global_zone && ismounted "$TESTDIR1" "ufs" ; then
+ if is_global_zone && ismounted "$TESTDIR1" "$NEWFS_DEFAULT_FS" ; then
log_must $UMOUNT -f $TESTDIR1
fi
if [[ -d $TESTDIR1 ]]; then