1# CDDL HEADER START
2#
3# The contents of this file are subject to the terms of the
4# Common Development and Distribution License (the "License").
5# You may not use this file except in compliance with the License.
6#
7# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
8# or http://www.opensolaris.org/os/licensing.
9# See the License for the specific language governing permissions
10# and limitations under the License.
11#
12# When distributing Covered Code, include this CDDL HEADER in each
13# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
14# If applicable, add the following below this CDDL HEADER, with the
15# fields enclosed by brackets "[]" replaced with your own identifying
16# information: Portions Copyright [yyyy] [name of copyright owner]
17#
18# CDDL HEADER END
19#
20
21#
22# Copyright 2012 Spectra Logic.  All rights reserved.
23# Use is subject to license terms.
24#
25
26
27atf_test_case zfs_destroy_001_pos cleanup
28zfs_destroy_001_pos_head()
29{
30	atf_set "descr" "'zfs destroy -r|-R|-f|-rf|-Rf <fs|ctr|vol|snap>' shouldrecursively destroy all children."
31	atf_set "require.progs" "ksh93 zfs"
32	atf_set "timeout" 3600
33}
34zfs_destroy_001_pos_body()
35{
36	. $(atf_get_srcdir)/../../../include/default.cfg
37	. $(atf_get_srcdir)/zfs_destroy_common.kshlib
38	. $(atf_get_srcdir)/zfs_destroy.cfg
39
40	verify_disk_count "$DISKS" 1
41	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
42	ksh93 $(atf_get_srcdir)/zfs_destroy_001_pos.ksh || atf_fail "Testcase failed"
43}
44zfs_destroy_001_pos_cleanup()
45{
46	. $(atf_get_srcdir)/../../../include/default.cfg
47	. $(atf_get_srcdir)/zfs_destroy_common.kshlib
48	. $(atf_get_srcdir)/zfs_destroy.cfg
49
50	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
51}
52
53
54atf_test_case zfs_destroy_002_pos cleanup
55zfs_destroy_002_pos_head()
56{
57	atf_set "descr" "Verify 'zfs destroy' can destroy the specified datasets without activedependents."
58	atf_set "require.progs" "ksh93 zfs"
59	atf_set "timeout" 3600
60}
61zfs_destroy_002_pos_body()
62{
63	. $(atf_get_srcdir)/../../../include/default.cfg
64	. $(atf_get_srcdir)/zfs_destroy_common.kshlib
65	. $(atf_get_srcdir)/zfs_destroy.cfg
66
67	verify_disk_count "$DISKS" 1
68	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
69	ksh93 $(atf_get_srcdir)/zfs_destroy_002_pos.ksh || atf_fail "Testcase failed"
70}
71zfs_destroy_002_pos_cleanup()
72{
73	. $(atf_get_srcdir)/../../../include/default.cfg
74	. $(atf_get_srcdir)/zfs_destroy_common.kshlib
75	. $(atf_get_srcdir)/zfs_destroy.cfg
76
77	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
78}
79
80
81atf_test_case zfs_destroy_003_pos cleanup
82zfs_destroy_003_pos_head()
83{
84	atf_set "descr" "Verify that 'zfs destroy [-rR]' succeeds as root."
85	atf_set "require.progs" "ksh93 zfs"
86	atf_set "timeout" 3600
87}
88zfs_destroy_003_pos_body()
89{
90	. $(atf_get_srcdir)/../../../include/default.cfg
91	. $(atf_get_srcdir)/zfs_destroy_common.kshlib
92	. $(atf_get_srcdir)/zfs_destroy.cfg
93
94	verify_disk_count "$DISKS" 1
95	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
96	ksh93 $(atf_get_srcdir)/zfs_destroy_003_pos.ksh || atf_fail "Testcase failed"
97}
98zfs_destroy_003_pos_cleanup()
99{
100	. $(atf_get_srcdir)/../../../include/default.cfg
101	. $(atf_get_srcdir)/zfs_destroy_common.kshlib
102	. $(atf_get_srcdir)/zfs_destroy.cfg
103
104	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
105}
106
107
108atf_test_case zfs_destroy_004_pos cleanup
109zfs_destroy_004_pos_head()
110{
111	atf_set "descr" "Verify that 'zfs destroy -f' succeeds as root."
112	atf_set "require.progs" "ksh93 zfs"
113	atf_set "timeout" 3600
114}
115zfs_destroy_004_pos_body()
116{
117	. $(atf_get_srcdir)/../../../include/default.cfg
118	. $(atf_get_srcdir)/zfs_destroy_common.kshlib
119	. $(atf_get_srcdir)/zfs_destroy.cfg
120
121	verify_disk_count "$DISKS" 1
122	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
123	ksh93 $(atf_get_srcdir)/zfs_destroy_004_pos.ksh || atf_fail "Testcase failed"
124}
125zfs_destroy_004_pos_cleanup()
126{
127	. $(atf_get_srcdir)/../../../include/default.cfg
128	. $(atf_get_srcdir)/zfs_destroy_common.kshlib
129	. $(atf_get_srcdir)/zfs_destroy.cfg
130
131	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
132}
133
134
135atf_test_case zfs_destroy_005_neg cleanup
136zfs_destroy_005_neg_head()
137{
138	atf_set "descr" "Separately verify 'zfs destroy -f|-r|-rf|-R|-rR <dataset>' willfail in different conditions."
139	atf_set "require.progs" "ksh93 zfs"
140	atf_set "timeout" 3600
141}
142zfs_destroy_005_neg_body()
143{
144	. $(atf_get_srcdir)/../../../include/default.cfg
145	. $(atf_get_srcdir)/zfs_destroy_common.kshlib
146	. $(atf_get_srcdir)/zfs_destroy.cfg
147
148	verify_disk_count "$DISKS" 1
149	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
150	ksh93 $(atf_get_srcdir)/zfs_destroy_005_neg.ksh || atf_fail "Testcase failed"
151}
152zfs_destroy_005_neg_cleanup()
153{
154	. $(atf_get_srcdir)/../../../include/default.cfg
155	. $(atf_get_srcdir)/zfs_destroy_common.kshlib
156	. $(atf_get_srcdir)/zfs_destroy.cfg
157
158	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
159}
160
161
162atf_test_case zfs_destroy_006_neg cleanup
163zfs_destroy_006_neg_head()
164{
165	atf_set "descr" "'zfs destroy' should return an error with badly-formed parameters."
166	atf_set "require.progs" "ksh93 zfs"
167	atf_set "timeout" 3600
168}
169zfs_destroy_006_neg_body()
170{
171	. $(atf_get_srcdir)/../../../include/default.cfg
172	. $(atf_get_srcdir)/zfs_destroy_common.kshlib
173	. $(atf_get_srcdir)/zfs_destroy.cfg
174
175	verify_disk_count "$DISKS" 1
176	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
177	ksh93 $(atf_get_srcdir)/zfs_destroy_006_neg.ksh || atf_fail "Testcase failed"
178}
179zfs_destroy_006_neg_cleanup()
180{
181	. $(atf_get_srcdir)/../../../include/default.cfg
182	. $(atf_get_srcdir)/zfs_destroy_common.kshlib
183	. $(atf_get_srcdir)/zfs_destroy.cfg
184
185	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
186}
187
188
189atf_test_case zfs_destroy_007_neg cleanup
190zfs_destroy_007_neg_head()
191{
192	atf_set "descr" "Destroy dataset which is namespace-parent of origin should failed."
193	atf_set "require.progs" "ksh93 zfs"
194	atf_set "timeout" 3600
195}
196zfs_destroy_007_neg_body()
197{
198	. $(atf_get_srcdir)/../../../include/default.cfg
199	. $(atf_get_srcdir)/zfs_destroy_common.kshlib
200	. $(atf_get_srcdir)/zfs_destroy.cfg
201
202	verify_disk_count "$DISKS" 1
203	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
204	ksh93 $(atf_get_srcdir)/zfs_destroy_007_neg.ksh || atf_fail "Testcase failed"
205}
206zfs_destroy_007_neg_cleanup()
207{
208	. $(atf_get_srcdir)/../../../include/default.cfg
209	. $(atf_get_srcdir)/zfs_destroy_common.kshlib
210	. $(atf_get_srcdir)/zfs_destroy.cfg
211
212	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
213}
214
215
216atf_init_test_cases()
217{
218
219	atf_add_test_case zfs_destroy_001_pos
220	atf_add_test_case zfs_destroy_002_pos
221	atf_add_test_case zfs_destroy_003_pos
222	atf_add_test_case zfs_destroy_004_pos
223	atf_add_test_case zfs_destroy_005_neg
224	atf_add_test_case zfs_destroy_006_neg
225	atf_add_test_case zfs_destroy_007_neg
226}
227