xfstests: more 214 updates
[xfstests-dev.git] / 250
1 #! /bin/bash
2 # FS QA Test No. 250
3 #
4 # Bmap btree corruption regression test
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2011 Red Hat, 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 # creator
24 owner=dchinner@redhat.com
25
26 seq=`basename $0`
27 echo "QA output created by $seq"
28
29 here=`pwd`
30 tmp=/tmp/$$
31 status=1  # failure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
33
34 _cleanup()
35 {
36         cd /
37         umount -d $LOOP_MNT 2>/dev/null
38         rm -f $LOOP_DEV
39         rmdir $LOOP_MNT
40         _cleanup_testdir
41 }
42
43 # get standard environment, filters and checks
44 . ./common.rc
45 . ./common.filter
46
47 # real QA test starts here
48 _supported_fs xfs
49 _supported_os Linux
50 _require_loop
51
52 LOOP_DEV=$TEST_DIR/$seq.fs
53 LOOP_MNT=$TEST_DIR/$seq.mnt
54
55 _filter_io()
56 {
57         sed -e '/.* ops; /d'
58 }
59
60 # real QA test starts here
61
62 echo "*** create loop mount point"
63 rmdir $LOOP_MNT 2>/dev/null
64 mkdir -p $LOOP_MNT || _fail "cannot create loopback mount point"
65
66 _test_loop()
67 {
68         size=$1
69         agsize=$2
70         fsize=$3
71
72         dparam="file,name=$LOOP_DEV,size=$size"
73         if [ -n "$agsize" ]; then
74                 dparam="$dparam,agsize=$agsize"
75         fi
76
77         echo "*** mkfs loop file (size=$size)"
78         $MKFS_XFS_PROG -d $dparam \
79                 | _filter_mkfs 2>/dev/null
80
81         echo "*** mount loop filesystem"
82         mount -t xfs -o loop $LOOP_DEV $LOOP_MNT
83
84         echo "*** preallocate large file"
85         xfs_io -f -c "resvsp 0 $fsize" $LOOP_MNT/foo | _filter_io
86
87         echo "*** unmount loop filesystem"
88         umount -d $LOOP_MNT > /dev/null 2>&1
89
90         echo "*** check loop filesystem"
91          _check_xfs_filesystem $LOOP_DEV none none
92 }
93
94 _test_loop 50g 16m 40G
95 echo "*** done"
96 status=0
97 exit