Fix up output for mkfs failure with logsize not a multiple
[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 _require_nobigloopfs
78
79 _scratch_mkfs_xfs -d size=50m >/dev/null
80 _scratch_mount
81 out=$SCRATCH_MNT/fillup.$$
82 rm -f $seq.full
83
84 free0=`_free`
85 if [ -z "$free0" ]
86 then
87     echo "   *** failed to get free space (0)"
88     exit 1
89 fi
90 echo "free space at start $free0" >> $seq.full
91
92 echo "fill disk:"       # well, filesystem really - not disk
93
94 POSIXLY_CORRECT=yes dd if=/dev/zero of=$out bs=1024k 2>&1 | _filter_dd
95
96 echo "check free space:"
97
98 free1=`_free`
99 if [ -z "$free1" ]
100 then
101     echo "   *** failed to get free space (1)"
102     exit 1
103 fi
104 echo "free space after fill $free1" >> $seq.full
105
106 if [ ! -e $out ]
107 then
108     echo "   *** file not created"
109     exit 1
110 fi
111
112 if [ ! -s $out ]
113 then
114     echo "   *** file created with zero length"
115     ls -l $out
116     exit 1
117 fi
118
119 echo "delete fill:"
120
121 if ! rm $out
122 then
123     echo "   *** file not deleted"
124     exit 1
125 fi
126
127 if [ -e $out ]
128 then
129     echo "   *** file still exists"
130     ls -l $out
131     exit 1
132 fi
133
134 echo "check free space:"
135
136 free2=`_free`
137 if [ -z "$free2" ]
138 then
139     echo "   *** failed to get free space (2)"
140     exit 1
141 fi
142 echo "free space after delete $free2" >> $seq.full
143
144 echo -n "   !!! "
145 _within_tolerance "free space" $free2 $free0 1% -v
146
147 status=0
148 exit