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# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24# Use is subject to license terms. 25# 26 27. $STF_SUITE/include/libtest.kshlib 28. $STF_SUITE/tests/zvol/zvol_common.kshlib 29 30############################################################################### 31# 32# __stc_assertion_start 33# 34# ID: zvol_swap_002_pos 35# 36# DESCRIPTION: 37# Using a zvol as swap space, fill with files until ENOSPC returned. 38# 39# STRATEGY: 40# 1. Create a pool 41# 2. Create a zvol volume 42# 3. Add zvol to swap space 43# 4. Fill swap space until ENOSPC is returned 44# 45# TESTABILITY: explicit 46# 47# TEST_AUTOMATION_LEVEL: automated 48# 49# CODING_STATUS: COMPLETED (2005-07-04) 50# 51# __stc_assertion_end 52# 53################################################################################ 54 55log_unsupported "Fill swap will cause system hang, hide this case temporarily." 56 57verify_runnable "global" 58 59function cleanup 60{ 61 $RM -rf $TMPDIR/$TESTDIR 62 63 if is_swap_inuse $voldev ; then 64 log_must $SWAP -d $voldev 65 fi 66} 67 68log_assert "Using a zvol as swap space, fill with files until ENOSPC returned." 69 70if ! is_dumpswap_supported $TESTPOOL ; then 71 log_unsupported "ZVOLs as swap devices are not currently supported." 72fi 73 74log_onexit cleanup 75 76voldev=/dev/zvol/$TESTPOOL/$TESTVOL 77 78$SWAP -l | $GREP zvol 79if (( $? != 0 )) ; then 80 log_note "Add zvol volume as swap space" 81 log_must $SWAP -a $voldev 82fi 83 84typeset -i filenum=0 85typeset -i retval=0 86typeset testdir=$TMPDIR/$TESTDIR 87 88log_note "Attempt to fill $TMPDIR until ENOSPC is hit" 89fill_fs $testdir -1 100 $BLOCKSZ $NUM_WRITES 90retval=$? 91 92(( $retval != $ENOSPC )) && \ 93 log_fail "ENOSPC was not returned, $retval was returned instead" 94 95log_pass "ENOSPC was returned as expected" 96