xfstests: add _require_freeze and minor cleanups
[xfstests-dev.git] / 041
1 #! /bin/bash
2 # FS QA Test No. 041
3 #
4 # growfs QA tests - repeatedly fill/grow the filesystem
5 # check the filesystem contents after each operation
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
9 #
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
13 #
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22 #
23 #-----------------------------------------------------------------------
24 #
25 set +x
26 # creator
27 owner=ajag@sgi.com
28
29 seq=`basename $0`
30 echo "QA output created by $seq"
31
32 here=`pwd`
33 tmp=/tmp/$$
34 status=1        # failure is the default!
35
36 _cleanup()
37 {
38     cd /
39     umount $SCRATCH_MNT
40     rm -f $tmp.*
41 }
42 trap "_cleanup ; exit \$status" 0 1 2 3 15
43
44 # get standard environment, filters and checks
45 . ./common.rc
46 . ./common.filter
47
48 # real QA test starts here
49 _supported_fs xfs
50 _supported_os IRIX Linux
51
52 _require_scratch
53 _require_nobigloopfs
54 umount $SCRATCH_DEV 2>/dev/null
55
56 _fill()
57 {
58     if [ $# -ne 1 ]; then echo "Usage: _fill \"path\"" 1>&2 ; exit 1; fi
59     _do "Fill filesystem" \
60         "src/fill2fs --verbose --dir=$1 --seed=0 --filesize=65536 --stddev=32768 --list=- >>$tmp.manifest"
61 }
62
63 _do_die_on_error=message_only
64 rm -f $seq.full
65 agsize=32
66 echo -n "Make $agsize megabyte filesystem on SCRATCH_DEV and mount... "
67 _scratch_mkfs_xfs -dsize=${agsize}m,agcount=1 2>&1 >/dev/null || _fail "mkfs failed"
68 bsize=`_scratch_mkfs_xfs -dsize=${agsize}m,agcount=1 2>&1 | _filter_mkfs 2>&1 \
69                 | perl -ne 'if (/dbsize=(\d+)/) {print $1;}'`
70 onemeginblocks=`expr 1048576 / $bsize`
71 _scratch_mount || _fail "mount failed"
72
73 echo "done"
74
75 # full allocation group -> partial; partial -> expand partial + new partial;
76 # partial -> expand partial; partial -> full
77 # cycle through 33m -> 67m -> 75m -> 96m
78 for size in 33 67 75 96
79 do
80     grow_size=`expr $size \* $onemeginblocks`
81     _fill $SCRATCH_MNT/fill_$size
82     _do "Grow filesystem to ${size}m" "xfs_growfs -D $grow_size $SCRATCH_MNT"
83     echo -n "Flush filesystem... "
84     _do "umount $SCRATCH_MNT"
85     _do "_scratch_mount"
86     echo "done"
87     echo -n "Check files... "
88     if ! _do "src/fill2fs_check $tmp.manifest"; then
89       echo "fail (see $seq.full)"
90       _do "cat $tmp.manifest"
91       _do "ls -altrR $SCRATCH_MNT"
92       _do "dd if=$SCRATCH_DEV bs=4096 count=$grow_size | gzip -9 > $seq.fsimage.gz"
93       status=1 ; exit
94     fi
95     echo "done"
96 done
97
98 # success, all done
99 echo "Growfs tests passed."
100 status=0 ; exit