xfs/419: remove irrelevant swapfile test
[xfstests-dev.git] / tests / xfs / 190
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2008 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FSQA Test No. 190
6 #
7 # This test uses xfs_io to unreserve space in a file at various different
8 # offsets and sizes. The script then verifies the holes are in the correct
9 # location.
10 #
11 # PV 985792
12 #
13
14 seq=`basename $0`
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
17
18 here=`pwd`
19 tmp=/tmp/$$
20 status=0    # success is the default!
21 rm -f $seqres.full
22
23 # get standard environment, filters and checks
24 . ./common/rc
25 . ./common/filter
26
27 # real QA test starts here
28 _supported_fs xfs
29
30 _require_scratch
31 _scratch_mkfs_xfs >/dev/null 2>&1
32 _scratch_mount
33
34 fsblocksize=$(_get_file_block_size $SCRATCH_MNT)
35
36 #This is the list of holes to punch in the file limited to $filesize
37 #NOTE holes cannot overlap or this script will fail.
38 holes="$fsblocksize:$fsblocksize \
39 $(($fsblocksize * 74)):$fsblocksize \
40 $(($fsblocksize * 256)):$(($fsblocksize / 8)) \
41 $(echo scale=0\;$fsblocksize \* 256 \+ $fsblocksize \* 3 \/ 4 | bc):$(($fsblocksize * 2)) \
42 $(echo scale=0\;$fsblocksize \* 260 \+ $fsblocksize \* 1 \/ 4 | bc):$(($fsblocksize * 2)) \
43 $(($fsblocksize * 265)):$(echo scale=0\;$fsblocksize \+ $fsblocksize \* 3 \/ 4 | bc)"
44
45 #filesize
46 filesize=$(($fsblocksize * 2560))
47 #Name of file to perform the test on
48 filename=test-190
49
50 $XFS_IO_PROG -f -c "pwrite 0 $(($fsblocksize * 2560))" $SCRATCH_MNT/$filename >> $seqres.full 2>&1
51
52 # run DMAPI test using verbose output
53 echo Punching holes in file
54 echo Punching holes in file >> $seqres.full
55 for i in $holes ; do
56         echo $XFS_IO_PROG -c "unresvsp `echo $i |$SED_PROG 's/:/ /g'`" $SCRATCH_MNT/$filename >> $seqres.full
57         $XFS_IO_PROG -c "unresvsp `echo $i |$SED_PROG 's/:/ /g'`" $SCRATCH_MNT/$filename ;
58 done
59
60 echo Verifying holes are in the correct spots:
61
62 xfs_bmap=`xfs_bmap $SCRATCH_MNT/$filename`
63 xfs_bmap $SCRATCH_MNT/$filename >> $seqres.full
64 for i in $holes ; do
65         holeStart=$[`echo $i|$SED_PROG 's/:/ /g'|awk '{print $1}'`];
66         holeEnd=$[`echo $i|$SED_PROG 's/:/ /g'|awk '{print $2}'`];
67
68         #Round hole size down to a multiple of $fsblocksize
69         holeEnd=$[(($holeStart+$holeEnd)/$fsblocksize)*$fsblocksize]
70
71         #Round hole start up to a multiple of $fsblocksize
72         if [ $[$holeStart % $fsblocksize] -gt 0 ] ; then
73                 holeStart=$[($holeStart/$fsblocksize +1) * $fsblocksize]
74         fi
75         #xfs_bmap prints holes in the following format
76         #                1: [8..15]: hole
77         bmap="\[$[$holeStart/512]..$[($holeEnd/512) -1]\]";
78         echo $bmap >> $seqres.full
79         if [ $holeEnd == $holeStart ] ; then
80                 continue #there is no hole
81         fi
82         if ! echo $xfs_bmap|grep -q $bmap; then
83                 echo Offset $holeStart to $holeEnd  basic blocks failed;
84                 status=1;
85         fi
86 done
87 if [ $status == 0 ] ; then
88         echo Test $seq Passed.
89 fi
90
91 exit