1 #! /usr/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 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
26 #
27
28 ################################################################################
29 #
30 # __stc_assertion_start
31 #
32 # ID: dir_pos002
33 #
34 # DESCRIPTION:
35 # Looply create a large amount of dirs with large files until
36 # no space is available, the system should be stable.
37 #
38 # STRATEGY:
39 # - Looply create a large amount of dirs which include some files
40 # until the error occurs.
41 # - Verify the filesystem is full and system is stable
42 # - Remove all dirs and files
43 #
44 # TESTABILITY: explicit
45 #
46 # TEST_AUTOMATION_LEVEL: automated
47 #
48 # __stc_assertion_end
49 #
50 ################################################################################
51
52 . ${STF_SUITE}/include/nfsgen.kshlib
53
54 readonly FILE=$(whence -p ${0})
55 readonly NAME=$(basename $0)
56 readonly DIR=$(dirname $0)
57
58 export _NFS_STF_DEBUG=$_NFS_STF_DEBUG:$NFSGEN_DEBUG
59 [[ :$NFSGEN_DEBUG: = *:${NAME}:* \
60 || :${NFSGEN_DEBUG}: = *:all:* ]] && set -x
61
62 # Extract and print assertion information from this source script to journal
63 extract_assertion_info $FILE
64
65 function assert_cleanup {
66 [[ :$NFSGEN_DEBUG: = *:${NAME}:* \
67 || :${NFSGEN_DEBUG}: = *:all:* ]] && set -x
68
69 ret=$STF_PASS
70 if [[ ! -z $1 ]]; then
71 cat $1 | grep "No space left on device" > /dev/null 2>&1
72 if (($? != 0)); then
73 cat $1
74 ret=$STF_FAIL
75 fi
76 fi
77 RUN_CHECK rm -rf $testdir || ret=$STF_FAIL
78 cleanup $ret
79 }
80
81 #
82 # Create a large amount of directories which include some small
83 # files and a large files until the space is full
84 #
85 testdir=${MNTDIR}/${NAME}.`hostname`.$$
86 typeset -i num=0
87 while (($num < 10 )); do
88 curdir=$testdir/$num
89 RUN_CHECK mkdir -p $curdir > $STF_TMPDIR/mkdir.$$ 2>&1 \
90 || assert_cleanup $STF_TMPDIR/mkdir.$$
91 RUN_CHECK create_small_files $curdir 10 > $STF_TMPDIR/sfile.$$ 2>&1 \
92 || assert_cleanup $STF_TMPDIR/sfile.$$
93 RUN_CHECK mkfile 100m $curdir/file_100m > $STF_TMPDIR/lfile.$$ 2>&1 \
94 || assert_cleanup $STF_TMPDIR/lfile.$$
95 num=$((num + 1))
96 done
97
98 assert_cleanup
99