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