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# $FreeBSD$
24
25#
26# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
27# Use is subject to license terms.
28#
29# ident	"@(#)zpool_add_005_pos.ksh	1.4	09/06/22 SMI"
30#
31. $STF_SUITE/include/libtest.kshlib
32. $STF_SUITE/tests/cli_root/zpool_add/zpool_add.kshlib
33
34################################################################################
35#
36# __stc_assertion_start
37#
38# ID: zpool_add_005_pos
39#
40# DESCRIPTION:
41#       'zpool add' should return fail if
42#	1. vdev is part of an active pool
43# 	2. vdev is currently mounted
44# 	3. vdev is in /etc/vfstab
45#	3. vdev is specified as the dedicated dump device
46#
47# STRATEGY:
48#	1. Create case scenarios
49#	2. For each scenario, try to add the device to the pool
50#	3. Verify the add operation get failed
51#
52# TESTABILITY: explicit
53#
54# TEST_AUTOMATION_LEVEL: automated
55#
56# CODING_STATUS: COMPLETED (2005-09-29)
57#
58# __stc_assertion_end
59#
60###############################################################################
61
62verify_runnable "global"
63
64set_disks
65
66function cleanup
67{
68	poolexists "$TESTPOOL" && \
69		destroy_pool "$TESTPOOL"
70	poolexists "$TESTPOOL1" && \
71		destroy_pool "$TESTPOOL1"
72
73	$DUMPON -r $dump_dev
74}
75
76log_assert "'zpool add' should fail with inapplicable scenarios."
77
78log_onexit cleanup
79
80mnttab_dev=$(find_mnttab_dev)
81vfstab_dev=$(find_vfstab_dev)
82dump_dev=${DISK2}
83
84create_pool "$TESTPOOL" "${DISK0}"
85log_must poolexists "$TESTPOOL"
86
87create_pool "$TESTPOOL1" "${DISK1}"
88log_must poolexists "$TESTPOOL1"
89log_mustnot $ZPOOL add -f "$TESTPOOL" ${DISK1}
90
91log_mustnot $ZPOOL add -f "$TESTPOOL" $mnttab_dev
92
93log_mustnot $ZPOOL add -f "$TESTPOOL" $vfstab_dev
94
95log_must $DUMPON $dump_dev
96log_mustnot $ZPOOL add -f "$TESTPOOL" $dump_dev
97
98log_pass "'zpool add' should fail with inapplicable scenarios."
99