xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/bootfs/bootfs_002_neg.ksh (revision 5e989a96186a37eb528fb7bb4d28a150874ec799)
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 2009 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# Invalid datasets are rejected as boot property values
34#
35# STRATEGY:
36#
37# 1. Create a snapshot and a zvol
38# 2. Verify that we can't set the bootfs to those datasets
39#
40
41verify_runnable "global"
42
43function cleanup {
44	if snapexists $TESTPOOL/$TESTFS@snap
45	then
46		$ZFS destroy $TESTPOOL/$TESTFS@snap
47	fi
48	if datasetexists $TESTPOOL/$TESTFS
49	then
50		log_must $ZFS destroy $TESTPOOL/$TESTFS
51	fi
52	if datasetexists $TESTPOOL/vol
53	then
54		log_must $ZFS destroy $TESTPOOL/vol
55	fi
56	if poolexists $TESTPOOL
57	then
58		log_must $ZPOOL destroy $TESTPOOL
59	fi
60}
61
62
63$ZPOOL set 2>&1 | $GREP bootfs > /dev/null
64if [ $? -ne 0 ]
65then
66	log_unsupported "bootfs pool property not supported on this release."
67fi
68
69log_assert "Invalid datasets are rejected as boot property values"
70log_onexit cleanup
71
72DISK=${DISKS%% *}
73
74log_must $ZPOOL create $TESTPOOL $DISK
75log_must $ZFS create $TESTPOOL/$TESTFS
76log_must $ZFS snapshot $TESTPOOL/$TESTFS@snap
77log_must $ZFS create -V 10m $TESTPOOL/vol
78
79log_mustnot $ZPOOL set bootfs=$TESTPOOL/$TESTFS@snap $TESTPOOL
80log_mustnot $ZPOOL set bootfs=$TESTPOOL/vol $TESTPOOL
81
82log_pass "Invalid datasets are rejected as boot property values"
83