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 https://opensource.org/licenses/CDDL-1.0.
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#
29# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
30#
31
32. $STF_SUITE/include/libtest.shlib
33. $STF_SUITE/tests/functional/cli_root/zpool_create/zpool_create.shlib
34
35#
36# DESCRIPTION:
37#
38# zpool create can create pools with specified properties
39#
40# STRATEGY:
41# 1. Create a pool with all editable properties
42# 2. Verify those properties are set
43# 3. Create a pool with two properties set
44# 4. Verify both properties are set correctly
45#
46
47function cleanup
48{
49	poolexists $TESTPOOL && destroy_pool $TESTPOOL
50	rm -f $CPATH
51}
52
53log_onexit cleanup
54log_assert "zpool create can create pools with specified properties"
55
56#
57# we don't include "root" property in this list, as it requires both "cachefile"
58# and "root" to be set at the same time. A test for this is included in
59# ../../root.
60#
61typeset props=("autoreplace" "delegation" "cachefile" "version" "autoexpand")
62typeset vals=("off" "off" "$CPATH" "3" "on")
63
64typeset -i i=0;
65while [ $i -lt "${#props[@]}" ]
66do
67	log_must zpool create -o ${props[$i]}=${vals[$i]} $TESTPOOL $DISK0
68	RESULT=$(get_pool_prop ${props[$i]} $TESTPOOL)
69	if [[ $RESULT != ${vals[$i]} ]]
70	then
71		zpool get all $TESTPOOL
72		log_fail "Pool was created without setting the ${props[$i]} " \
73		    "property"
74	fi
75	log_must zpool destroy $TESTPOOL
76	((i = i + 1))
77done
78
79# Destroy our pool
80poolexists $TESTPOOL && destroy_pool $TESTPOOL
81
82# pick two properties, and verify we can create with those as well
83log_must zpool create -o delegation=off -o cachefile=$CPATH $TESTPOOL $DISK0
84RESULT=$(get_pool_prop delegation $TESTPOOL)
85if [[ $RESULT != off ]]
86then
87	zpool get all $TESTPOOL
88	log_fail "Pool created without the delegation prop."
89fi
90
91RESULT=$(get_pool_prop cachefile $TESTPOOL)
92if [[ $RESULT != $CPATH ]]
93then
94	zpool get all $TESTPOOL
95	log_fail "Pool created without the cachefile prop."
96fi
97
98log_pass "zpool create can create pools with specified properties"
99