xfstests: randholes: Fix two bugs
[xfstests-dev.git] / 072
1 #! /bin/bash
2 # FS QA Test No. 072
3 #
4 # Check some unwritten extent boundary conditions
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2003 Silicon Graphics, 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 #
24 # creator
25 owner=nathans@sgi.com
26
27 seq=`basename $0`
28 echo "QA output created by $seq"
29
30 _cleanup()
31 {
32         cd /
33         rm -f $tmp.*
34         umount $SCRATCH_MNT 2>/dev/null
35 }
36
37 here=`pwd`
38 tmp=/tmp/$$
39 status=1        # failure is the default!
40 trap "_cleanup; exit \$status" 0 1 2 3 15
41
42 # get standard environment, filters and checks
43 . ./common.rc
44 . ./common.filter
45
46 # real QA test starts here
47 _supported_fs xfs
48 _supported_os IRIX Linux
49
50 [ -n "$XFS_IO_PROG" ] || _notrun "xfs_io executable not found"
51
52 _require_scratch
53
54 rm -f $seq.full
55 umount $SCRATCH_DEV >/dev/null 2>&1
56
57 _scratch_mkfs_xfs >/dev/null    || _fail "mkfs failed"
58 _scratch_mount >/dev/null       || _fail "mount failed"
59
60 # check there's enough freespace on $SCRATCH_MNT ... (1GiB + 1MiB)
61 avail=`df -P $SCRATCH_MNT | awk 'END {print $4}'`
62 [ "$avail" -ge 1049600 ] || _notrun "Scratch device is too small ($avail KiB)"
63
64 echo Silence is golden
65
66 # reserve 1GiB, truncate at 100bytes
67 $XFS_IO_PROG -f -c 'resvsp 0 1g' -c 'truncate 100' $SCRATCH_MNT/ouch
68 rm -f $SCRATCH_MNT/ouch
69
70 # reserve 1GiB, truncate at 1GiB
71 $XFS_IO_PROG -f -c 'resvsp 0 1g' -c 'truncate 1g' $SCRATCH_MNT/ouch
72 rm -f $SCRATCH_MNT/ouch
73
74 # reserve 1GiB, truncate at 2GiB
75 $XFS_IO_PROG -f -c 'resvsp 0 1g' -c 'truncate 2g' $SCRATCH_MNT/ouch
76 rm -f $SCRATCH_MNT/ouch
77
78 # reserve 1GiB, 1GiB hole, reserve 1MiB, truncate at 3GiB
79 $XFS_IO_PROG -f -c 'resvsp 0 1g' -c 'resvsp 2g 1m' -c 'truncate 3g' $SCRATCH_MNT/ouch
80 rm -f $SCRATCH_MNT/ouch
81
82 # success, all done
83 status=0
84 exit