66c33c22fdbd461117297701a5696c63af7c75b0
[xfstests-dev.git] / tests / generic / 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
25 seq=`basename $0`
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
28
29 here=`pwd`
30 tmp=/tmp/$$
31 status=1        # success is the default!
32
33 # get standard environment, filters and checks
34 . ./common/rc
35 . ./common/filter
36
37 _cleanup()
38 {
39         _scratch_unmount
40 }
41
42 trap "_cleanup; exit \$status" 0 1 2 3 15
43
44 _free()
45 {
46     _df_dir $SCRATCH_MNT | $AWK_PROG '{ print $5 }'
47 }
48
49 # real QA test starts here
50 _supported_fs generic
51 _supported_os IRIX Linux
52
53 _require_scratch
54 _require_no_large_scratch_dev
55
56 _scratch_mkfs_sized `expr 50 \* 1024 \* 1024` >/dev/null 2>&1 \
57     || _fail "mkfs failed"
58 _scratch_mount || _fail "mount failed"
59 out=$SCRATCH_MNT/fillup.$$
60 rm -f $seqres.full
61
62 free0=`_free`
63 if [ -z "$free0" ]
64 then
65     echo "   *** failed to get free space (0)"
66     exit 1
67 fi
68 echo "free space at start $free0" >> $seqres.full
69
70 echo "fill disk:"       # well, filesystem really - not disk
71
72 POSIXLY_CORRECT=yes dd if=/dev/zero of=$out bs=1024k 2>&1 | _filter_dd
73
74 echo "check free space:"
75
76 free1=`_free`
77 if [ -z "$free1" ]
78 then
79     echo "   *** failed to get free space (1)"
80     exit 1
81 fi
82 echo "free space after fill $free1" >> $seqres.full
83
84 if [ ! -e $out ]
85 then
86     echo "   *** file not created"
87     exit 1
88 fi
89
90 if [ ! -s $out ]
91 then
92     echo "   *** file created with zero length"
93     ls -l $out
94     exit 1
95 fi
96
97 echo "delete fill:"
98
99 if ! rm $out
100 then
101     echo "   *** file not deleted"
102     exit 1
103 fi
104
105 if [ -e $out ]
106 then
107     echo "   *** file still exists"
108     ls -l $out
109     exit 1
110 fi
111
112 echo "check free space:"
113
114 free2=`_free`
115 if [ -z "$free2" ]
116 then
117     echo "   *** failed to get free space (2)"
118     exit 1
119 fi
120 echo "free space after delete $free2" >> $seqres.full
121
122 echo -n "   !!! "
123 _within_tolerance "free space" $free2 $free0 1% -v
124
125 status=0
126 exit