xfstests: Convert all tests to use /bin/bash
[xfstests-dev.git] / 213
1 #! /bin/bash
2 # FS QA Test No. 213
3 #
4 # Check some unwritten extent boundary conditions, fallocate version.
5 #
6 # Based on xfs-specific test 072
7 #
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
10 # Copyright (c) 2009 Red Hat, Inc. All Rights Reserved.
11 #
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
15 #
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 #
25 #-----------------------------------------------------------------------
26 #
27 # creator
28 owner=sandeen@sandeen.net
29
30 seq=`basename $0`
31 echo "QA output created by $seq"
32
33 _cleanup()
34 {
35         cd /
36         rm -f $tmp.*
37 }
38
39 here=`pwd`
40 tmp=$TEST_DIR/$$
41 status=1        # failure is the default!
42 trap "_cleanup; exit \$status" 0 1 2 3 15
43
44 # get standard environment, filters and checks
45 . ./common.rc
46 . ./common.filter
47
48 # real QA test starts here
49 # generic, but xfs_io's fallocate must work
50 _supported_fs generic
51 # only Linux supports fallocate
52 _supported_os Linux
53
54 [ -n "$XFS_IO_PROG" ] || _notrun "xfs_io executable not found"
55
56 rm -f $seq.full
57
58 _require_xfs_io_falloc
59
60 # check there's enough freespace on $TEST_DIR ... (1GiB + 1MiB)
61 avail=`df -P $TEST_DIR | awk 'END {print $4}'`
62 [ "$avail" -ge 1049600 ] || _notrun "Test device is too small ($avail KiB)"
63
64 # reserve 1GiB, truncate at 100bytes
65 $XFS_IO_PROG -F -f -c 'falloc 0 1g' -c 'truncate 100' $TEST_DIR/ouch
66 rm -f $TEST_DIR/ouch
67
68 # reserve 1GiB, truncate at 1GiB
69 $XFS_IO_PROG -F -f -c 'falloc 0 1g' -c 'truncate 1g' $TEST_DIR/ouch
70 rm -f $TEST_DIR/ouch
71
72 # reserve 1GiB, truncate at 2GiB
73 $XFS_IO_PROG -F -f -c 'falloc 0 1g' -c 'truncate 2g' $TEST_DIR/ouch
74 rm -f $TEST_DIR/ouch
75
76 # reserve 1GiB, 1GiB hole, reserve 1MiB, truncate at 3GiB
77 $XFS_IO_PROG -F -f -c 'falloc 0 1g' -c 'falloc 2g 1m' -c 'truncate 3g' $TEST_DIR/ouch
78 rm -f $TEST_DIR/ouch
79
80 # Try to reserve more space than we have
81 echo "We should get: fallocate: No space left on device"
82 echo "Strangely, xfs_io sometimes says \"Success\" when something went wrong, FYI"
83
84 let toobig=$avail*2
85 $XFS_IO_PROG -F -f -c "falloc 0 ${toobig}k" $TEST_DIR/ouch
86 rm -f $TEST_DIR/ouch
87
88 # success, all done
89 status=0
90 exit