]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/bootfs/bootfs_006_pos.ksh
fc3ca142f8f0346eab0c85b1908620c23d8e54ec
[mirror_zfs.git] / tests / zfs-tests / tests / functional / bootfs / bootfs_006_pos.ksh
1 #!/bin/ksh -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 2008 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
26 #
27
28 . $STF_SUITE/include/libtest.shlib
29
30 #
31 # DESCRIPTION:
32 #
33 # Pools of correct vdev types accept boot property
34 #
35 # STRATEGY:
36 # 1. create pools of each vdev type (raid, raidz, raidz2, mirror + hotspares)
37 # 2. verify we can set bootfs on each pool type according to design
38 #
39
40 verify_runnable "global"
41
42
43 $ZPOOL set 2>&1 | $GREP bootfs > /dev/null
44 if [ $? -ne 0 ]
45 then
46 log_unsupported "bootfs pool property not supported on this release."
47 fi
48
49 VDEV1=$TESTDIR/bootfs_006_pos_a.$$.dat
50 VDEV2=$TESTDIR/bootfs_006_pos_b.$$.dat
51 VDEV3=$TESTDIR/bootfs_006_pos_c.$$.dat
52 VDEV4=$TESTDIR/bootfs_006_pos_d.$$.dat
53
54 function verify_bootfs { # $POOL
55 POOL=$1
56 log_must $ZFS create $POOL/$TESTFS
57
58 log_must $ZPOOL set bootfs=$POOL/$TESTFS $POOL
59 VAL=$($ZPOOL get bootfs $POOL | $TAIL -1 | $AWK '{print $3}' )
60 if [ $VAL != "$POOL/$TESTFS" ]
61 then
62 log_must $ZPOOL status -v $POOL
63 log_fail \
64 "set/get failed on $POOL - expected $VAL == $POOL/$TESTFS"
65 fi
66 log_must $ZPOOL destroy $POOL
67 }
68
69 function verify_no_bootfs { # $POOL
70 POOL=$1
71 log_must $ZFS create $POOL/$TESTFS
72 log_mustnot $ZPOOL set bootfs=$POOL/$TESTFS $POOL
73 VAL=$($ZPOOL get bootfs $POOL | $TAIL -1 | $AWK '{print $3}' )
74 if [ $VAL == "$POOL/$TESTFS" ]
75 then
76 log_must $ZPOOL status -v $POOL
77 log_fail "set/get unexpectedly failed $VAL != $POOL/$TESTFS"
78 fi
79 log_must $ZPOOL destroy $POOL
80 }
81
82 function cleanup {
83 if poolexists $TESTPOOL
84 then
85 log_must $ZPOOL destroy $TESTPOOL
86 fi
87 log_must $RM $VDEV1 $VDEV2 $VDEV3 $VDEV4
88 }
89
90 log_assert "Pools of correct vdev types accept boot property"
91
92
93
94 log_onexit cleanup
95 log_must $MKFILE 64m $VDEV1 $VDEV2 $VDEV3 $VDEV4
96
97
98 ## the following configurations are supported bootable pools
99
100 # normal
101 log_must $ZPOOL create $TESTPOOL $VDEV1
102 verify_bootfs $TESTPOOL
103
104 # normal + hotspare
105 log_must $ZPOOL create $TESTPOOL $VDEV1 spare $VDEV2
106 verify_bootfs $TESTPOOL
107
108 # mirror
109 log_must $ZPOOL create $TESTPOOL mirror $VDEV1 $VDEV2
110 verify_bootfs $TESTPOOL
111
112 # mirror + hotspare
113 log_must $ZPOOL create $TESTPOOL mirror $VDEV1 $VDEV2 spare $VDEV3
114 verify_bootfs $TESTPOOL
115
116 ## the following configurations are not supported as bootable pools
117
118 # stripe
119 log_must $ZPOOL create $TESTPOOL $VDEV1 $VDEV2
120 verify_no_bootfs $TESTPOOL
121
122 # stripe + hotspare
123 log_must $ZPOOL create $TESTPOOL $VDEV1 $VDEV2 spare $VDEV3
124 verify_no_bootfs $TESTPOOL
125
126 # raidz
127 log_must $ZPOOL create $TESTPOOL raidz $VDEV1 $VDEV2
128 verify_no_bootfs $TESTPOOL
129
130 # raidz + hotspare
131 log_must $ZPOOL create $TESTPOOL raidz $VDEV1 $VDEV2 spare $VDEV3
132 verify_no_bootfs $TESTPOOL
133
134 # raidz2
135 log_must $ZPOOL create $TESTPOOL raidz2 $VDEV1 $VDEV2 $VDEV3
136 verify_no_bootfs $TESTPOOL
137
138 # raidz2 + hotspare
139 log_must $ZPOOL create $TESTPOOL raidz2 $VDEV1 $VDEV2 $VDEV3 spare $VDEV4
140 verify_no_bootfs $TESTPOOL
141
142 log_pass "Pools of correct vdev types accept boot property"