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 2007 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26 27. $STF_SUITE/include/libtest.kshlib 28 29################################################################################# 30# 31# __stc_assertion_start 32# 33# ID: zvol_swap_004_pos 34# 35# DESCRIPTION: 36# The minimum volume size for swap should be a multiple of 2 pagesize 37# bytes. 38# 39# STRATEGY: 40# 1. Get test system page size. 41# 2. Create different size volumes. 42# 3. Verify 'swap -a' has correct behaviour. 43# 44# TESTABILITY: explicit 45# 46# TEST_AUTOMATION_LEVEL: automated 47# 48# CODING_STATUS: COMPLETED (2006-12-12) 49# 50# __stc_assertion_end 51# 52################################################################################ 53 54verify_runnable "global" 55 56function cleanup 57{ 58 typeset tmp 59 for tmp in $swaplist ; do 60 log_must $SWAP -d $tmp 61 done 62 for tmp in $vollist ; do 63 log_must $ZFS destroy $tmp 64 done 65} 66 67log_assert "The minimum volume size should be a multiple of 2 pagesize bytes." 68log_onexit cleanup 69 70test_requires SWAP 71 72typeset -i volblksize pagesize=$($PAGESIZE) 73((volblksize = pagesize / 2)) 74# 75# volume size for swap Expected results 76# 77set -A array \ 78 $((volblksize)) "fail" \ 79 $((2 * volblksize)) "fail" \ 80 $((3 * volblksize)) "fail" \ 81 $((4 * volblksize)) "pass" \ 82 $((5 * volblksize)) "pass" \ 83 $((6 * volblksize)) "pass" 84 85typeset -i i=0 86while ((i < ${#array[@]})); do 87 vol="$TESTPOOL/vol_${array[$i]}" 88 vollist="$vollist $vol" 89 90 log_must $ZFS create -b $volblksize -V ${array[$i]} $vol 91 92 swapname="/dev/zvol/$vol" 93 if [[ ${array[((i+1))]} == "fail" ]]; then 94 log_mustnot $SWAP -a $swapname 95 else 96 log_must $SWAP -a $swapname 97 swaplist="$swaplist $swapname" 98 fi 99 100 ((i += 2)) 101done 102 103log_pass "Verify the minimum volume size pass." 104