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. $STF_SUITE/include/libtest.kshlib 27 28# ########################################################################## 29# 30# start __stf_assertion__ 31# 32# ASSERTION: largest_pool_001 33# 34# DESCRIPTION: 35# The largest pool can be created and a dataset in that 36# pool can be created and mounted. 37# 38# STRATEGY: 39# create a pool which will contain a volume device. 40# create a volume device of desired sizes. 41# create the largest pool allowed using the volume vdev. 42# create and mount a dataset in the largest pool. 43# create some files in the zfs file system. 44# do some zpool list commands and parse the output. 45# 46# end __stf_assertion__ 47# 48# ########################################################################## 49 50verify_runnable "global" 51 52# 53# Parse the results of zpool & zfs creation with specified size 54# 55# $1: volume size 56# 57# return value: 58# 0 -> success 59# 1 -> failure 60# 61function parse_expected_output 62{ 63 UNITS=`$ECHO $1 | $SED -e 's/^\([0-9].*\)\([a-z].\)/\2/'` 64 case "$UNITS" in 65 'mb') CHKUNIT="M" ;; 66 'gb') CHKUNIT="G" ;; 67 'tb') CHKUNIT="T" ;; 68 'pb') CHKUNIT="P" ;; 69 'eb') CHKUNIT="E" ;; 70 *) CHKUNIT="M" ;; 71 esac 72 73 log_note "Detect zpool $TESTPOOL in this test machine." 74 log_must eval "$ZPOOL list $TESTPOOL > $TMPDIR/j.${TESTCASE_ID}" 75 log_must eval "$GREP $TESTPOOL $TMPDIR/j.${TESTCASE_ID} | \ 76 $AWK '{print $2}' | $GREP $CHKUNIT" 77 78 log_note "Detect the file system in this test machine." 79 log_must eval "$DF -t zfs -h > $TMPDIR/j.${TESTCASE_ID}" 80 log_must eval "$GREP $TESTPOOL $TMPDIR/j.${TESTCASE_ID} | \ 81 $AWK '{print $2}' | $GREP $CHKUNIT" 82 83 return 0 84} 85 86# 87# Check and destroy zfs, volume & zpool remove the temporary files 88# 89function cleanup 90{ 91 log_note "Start cleanup the zfs and pool" 92 93 if datasetexists $TESTPOOL/$TESTFS ; then 94 if ismounted $TESTPOOL/$TESTFS ; then 95 log_must $ZFS unmount $TESTPOOL/$TESTFS 96 fi 97 log_must $ZFS destroy $TESTPOOL/$TESTFS 98 fi 99 100 destroy_pool $TESTPOOL 101 102 datasetexists $TESTPOOL2/$TESTVOL && \ 103 log_must $ZFS destroy $TESTPOOL2/$TESTVOL 104 105 destroy_pool $TESTPOOL2 106 107 $RM -f $TMPDIR/j.* > /dev/null 108} 109 110log_assert "The largest pool can be created and a dataset in that" \ 111 "pool can be created and mounted." 112 113# Set trigger. When the test case exit, cleanup is executed. 114log_onexit cleanup 115 116# ----------------------------------------------------------------------- 117# volume sizes with unit designations. 118# 119# Note: specifying the number '1' as size will not give the correct 120# units for 'df'. It must be greater than one. 121# ----------------------------------------------------------------------- 122typeset str 123typeset -i ret 124for volsize in $VOLSIZES; do 125 log_note "Create a pool which will contain a volume device" 126 create_pool $TESTPOOL2 "$DISKS" 127 128 log_note "Create a volume device of desired sizes: $volsize" 129 str=$($ZFS create -sV $volsize $TESTPOOL2/$TESTVOL 2>&1) 130 ret=$? 131 if (( ret != 0 )); then 132 if [[ $($ISAINFO -b) == 32 && \ 133 $str == *${VOL_LIMIT_KEYWORD1}* || \ 134 $str == *${VOL_LIMIT_KEYWORD2}* || \ 135 $str == *${VOL_LIMIT_KEYWORD3}* ]] 136 then 137 log_unsupported \ 138 "Max volume size is 1TB on 32-bit systems." 139 else 140 log_fail "$ZFS create -sV $volsize $TESTPOOL2/$TESTVOL" 141 fi 142 fi 143 144 log_note "Create the largest pool allowed using the volume vdev" 145 create_pool $TESTPOOL "$VOL_PATH" 146 147 log_note "Create a zfs file system in the largest pool" 148 log_must $ZFS create $TESTPOOL/$TESTFS 149 150 log_note "Parse the execution result" 151 parse_expected_output $volsize 152 153 log_note "unmount this zfs file system $TESTPOOL/$TESTFS" 154 log_must $ZFS unmount $TESTPOOL/$TESTFS 155 156 log_note "Destroy zfs, volume & zpool" 157 log_must $ZFS destroy $TESTPOOL/$TESTFS 158 destroy_pool $TESTPOOL 159 log_must $ZFS destroy $TESTPOOL2/$TESTVOL 160 destroy_pool $TESTPOOL2 161done 162 163log_pass "Dateset can be created, mounted & destroy in largest pool succeeded." 164