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_create_018_pos.ksh	1.4	09/06/22 SMI"
30#
31
32. $STF_SUITE/include/libtest.kshlib
33. $STF_SUITE/tests/cli_root/zpool_create/zpool_create.kshlib
34
35################################################################################
36#
37# __stc_assertion_start
38#
39# ID: zpool_create_018_pos
40#
41# DESCRIPTION:
42#
43# zpool create can create pools with specified properties
44#
45# STRATEGY:
46# 1. Create a pool with all editable properties
47# 2. Verify those properties are set
48# 3. Create a pool with two properties set
49# 4. Verify both properties are set correctly
50#
51# TESTABILITY: explicit
52#
53# TEST_AUTOMATION_LEVEL: automated
54#
55# CODING_STATUS: COMPLETED (2007-07-27)
56#
57# __stc_assertion_end
58#
59################################################################################
60
61function cleanup
62{
63	destroy_pool $TESTPOOL
64
65	if [[ -f $CPATH ]] ; then
66		log_must $RM $CPATH
67	fi
68}
69
70log_onexit cleanup
71log_assert "zpool create can create pools with specified properties"
72
73if [[ -n $DISK ]]; then
74	disk=$DISK
75else
76	disk=$DISK0
77fi
78
79# we don't include "root" property in this list, as it requires both "cachefile"
80# and "root" to be set at the same time. A test for this is included in
81# ../../root.
82set -A props "autoreplace" "delegation" "cachefile" "version"
83set -A vals  "off"         "off"        "$CPATH"   	    "3"
84
85if pool_prop_exist autoexpand ; then
86        set -A props ${props[*]} "autoexpand"
87        set -A vals ${vals[*]} "on"
88fi
89
90typeset -i i=0;
91while [ $i -lt "${#props[@]}" ]
92do
93	log_must $ZPOOL create -o ${props[$i]}=${vals[$i]} $TESTPOOL $disk
94	RESULT=$(get_pool_prop ${props[$i]} $TESTPOOL)
95	if [[ $RESULT != ${vals[$i]} ]]
96	then
97		$ZPOOL get all $TESTPOOL
98		log_fail "Pool was created without setting the ${props[$i]} property"
99	fi
100	destroy_pool $TESTPOOL
101        (( i = i + 1 ))
102done
103
104# pick two properties, and verify we can create with those as well
105log_must $ZPOOL create -o delegation=off -o cachefile=$CPATH $TESTPOOL $disk
106RESULT=$(get_pool_prop delegation $TESTPOOL)
107if [[ $RESULT != off ]]
108then
109	$ZPOOL get all $TESTPOOL
110	log_fail "Pool created without the delegation prop."
111fi
112
113RESULT=$(get_pool_prop cachefile $TESTPOOL)
114if [[ $RESULT != $CPATH ]]
115then
116	$ZPOOL get all $TESTPOOL
117	log_fail "Pool created without the cachefile prop."
118fi
119
120log_pass "zpool create can create pools with specified properties"
121