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 2008 Sun Microsystems, Inc.  All rights reserved.
27# Use is subject to license terms.
28#
29# ident	"@(#)bootfs_005_neg.ksh	1.2	08/02/27 SMI"
30#
31
32. $STF_SUITE/include/libtest.kshlib
33. $STF_SUITE/tests/cli_root/zpool_upgrade/zpool_upgrade.cfg
34. $STF_SUITE/tests/cli_root/zpool_upgrade/zpool_upgrade.kshlib
35
36################################################################################
37#
38# __stc_assertion_start
39#
40# ID:  bootfs_005_neg
41#
42# DESCRIPTION:
43#
44# Boot properties cannot be set on pools with older versions
45#
46# STRATEGY:
47# 1. Copy and import some pools of older versions
48# 2. Create a filesystem on each
49# 3. Verify that zpool set bootfs fails on each
50#
51# TESTABILITY: explicit
52#
53# TEST_AUTOMATION_LEVEL: automated
54#
55# CODING_STATUS: COMPLETED (2007-03-05)
56#
57# __stc_assertion_end
58#
59################################################################################
60
61verify_runnable "global"
62
63function cleanup {
64
65	#
66	# we need destroy pools that created on top of $TESTPOOL first
67	#
68	typeset pool_name
69	for config in $CONFIGS; do
70		pool_name=$($ENV| $GREP "ZPOOL_VERSION_${config}_NAME"\
71                	| $AWK -F= '{print $2}')
72		if poolexists $pool_name; then
73			log_must $ZPOOL destroy -f $pool_name
74		fi
75	done
76	destroy_pool $TESTPOOL
77}
78
79$ZPOOL set 2>&1 | $GREP bootfs > /dev/null
80if [ $? -ne 0 ]
81then
82        log_unsupported "bootfs pool property not supported on this release."
83fi
84
85log_assert "Boot properties cannot be set on pools with older versions"
86
87# These are configs from zpool_upgrade.cfg - see that file for more info.
88CONFIGS="1 2 3"
89
90log_onexit cleanup
91log_must $ZPOOL create -f $TESTPOOL $DISKS
92
93for config in $CONFIGS
94do
95	create_old_pool $config
96	POOL_NAME=$($ENV| $GREP "ZPOOL_VERSION_${config}_NAME"\
97		| $AWK -F= '{print $2}')
98	log_must $ZFS create $POOL_NAME/$FS
99	log_mustnot $ZPOOL set bootfs=$POOL_NAME/$FS $POOL_NAME
100	log_must destroy_upgraded_pool $config
101done
102
103log_pass "Boot properties cannot be set on pools with older versions"
104