1#!/bin/ksh -p
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22
23#
24# Copyright (c) 2012 by Delphix. All rights reserved.
25#
26
27. $STF_SUITE/include/libtest.shlib
28. $STF_SUITE/tests/functional/cli_root/zfs_destroy/zfs_destroy.cfg
29. $STF_SUITE/tests/functional/cli_root/zfs_destroy/zfs_destroy_common.kshlib
30
31################################################################################
32#
33# When using 'zfs destroy -R' on a file system heirarchy that inclues a
34# snapshot and a clone of that snapshot, and the snapshot has been
35# defer-destroyed, make sure that the 'zfs destroy -R' works as expected.
36# In particular make sure that libzfs is not confused by the fact that the
37# kernel will automatically remove the defer-destroyed snapshot when the
38# clone is destroyed.
39#
40# 1. Create test environment.
41# 2. Create a clone of the snapshot.
42# 3. 'zfs destroy -d <snap>'
43# 4. 'zfs destroy -R'
44# 5. Verify that the snapshot and clone are destroyed.
45#
46################################################################################
47
48log_assert "'zfs destroy -R' works on deferred destroyed snapshots"
49log_onexit cleanup_testenv
50
51setup_testenv clone
52log_must $UMOUNT -f $TESTDIR1
53
54for dstype in FS VOL; do
55    ds=$(eval echo \$${dstype})
56    snap=$(eval echo \$${dstype}SNAP)
57    clone=$(eval echo \$${dstype}CLONE)
58    log_must $ZFS destroy -d $snap
59    log_must datasetexists $snap
60    log_must $ZFS destroy -R $ds
61    log_mustnot datasetexists $snap
62    log_mustnot datasetexists $clone
63done
64
65log_pass "'zfs destroy -R' works on deferred destroyed snapshots"
66