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 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 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# 'zpool create [-R root][-m mountpoint] <pool> <vdev> ...' can create an 38# alternate root pool or a new pool mounted at the specified mountpoint. 39# 40# STRATEGY: 41# 1. Create a pool with '-m' option 42# 2. Verify the pool is mounted at the specified mountpoint 43# 44 45verify_runnable "global" 46 47function cleanup 48{ 49 poolexists $TESTPOOL && \ 50 log_must zpool destroy -f $TESTPOOL 51 52 for dir in $TESTDIR $TESTDIR1; do 53 [[ -d $dir ]] && rm -rf $dir 54 done 55} 56 57log_assert "'zpool create [-R root][-m mountpoint] <pool> <vdev> ...' can create" \ 58 "an alternate pool or a new pool mounted at the specified mountpoint." 59log_onexit cleanup 60 61set -A pooltype "" "mirror" "raidz" "raidz1" "raidz2" 62 63# 64# cleanup the pools created in previous case if zpool_create_004_pos timedout 65# 66for pool in $TESTPOOL2 $TESTPOOL1 $TESTPOOL; do 67 if poolexists $pool; then 68 destroy_pool $pool 69 fi 70done 71 72#prepare raw file for file disk 73[[ -d $TESTDIR ]] && rm -rf $TESTDIR 74log_must mkdir -p $TESTDIR 75typeset -i i=1 76while (( i < 4 )); do 77 log_must mkfile $FILESIZE $TESTDIR/file.$i 78 79 (( i = i + 1 )) 80done 81 82#Remove the directory with name as pool name if it exists 83[[ -d /$TESTPOOL ]] && rm -rf /$TESTPOOL 84file=$TESTDIR/file 85 86for opt in "-R $TESTDIR1" "-m $TESTDIR1" \ 87 "-R $TESTDIR1 -m $TESTDIR1" "-m $TESTDIR1 -R $TESTDIR1" 88do 89 i=0 90 while (( i < ${#pooltype[*]} )); do 91 #Remove the testing pool and its mount directory 92 poolexists $TESTPOOL && \ 93 log_must zpool destroy -f $TESTPOOL 94 [[ -d $TESTDIR1 ]] && rm -rf $TESTDIR1 95 log_must zpool create $opt $TESTPOOL ${pooltype[i]} \ 96 $file.1 $file.2 $file.3 97 ! poolexists $TESTPOOL && \ 98 log_fail "Createing pool with $opt fails." 99 mpt=`zfs mount | egrep "^$TESTPOOL[^/]" | awk '{print $2}'` 100 (( ${#mpt} == 0 )) && \ 101 log_fail "$TESTPOOL created with $opt is not mounted." 102 mpt_val=$(get_prop "mountpoint" $TESTPOOL) 103 [[ "$mpt" != "$mpt_val" ]] && \ 104 log_fail "The value of mountpoint property is different\ 105 from the output of zfs mount" 106 if [[ "$opt" == "-m $TESTDIR1" ]]; then 107 [[ ! -d $TESTDIR1 ]] && \ 108 log_fail "$TESTDIR1 is not created auotmatically." 109 [[ "$mpt" != "$TESTDIR1" ]] && \ 110 log_fail "$TESTPOOL is not mounted on $TESTDIR1." 111 elif [[ "$opt" == "-R $TESTDIR1" ]]; then 112 [[ ! -d $TESTDIR1/$TESTPOOL ]] && \ 113 log_fail "$TESTDIR1/$TESTPOOL is not created auotmatically." 114 [[ "$mpt" != "$TESTDIR1/$TESTPOOL" ]] && \ 115 log_fail "$TESTPOOL is not mounted on $TESTDIR1/$TESTPOOL." 116 else 117 [[ ! -d ${TESTDIR1}$TESTDIR1 ]] && \ 118 log_fail "${TESTDIR1}$TESTDIR1 is not created automatically." 119 [[ "$mpt" != "${TESTDIR1}$TESTDIR1" ]] && \ 120 log_fail "$TESTPOOL is not mounted on ${TESTDIR1}$TESTDIR1." 121 fi 122 [[ -d /$TESTPOOL ]] && \ 123 log_fail "The default mountpoint /$TESTPOOL is created" \ 124 "while with $opt option." 125 126 (( i = i + 1 )) 127 done 128done 129 130log_pass "'zpool create [-R root][-m mountpoint] <pool> <vdev> ...' works as expected." 131