1#!/usr/local/bin/ksh93 -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 2007 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26
27. $STF_SUITE/include/libtest.kshlib
28
29#################################################################################
30#
31# __stc_assertion_start
32#
33# ID: zpool_import_010_pos
34#
35# DESCRIPTION:
36#	'zpool -D -a' can import all the specified directories destroyed pools.
37#
38# STRATEGY:
39#	1. Create a 5 ways mirror pool A with dev0/1/2/3/4, then destroy it.
40#	2. Create a stripe pool B with dev1. Then destroy it.
41#	3. Create a raidz2 pool C with dev2/3/4. Then destroy it.
42#	4. Create a raidz pool D with dev3/4. Then destroy it.
43#	5. Create a stripe pool E with dev4. Then destroy it.
44#	6. Verify 'zpool import -D -a' recover all the pools.
45#
46# TESTABILITY: explicit
47#
48# TEST_AUTOMATION_LEVEL: automated
49#
50# CODING_STATUS: COMPLETED (2006-06-12)
51#
52# __stc_assertion_end
53#
54################################################################################
55
56verify_runnable "global"
57
58function cleanup
59{
60	typeset dt
61	for dt in $poolE $poolD $poolC $poolB $poolA; do
62		destroy_pool $dt
63	done
64
65	log_must $RM -rf $DEVICE_DIR/*
66	typeset i=0
67	while (( i < $MAX_NUM )); do
68		log_must create_vdevs ${DEVICE_DIR}/${DEVICE_FILE}$i
69		((i += 1))
70	done
71}
72
73log_assert "'zpool -D -a' can import all the specified directories " \
74	"destroyed pools."
75log_onexit cleanup
76
77poolA=poolA.${TESTCASE_ID}
78poolB=poolB.${TESTCASE_ID}
79poolC=poolC.${TESTCASE_ID}
80poolD=poolD.${TESTCASE_ID}
81poolE=poolE.${TESTCASE_ID}
82
83log_must $ZPOOL create $poolA mirror $VDEV0 $VDEV1 $VDEV2 $VDEV3 $VDEV4
84log_must $ZPOOL destroy $poolA
85
86log_must $ZPOOL create $poolB $VDEV1
87log_must $ZPOOL destroy $poolB
88
89log_must $ZPOOL create $poolC raidz2 $VDEV2 $VDEV3 $VDEV4
90log_must $ZPOOL destroy $poolC
91
92log_must $ZPOOL create $poolD raidz $VDEV3 $VDEV4
93log_must $ZPOOL destroy $poolD
94
95log_must $ZPOOL create $poolE $VDEV4
96log_must $ZPOOL destroy $poolE
97
98log_must $ZPOOL import -d $DEVICE_DIR -D -f -a
99
100for dt in $poolA $poolB $poolC $poolD $poolE; do
101	log_must datasetexists $dt
102done
103
104log_pass "'zpool -D -a' test passed."
105