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_clear_001_pos cleanup
28zpool_clear_001_pos_head()
29{
30	atf_set "descr" "Verify 'zpool clear' can clear errors of a storage pool."
31	atf_set "require.progs" "ksh93 zpool zfs"
32	atf_set "timeout" 2100
33}
34zpool_clear_001_pos_body()
35{
36	. $(atf_get_srcdir)/../../../include/default.cfg
37	. $(atf_get_srcdir)/zpool_clear.cfg
38
39	ksh93 $(atf_get_srcdir)/zpool_clear_001_pos.ksh || atf_fail "Testcase failed"
40}
41zpool_clear_001_pos_cleanup()
42{
43	. $(atf_get_srcdir)/../../../include/default.cfg
44	. $(atf_get_srcdir)/zpool_clear.cfg
45
46	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
47}
48
49
50atf_test_case zpool_clear_002_neg cleanup
51zpool_clear_002_neg_head()
52{
53	atf_set "descr" "Execute 'zpool clear' using invalid parameters."
54	atf_set "require.progs" "ksh93 zpool"
55	atf_set "timeout" 2100
56}
57zpool_clear_002_neg_body()
58{
59	. $(atf_get_srcdir)/../../../include/default.cfg
60	. $(atf_get_srcdir)/zpool_clear.cfg
61
62	ksh93 $(atf_get_srcdir)/zpool_clear_002_neg.ksh || atf_fail "Testcase failed"
63}
64zpool_clear_002_neg_cleanup()
65{
66	. $(atf_get_srcdir)/../../../include/default.cfg
67	. $(atf_get_srcdir)/zpool_clear.cfg
68
69	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
70}
71
72
73atf_test_case zpool_clear_003_neg cleanup
74zpool_clear_003_neg_head()
75{
76	atf_set "descr" "Verify 'zpool clear' cannot clear error for available spare devices."
77	atf_set "require.progs" "ksh93 zpool"
78	atf_set "timeout" 2100
79}
80zpool_clear_003_neg_body()
81{
82	. $(atf_get_srcdir)/../../../include/default.cfg
83	. $(atf_get_srcdir)/zpool_clear.cfg
84
85	ksh93 $(atf_get_srcdir)/zpool_clear_003_neg.ksh || atf_fail "Testcase failed"
86}
87zpool_clear_003_neg_cleanup()
88{
89	. $(atf_get_srcdir)/../../../include/default.cfg
90	. $(atf_get_srcdir)/zpool_clear.cfg
91
92	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
93}
94
95atf_test_case zpool_clear_004_pos cleanup
96zpool_clear_004_pos_head()
97{
98	atf_set "descr" "Verify 'zpool clear' can work on spare vdevs"
99	atf_set "require.progs" "ksh93 zpool"
100	atf_set "timeout" 2100
101}
102zpool_clear_004_pos_body()
103{
104	. $(atf_get_srcdir)/../../../include/default.cfg
105	. $(atf_get_srcdir)/zpool_clear.cfg
106
107	ksh93 $(atf_get_srcdir)/zpool_clear_004_pos.ksh || atf_fail "Testcase failed"
108}
109zpool_clear_004_pos_cleanup()
110{
111	. $(atf_get_srcdir)/../../../include/default.cfg
112	. $(atf_get_srcdir)/zpool_clear.cfg
113
114	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
115}
116
117atf_test_case zpool_clear_005_pos cleanup
118zpool_clear_005_pos_head()
119{
120	atf_set "descr" "'zpool clear' can online an UNAVAIL pool after all vdevs have reappeared"
121	atf_set "require.progs" "ksh93 gnop zpool"
122}
123zpool_clear_005_pos_body()
124{
125	atf_skip "Fails on OpenZFS, causing eventual deadlock. PR tests/248910"
126	. $(atf_get_srcdir)/../../../include/default.cfg
127	. $(atf_get_srcdir)/zpool_clear.cfg
128
129	verify_disk_count "$DISKS" 3
130	ksh93 $(atf_get_srcdir)/zpool_clear_005_pos.ksh || atf_fail "Testcase failed"
131}
132zpool_clear_005_pos_cleanup()
133{
134	. $(atf_get_srcdir)/../../../include/default.cfg
135	. $(atf_get_srcdir)/zpool_clear.cfg
136
137	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
138}
139
140
141
142atf_init_test_cases()
143{
144
145	atf_add_test_case zpool_clear_001_pos
146	atf_add_test_case zpool_clear_002_neg
147	atf_add_test_case zpool_clear_003_neg
148	atf_add_test_case zpool_clear_004_pos
149	atf_add_test_case zpool_clear_005_pos
150}
151