]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_005_pos.ksh
MFC r353117-r353118, r353281-r353282, r353284-r353289, r353309-r353310, r353360-r3533...
[FreeBSD/FreeBSD.git] / tests / sys / cddl / zfs / tests / cli_root / zpool_add / zpool_add_005_pos.ksh
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
62 verify_runnable "global"
63
64 set_disks
65
66 function cleanup
67 {
68         poolexists "$TESTPOOL" && \
69                 destroy_pool "$TESTPOOL"
70         poolexists "$TESTPOOL1" && \
71                 destroy_pool "$TESTPOOL1"
72
73         $DUMPON -r $dump_dev
74 }
75
76 log_assert "'zpool add' should fail with inapplicable scenarios."
77
78 log_onexit cleanup
79
80 mnttab_dev=$(find_mnttab_dev)
81 vfstab_dev=$(find_vfstab_dev)
82 dump_dev=${DISK2}
83
84 create_pool "$TESTPOOL" "${DISK0}"
85 log_must poolexists "$TESTPOOL"
86
87 create_pool "$TESTPOOL1" "${DISK1}"
88 log_must poolexists "$TESTPOOL1"
89 log_mustnot $ZPOOL add -f "$TESTPOOL" ${DISK1}
90
91 log_mustnot $ZPOOL add -f "$TESTPOOL" $mnttab_dev
92
93 log_mustnot $ZPOOL add -f "$TESTPOOL" $vfstab_dev
94
95 log_must $DUMPON $dump_dev
96 log_mustnot $ZPOOL add -f "$TESTPOOL" $dump_dev
97
98 log_pass "'zpool add' should fail with inapplicable scenarios."