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