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# 29# Copyright (c) 2012 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 [[ -f $CPATH ]] && log_must $RM $CPATH 51} 52 53log_onexit cleanup 54log_assert "zpool create can create pools with specified properties" 55 56if [[ -n $DISK ]]; then 57 disk=$DISK 58else 59 disk=$DISK0 60fi 61 62# 63# we don't include "root" property in this list, as it requires both "cachefile" 64# and "root" to be set at the same time. A test for this is included in 65# ../../root. 66# 67typeset props=("autoreplace" "delegation" "cachefile" "version" "autoexpand") 68typeset vals=("off" "off" "$CPATH" "3" "on") 69 70typeset -i i=0; 71while [ $i -lt "${#props[@]}" ] 72do 73 log_must $ZPOOL create -o ${props[$i]}=${vals[$i]} $TESTPOOL $disk 74 RESULT=$(get_pool_prop ${props[$i]} $TESTPOOL) 75 if [[ $RESULT != ${vals[$i]} ]] 76 then 77 $ZPOOL get all $TESTPOOL 78 log_fail "Pool was created without setting the ${props[$i]} " \ 79 "property" 80 fi 81 log_must $ZPOOL destroy $TESTPOOL 82 ((i = i + 1)) 83done 84 85# Destroy our pool 86poolexists $TESTPOOL && destroy_pool $TESTPOOL 87 88# pick two properties, and verify we can create with those as well 89log_must $ZPOOL create -o delegation=off -o cachefile=$CPATH $TESTPOOL $disk 90RESULT=$(get_pool_prop delegation $TESTPOOL) 91if [[ $RESULT != off ]] 92then 93 $ZPOOL get all $TESTPOOL 94 log_fail "Pool created without the delegation prop." 95fi 96 97RESULT=$(get_pool_prop cachefile $TESTPOOL) 98if [[ $RESULT != $CPATH ]] 99then 100 $ZPOOL get all $TESTPOOL 101 log_fail "Pool created without the cachefile prop." 102fi 103 104log_pass "zpool create can create pools with specified properties" 105