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 zpool_destroy_001_pos cleanup
28zpool_destroy_001_pos_head()
29{
30	atf_set "descr" "'zpool destroy <pool>' can destroy a specified pool."
31	atf_set "require.progs" "ksh93 zfs zpool"
32}
33zpool_destroy_001_pos_body()
34{
35	. $(atf_get_srcdir)/../../../include/default.cfg
36	. $(atf_get_srcdir)/zpool_destroy.cfg
37
38	verify_zvol_recursive
39	verify_disk_count "$DISK" 1
40	ksh93 $(atf_get_srcdir)/zpool_destroy_001_pos.ksh || atf_fail "Testcase failed"
41}
42zpool_destroy_001_pos_cleanup()
43{
44	. $(atf_get_srcdir)/../../../include/default.cfg
45	. $(atf_get_srcdir)/zpool_destroy.cfg
46
47	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
48}
49
50
51atf_test_case zpool_destroy_002_pos cleanup
52zpool_destroy_002_pos_head()
53{
54	atf_set "descr" "'zpool destroy -f <pool>' can forcely destroy the specified pool"
55	atf_set "require.progs" "ksh93 zfs zpool"
56}
57zpool_destroy_002_pos_body()
58{
59	. $(atf_get_srcdir)/../../../include/default.cfg
60	. $(atf_get_srcdir)/zpool_destroy.cfg
61
62	verify_disk_count "$DISK" 1
63	ksh93 $(atf_get_srcdir)/zpool_destroy_002_pos.ksh || atf_fail "Testcase failed"
64}
65zpool_destroy_002_pos_cleanup()
66{
67	. $(atf_get_srcdir)/../../../include/default.cfg
68	. $(atf_get_srcdir)/zpool_destroy.cfg
69
70	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
71}
72
73
74atf_test_case zpool_destroy_003_neg cleanup
75zpool_destroy_003_neg_head()
76{
77	atf_set "descr" "'zpool destroy' should return an error with badly-formed parameters."
78	atf_set "require.progs" "ksh93 zpool"
79}
80zpool_destroy_003_neg_body()
81{
82	. $(atf_get_srcdir)/../../../include/default.cfg
83	. $(atf_get_srcdir)/zpool_destroy.cfg
84
85	ksh93 $(atf_get_srcdir)/zpool_destroy_003_neg.ksh || atf_fail "Testcase failed"
86}
87zpool_destroy_003_neg_cleanup()
88{
89	. $(atf_get_srcdir)/../../../include/default.cfg
90	. $(atf_get_srcdir)/zpool_destroy.cfg
91
92	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
93}
94
95
96atf_test_case zpool_destroy_004_pos cleanup
97zpool_destroy_004_pos_head()
98{
99	atf_set "descr" "'zpool destroy -f' should work on active pools."
100	atf_set "require.progs" "ksh93 zfs zpool"
101	atf_set "timeout" 2000
102}
103zpool_destroy_004_pos_body()
104{
105	. $(atf_get_srcdir)/../../../include/default.cfg
106	. $(atf_get_srcdir)/zpool_destroy.cfg
107
108	verify_disk_count "$DISKS" 2
109	ksh93 $(atf_get_srcdir)/zpool_destroy_004_pos.ksh || atf_fail "Testcase failed"
110}
111zpool_destroy_004_pos_cleanup()
112{
113	. $(atf_get_srcdir)/../../../include/default.cfg
114	. $(atf_get_srcdir)/zpool_destroy.cfg
115
116	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
117}
118
119
120atf_init_test_cases()
121{
122
123	atf_add_test_case zpool_destroy_001_pos
124	atf_add_test_case zpool_destroy_002_pos
125	atf_add_test_case zpool_destroy_003_neg
126	atf_add_test_case zpool_destroy_004_pos
127}
128