common: Use _require_xfs_io_command() instead of helpers
[xfstests-dev.git] / tests / generic / 223
1 #! /bin/bash
2 # FS QA Test No. 223
3 #
4 # File alignment tests
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2010 Eric Sandeen.  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 here=`pwd`
30 tmp=/tmp/$$
31 status=1        # failure is the default!
32
33 _cleanup()
34 {
35     rm -f $tmp.*
36 }
37
38 trap "_cleanup ; exit \$status" 0 1 2 3 15
39
40 # get standard environment, filters and checks
41 . ./common/rc
42 . ./common/filter
43
44 # real QA test starts here
45 _supported_fs generic
46 _supported_os Linux
47
48 _require_scratch
49 _require_xfs_io_command "falloc"
50
51 rm -f $seqres.full
52
53 BLOCKSIZE=4096
54
55 for SUNIT_K in 8 16 32 64 128; do
56         let SUNIT_BYTES=$SUNIT_K*1024
57         let SUNIT_BLOCKS=$SUNIT_BYTES/$BLOCKSIZE
58
59         echo "=== mkfs with su $SUNIT_BLOCKS blocks x 4 ==="
60         export MKFS_OPTIONS=""
61         _scratch_mkfs_geom $SUNIT_BYTES 4 $BLOCKSIZE >> $seqres.full 2>&1
62         _scratch_mount
63
64         for SIZE_MULT in 1 2 8 64 256; do
65                 let SIZE=$SIZE_MULT*$SUNIT_BYTES
66
67                 echo "=== Testing size ${SIZE_MULT}*${SUNIT_K}k on ${SUNIT_K}k stripe ==="
68                 for FILE in 1 2 3 4; do
69                         $XFS_IO_PROG -f -c "falloc 0 $SIZE" \
70                                 $SCRATCH_MNT/file-$FILE-$SIZE-falloc \
71                                         >> $seqres.full 2>&1
72                         $XFS_IO_PROG -f -c "pwrite 0 $SIZE" \
73                                 $SCRATCH_MNT/file-$FILE-$SIZE-write \
74                                         >> $seqres.full 2>&1
75                         src/t_stripealign $SCRATCH_MNT/file-$FILE-$SIZE-falloc \
76                                 $SUNIT_BLOCKS | _filter_scratch
77                         src/t_stripealign $SCRATCH_MNT/file-$FILE-$SIZE-write \
78                                 $SUNIT_BLOCKS | _filter_scratch
79                 done
80         done
81
82         echo "=== Testing size 1g falloc on ${SUNIT_K}k stripe ==="
83         $XFS_IO_PROG -f -c "falloc 0 1g" \
84             $SCRATCH_MNT/file-1g-falloc >> $seqres.full 2>&1
85         src/t_stripealign $SCRATCH_MNT/file-1g-falloc $SUNIT_BLOCKS \
86             | _filter_scratch
87
88         rm -f $SCRATCH_MNT/file-1g-falloc | _filter_scratch
89
90         echo "=== Testing size 1073745920 falloc on ${SUNIT_K}k stripe ==="
91         $XFS_IO_PROG -f -c "falloc 0 1073745920" \
92                 $SCRATCH_MNT/file-1073745920-falloc >> $seqres.full 2>&1
93         src/t_stripealign $SCRATCH_MNT/file-1073745920-falloc \
94                 $SUNIT_BLOCKS | _filter_scratch
95
96         _scratch_unmount
97 done
98
99 status=0
100 exit