]>
git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - zfs/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_003_pos.ksh
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.
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.
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]
24 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2012 by Delphix. All rights reserved.
32 .
$STF_SUITE/include
/libtest.shlib
33 .
$STF_SUITE/tests
/functional
/cli_root
/zfs_destroy
/zfs_destroy.cfg
37 # Verify 'zfs destroy [-rR]' succeeds as root.
40 # 1. Create two datasets in the storage pool
41 # 2. Create fs,vol,ctr,snapshot and clones of snapshot in the two datasets
42 # 3. Create clone in the second dataset for the snapshot in the first dataset
43 # 4. Verify 'zfs destroy -r' fails to destroy dataset with clone outside it
44 # 5. Verify 'zfs destroy -R' succeeds to destroy dataset with clone outside it
45 # 6. Verify 'zfs destroy -r' succeeds to destroy dataset without clone outside it.
48 verify_runnable
"both"
52 for obj
in $ctr2 $ctr1 $ctr; do
53 datasetexists
$obj && \
54 log_must
$ZFS destroy
-Rf $obj
57 for mntp
in $TESTDIR1 $TESTDIR2; do
59 log_must
$RM -rf $mntp
63 log_assert
"Verify that 'zfs destroy [-rR]' succeeds as root. "
68 # Preparations for testing
70 for dir
in $TESTDIR1 $TESTDIR2; do
72 log_must
$MKDIR -p $dir
75 ctr
=$TESTPOOL/$TESTCTR
76 ctr1
=$TESTPOOL/$TESTCTR1
79 child_fs
=$ctr/$TESTFS1
80 child_fs1
=$ctr1/$TESTFS2
81 child_fs_mntp
=$TESTDIR1
82 child_fs1_mntp
=$TESTDIR2
83 child_vol
=$ctr/$TESTVOL
84 child_vol1
=$ctr1/$TESTVOL
85 child_fs_snap
=$child_fs@snap
86 child_fs1_snap
=$child_fs1@snap
87 child_fs_snap_clone
=$ctr/$TESTCLONE
88 child_fs_snap_clone1
=$ctr1/${TESTCLONE}_across_ctr
89 child_fs_snap_clone2
=$ctr2/$TESTCLONE2
90 child_fs1_snap_clone
=$ctr1/$TESTCLONE1
91 child_fs1_snap_clone1
=$ctr/${TESTCLONE1}_across_ctr
94 # Create two datasets in the storage pool
96 log_must
$ZFS create
$ctr
97 log_must
$ZFS create
$ctr1
100 # Create children datasets fs,vol,snapshot in the datasets, and
101 # clones across two datasets
103 log_must
$ZFS create
$ctr2
105 for fs
in $child_fs $child_fs1; do
106 log_must
$ZFS create
$fs
109 log_must
$ZFS set mountpoint
=$child_fs_mntp $child_fs
110 log_must
$ZFS set mountpoint
=$child_fs1_mntp $child_fs1
112 for snap
in $child_fs_snap $child_fs1_snap; do
113 log_must
$ZFS snapshot
$snap
116 if is_global_zone
; then
117 for vol
in $child_vol $child_vol1; do
118 log_must
$ZFS create
-V $VOLSIZE $vol
122 for clone
in $child_fs_snap_clone $child_fs_snap_clone1; do
123 log_must
$ZFS clone
$child_fs_snap $clone
127 for clone
in $child_fs1_snap_clone $child_fs1_snap_clone1; do
128 log_must
$ZFS clone
$child_fs1_snap $clone
131 log_note
"Verify that 'zfs destroy -r' fails to destroy dataset " \
132 "with clone dependant outside it."
134 for obj
in $child_fs $child_fs1 $ctr $ctr1; do
135 log_mustnot
$ZFS destroy
-r $obj
136 datasetexists
$obj || \
137 log_fail
"'zfs destroy -r' fails to keep clone " \
138 "dependant outside the hirearchy."
142 log_note
"Verify that 'zfs destroy -R' succeeds to destroy dataset " \
143 "with clone dependant outside it."
145 log_must
$ZFS destroy
-R $ctr1
146 datasetexists
$ctr1 && \
147 log_fail
"'zfs destroy -R' fails to destroy dataset with clone outside it."
149 log_note
"Verify that 'zfs destroy -r' succeeds to destroy dataset " \
150 "without clone dependant outside it."
152 log_must
$ZFS destroy
-r $ctr
153 datasetexists
$ctr && \
154 log_fail
"'zfs destroy -r' fails to destroy dataset with clone outside it."
156 log_pass
"'zfs destroy [-rR] succeeds as root."