xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/bootfs/bootfs_006_pos.ksh (revision b6805bf78d2bbbeeaea8909a05623587b42d58b3)
1#!/usr/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
40verify_runnable "global"
41
42
43$ZPOOL set 2>&1 | $GREP bootfs > /dev/null
44if [ $? -ne 0 ]
45then
46	log_unsupported "bootfs pool property not supported on this release."
47fi
48
49VDEV1=/bootfs_006_pos_a.$$.dat
50VDEV2=/bootfs_006_pos_b.$$.dat
51VDEV3=/bootfs_006_pos_c.$$.dat
52VDEV4=/bootfs_006_pos_d.$$.dat
53
54function 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
69function 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
82function 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
90log_assert "Pools of correct vdev types accept boot property"
91
92
93
94log_onexit cleanup
95log_must $MKFILE 64m $VDEV1 $VDEV2 $VDEV3 $VDEV4
96
97
98## the following configurations are supported bootable pools
99
100# normal
101log_must $ZPOOL create $TESTPOOL $VDEV1
102verify_bootfs $TESTPOOL
103
104# normal + hotspare
105log_must $ZPOOL create $TESTPOOL $VDEV1 spare $VDEV2
106verify_bootfs $TESTPOOL
107
108# mirror
109log_must $ZPOOL create $TESTPOOL mirror $VDEV1 $VDEV2
110verify_bootfs $TESTPOOL
111
112# mirror + hotspare
113log_must $ZPOOL create $TESTPOOL mirror $VDEV1 $VDEV2 spare $VDEV3
114verify_bootfs $TESTPOOL
115
116## the following configurations are not supported as bootable pools
117
118# stripe
119log_must $ZPOOL create $TESTPOOL $VDEV1 $VDEV2
120verify_no_bootfs $TESTPOOL
121
122# stripe + hotspare
123log_must $ZPOOL create $TESTPOOL $VDEV1 $VDEV2 spare $VDEV3
124verify_no_bootfs $TESTPOOL
125
126# raidz
127log_must $ZPOOL create $TESTPOOL raidz $VDEV1 $VDEV2
128verify_no_bootfs $TESTPOOL
129
130# raidz + hotspare
131log_must $ZPOOL create $TESTPOOL raidz $VDEV1 $VDEV2 spare $VDEV3
132verify_no_bootfs $TESTPOOL
133
134# raidz2
135log_must $ZPOOL create $TESTPOOL raidz2 $VDEV1 $VDEV2 $VDEV3
136verify_no_bootfs $TESTPOOL
137
138# raidz2 + hotspare
139log_must $ZPOOL create $TESTPOOL raidz2 $VDEV1 $VDEV2 $VDEV3 spare $VDEV4
140verify_no_bootfs $TESTPOOL
141
142log_pass "Pools of correct vdev types accept boot property"
143