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