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 2008 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27# ident "@(#)zpool_create_005_pos.ksh 1.3 08/02/27 SMI" 28# 29. $STF_SUITE/include/libtest.kshlib 30. $STF_SUITE/tests/cli_root/zpool_create/zpool_create.kshlib 31 32################################################################################ 33# 34# __stc_assertion_start 35# 36# ID: zpool_create_005_pos 37# 38# DESCRIPTION: 39# 'zpool create [-R root][-m mountpoint] <pool> <vdev> ...' can create an 40# alternate root pool or a new pool mounted at the specified mountpoint. 41# 42# STRATEGY: 43# 1. Create a pool with '-m' option 44# 2. Verify the pool is mounted at the specified mountpoint 45# 46# TESTABILITY: explicit 47# 48# TEST_AUTOMATION_LEVEL: automated 49# 50# CODING_STATUS: COMPLETED (2006-08-04) 51# 52# __stc_assertion_end 53# 54################################################################################ 55 56verify_runnable "global" 57 58function cleanup 59{ 60 poolexists $TESTPOOL && \ 61 log_must $ZPOOL destroy -f $TESTPOOL 62 63 for dir in $TMPDIR/zpool_create_005_pos $TESTDIR1; do 64 [[ -d $dir ]] && $RM -rf $dir 65 done 66} 67 68log_assert "'zpool create [-R root][-m mountpoint] <pool> <vdev> ...' can create" \ 69 "an alternate pool or a new pool mounted at the specified mountpoint." 70log_onexit cleanup 71 72set -A pooltype "" "mirror" "raidz" "raidz1" "raidz2" 73 74#prepare raw file for file disk 75TDIR=$TMPDIR/zpool_create_005_pos 76FBASE=$TDIR/file 77log_must $MKDIR $TDIR 78log_must create_vdevs $FBASE.0 $FBASE.1 $FBASE.2 $FBASE.3 79#Remove the directory with name as pool name if it exists 80[[ -d /$TESTPOOL ]] && $RM -rf /$TESTPOOL 81 82for opt in "-R $TESTDIR1" "-m $TESTDIR1" \ 83 "-R $TESTDIR1 -m $TESTDIR1" "-m $TESTDIR1 -R $TESTDIR1" 84do 85 i=0 86 while (( i < ${#pooltype[*]} )); do 87 #Remove the testing pool and its mount directory 88 poolexists $TESTPOOL && \ 89 log_must $ZPOOL destroy -f $TESTPOOL 90 [[ -d $TESTDIR1 ]] && $RM -rf $TESTDIR1 91 log_must $ZPOOL create $opt $TESTPOOL ${pooltype[i]} \ 92 $FBASE.1 $FBASE.2 $FBASE.3 93 mpt=`$ZFS mount | $EGREP "^$TESTPOOL[^/]" | $AWK '{print $2}'` 94 (( ${#mpt} == 0 )) && \ 95 log_fail "$TESTPOOL created with $opt is not mounted." 96 mpt_val=$(get_prop "mountpoint" $TESTPOOL) 97 [[ "$mpt" != "$mpt_val" ]] && \ 98 log_fail "The value of mountpoint property is different\ 99 from the output of zfs mount" 100 if [[ "$opt" == "-R $TESTDIR1" ]]; then 101 expected_mpt=${TESTDIR1}/${TESTPOOL} 102 elif [[ "$opt" == "-m $TESTDIR1" ]]; then 103 expected_mpt=${TESTDIR1} 104 else 105 expected_mpt=${TESTDIR1}${TESTDIR1} 106 fi 107 [[ ! -d $expected_mpt ]] && \ 108 log_fail "$expected_mpt is not created auotmatically." 109 [[ "$mpt" != "$expected_mpt" ]] && \ 110 log_fail "$expected_mpt is mounted on ${mpt} instead of $expected_mpt." 111 112 [[ -d /$TESTPOOL ]] && \ 113 log_fail "The default mountpoint /$TESTPOOL is created" \ 114 "while with $opt option." 115 116 (( i = i + 1 )) 117 done 118done 119 120log_pass "'zpool create [-R root][-m mountpoint] <pool> <vdev> ...' works as expected." 121