QA updates to enable simplified large filesystem testing
[xfstests-dev.git] / 015
1 #! /bin/sh
2 # XFS QA Test No. 015
3 #
4 # check out-of-space behaviour
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
8
9 # This program is free software; you can redistribute it and/or modify it
10 # under the terms of version 2 of the GNU General Public License as
11 # published by the Free Software Foundation.
12
13 # This program is distributed in the hope that it would be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17 # Further, this software is distributed without any warranty that it is
18 # free of the rightful claim of any third person regarding infringement
19 # or the like.  Any license provided herein, whether implied or
20 # otherwise, applies only to this software file.  Patent licenses, if
21 # any, provided herein do not apply to combinations of this program with
22 # other software, or any other product whatsoever.
23
24 # You should have received a copy of the GNU General Public License along
25 # with this program; if not, write the Free Software Foundation, Inc., 59
26 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
27
28 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
29 # Mountain View, CA  94043, or:
30
31 # http://www.sgi.com 
32
33 # For further information regarding this notice, see: 
34
35 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
36 #-----------------------------------------------------------------------
37 #
38 # creator
39 owner=dxm@sgi.com
40
41 seq=`basename $0`
42 echo "QA output created by $seq"
43
44 here=`pwd`
45 tmp=/tmp/$$
46 status=1        # success is the default!
47
48 # get standard environment, filters and checks
49 . ./common.rc
50 . ./common.filter
51
52 _cleanup()
53 {
54         umount $SCRATCH_MNT
55 }
56
57 trap "_cleanup; exit \$status" 0 1 2 3 15
58
59 _free()
60 {
61     _df_dir $SCRATCH_MNT | $AWK_PROG '{ print $5 }'
62 }
63
64 _filter_dd()
65 {
66     $AWK_PROG '
67         /records in/                { next }
68         /records out/               { next }
69         /No space left on device/   { print "   !!! disk full (expected)" 
70                                       next }
71                                     { print "   *** " $0 }
72     '
73 }
74
75 # real QA test starts here
76 _require_scratch
77
78 _scratch_mkfs_xfs -d size=50m >/dev/null
79 _scratch_mount
80 out=$SCRATCH_MNT/fillup.$$
81 rm -f $seq.full
82
83 free0=`_free`
84 if [ -z "$free0" ]
85 then
86     echo "   *** failed to get free space (0)"
87     exit 1
88 fi
89 echo "free space at start $free0" >> $seq.full
90
91 echo "fill disk:"       # well, filesystem really - not disk
92
93 POSIXLY_CORRECT=yes dd if=/dev/zero of=$out bs=1024k 2>&1 | _filter_dd
94
95 echo "check free space:"
96
97 free1=`_free`
98 if [ -z "$free1" ]
99 then
100     echo "   *** failed to get free space (1)"
101     exit 1
102 fi
103 echo "free space after fill $free1" >> $seq.full
104
105 if [ ! -e $out ]
106 then
107     echo "   *** file not created"
108     exit 1
109 fi
110
111 if [ ! -s $out ]
112 then
113     echo "   *** file created with zero length"
114     ls -l $out
115     exit 1
116 fi
117
118 echo "delete fill:"
119
120 if ! rm $out
121 then
122     echo "   *** file not deleted"
123     exit 1
124 fi
125
126 if [ -e $out ]
127 then
128     echo "   *** file still exists"
129     ls -l $out
130     exit 1
131 fi
132
133 echo "check free space:"
134
135 free2=`_free`
136 if [ -z "$free2" ]
137 then
138     echo "   *** failed to get free space (2)"
139     exit 1
140 fi
141 echo "free space after delete $free2" >> $seq.full
142
143 echo -n "   !!! "
144 _within_tolerance "free space" $free2 $free0 1% -v
145
146 status=0
147 exit