274: Many fixups
[xfstests-dev.git] / 015
1 #! /bin/bash
2 # FS 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
10 # modify it under the terms 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,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #
22 #-----------------------------------------------------------------------
23 #
24 # creator
25 owner=dxm@sgi.com
26
27 seq=`basename $0`
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=1        # success is the default!
33
34 # get standard environment, filters and checks
35 . ./common.rc
36 . ./common.filter
37
38 _cleanup()
39 {
40         umount $SCRATCH_MNT
41 }
42
43 trap "_cleanup; exit \$status" 0 1 2 3 15
44
45 _free()
46 {
47     _df_dir $SCRATCH_MNT | $AWK_PROG '{ print $5 }'
48 }
49
50 # real QA test starts here
51 _supported_fs generic
52 _supported_os IRIX Linux
53
54 _require_scratch
55 _require_nobigloopfs
56
57 _scratch_mkfs_sized `expr 50 \* 1024 \* 1024` >/dev/null 2>&1 \
58     || _fail "mkfs failed"
59 _scratch_mount || _fail "mount failed"
60 out=$SCRATCH_MNT/fillup.$$
61 rm -f $seq.full
62
63 free0=`_free`
64 if [ -z "$free0" ]
65 then
66     echo "   *** failed to get free space (0)"
67     exit 1
68 fi
69 echo "free space at start $free0" >> $seq.full
70
71 echo "fill disk:"       # well, filesystem really - not disk
72
73 POSIXLY_CORRECT=yes dd if=/dev/zero of=$out bs=1024k 2>&1 | _filter_dd
74
75 echo "check free space:"
76
77 free1=`_free`
78 if [ -z "$free1" ]
79 then
80     echo "   *** failed to get free space (1)"
81     exit 1
82 fi
83 echo "free space after fill $free1" >> $seq.full
84
85 if [ ! -e $out ]
86 then
87     echo "   *** file not created"
88     exit 1
89 fi
90
91 if [ ! -s $out ]
92 then
93     echo "   *** file created with zero length"
94     ls -l $out
95     exit 1
96 fi
97
98 echo "delete fill:"
99
100 if ! rm $out
101 then
102     echo "   *** file not deleted"
103     exit 1
104 fi
105
106 if [ -e $out ]
107 then
108     echo "   *** file still exists"
109     ls -l $out
110     exit 1
111 fi
112
113 echo "check free space:"
114
115 free2=`_free`
116 if [ -z "$free2" ]
117 then
118     echo "   *** failed to get free space (2)"
119     exit 1
120 fi
121 echo "free space after delete $free2" >> $seq.full
122
123 echo -n "   !!! "
124 _within_tolerance "free space" $free2 $free0 1% -v
125
126 status=0
127 exit