xfstests 068: Add mmap load
[xfstests-dev.git] / 190
1 #! /bin/bash
2 # FSQA Test No. 190
3 #
4 # This test uses xfs_io to unreserve space in a file at various different
5 # offsets and sizes. The script then verifies the holes are in the correct
6 # location.
7 #
8 # PV 985792
9 #
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2008 Silicon Graphics, Inc.  All Rights Reserved.
12 #
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
16 #
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
25 #
26 #-----------------------------------------------------------------------
27 #
28 # creator
29 owner=pleckie@sgi.com
30
31 #This is the list of holes to punch in the file limited to $filesize
32 #NOTE holes cannot overlap or this script will fail.
33 holes="4096:4096 303104:4096 1048576:512 1051648:8192 1065984:8192 1085440:7168"
34 #filesize in MB
35 filesize=10
36 #Name of file to perform the test on
37 filename=test-190
38
39 seq=`basename $0`
40 echo "QA output created by $seq"
41
42 here=`pwd`
43 tmp=/tmp/$$
44 status=0    # success is the default!
45 rm -f $seq.full
46
47 # get standard environment, filters and checks
48 . ./common.rc
49 . ./common.filter
50
51 # real QA test starts here
52 _supported_fs xfs
53 _supported_os Linux
54
55 _require_scratch
56 _scratch_mkfs_xfs >/dev/null 2>&1
57 _scratch_mount
58 fsblocksize=`xfs_info $SCRATCH_MNT|sed 's/=/ /g'|awk '/^data / { print $3 }'`
59
60 dd if=/dev/zero of=$SCRATCH_MNT/$filename bs=1024k count=10 >> $seq.full 2>&1
61
62 # run DMAPI test using verbose output
63 echo Punching holes in file
64 echo Punching holes in file >> $seq.full
65 for i in $holes ; do
66         echo xfs_io -c "unresvsp `echo $i |$SED_PROG 's/:/ /g'`" $SCRATCH_MNT/$filename >> $seq.full
67         xfs_io -c "unresvsp `echo $i |$SED_PROG 's/:/ /g'`" $SCRATCH_MNT/$filename ;
68 done
69
70 echo Verifying holes are in the correct spots:
71
72 xfs_bmap=`xfs_bmap $SCRATCH_MNT/$filename`
73 xfs_bmap $SCRATCH_MNT/$filename >> $seq.full
74 for i in $holes ; do
75         holeStart=$[`echo $i|$SED_PROG 's/:/ /g'|awk '{print $1}'`];
76         holeEnd=$[`echo $i|$SED_PROG 's/:/ /g'|awk '{print $2}'`];
77
78         #Round hole size down to a multiple of $fsblocksize
79         holeEnd=$[(($holeStart+$holeEnd)/$fsblocksize)*$fsblocksize]
80
81         #Round hole start up to a multiple of $fsblocksize
82         if [ $[$holeStart % $fsblocksize] -gt 0 ] ; then
83                 holeStart=$[($holeStart/$fsblocksize +1) * $fsblocksize]
84         fi
85         #xfs_bmap prints holes in the following format
86         #                1: [8..15]: hole
87         bmap="\[$[$holeStart/512]..$[($holeEnd/512) -1]\]";
88         echo $bmap >> $seq.full
89         if [ $holeEnd == $holeStart ] ; then
90                 continue #there is no hole
91         fi
92         if ! echo $xfs_bmap|grep -q $bmap; then
93                 echo Offset $holeStart to $holeEnd  basic blocks failed;
94                 status=1;
95         fi
96 done
97 if [ $status == 0 ] ; then
98         echo Test $seq Passed.
99 fi
100
101 exit