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