xfstests: move generic tests out of top level dir
[xfstests-dev.git] / 096
1 #! /bin/bash
2 # FS QA Test No. 096
3 #
4 # test out mkfs_xfs output on IRIX/Linux and some of its error handling
5 # ensure pv#920679 is addressed
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
9 #
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
13 #
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22 #
23 #-----------------------------------------------------------------------
24 #
25
26 seq=`basename $0`
27 echo "QA output created by $seq"
28
29 here=`pwd`
30 tmp=/tmp/$$
31 status=1        # failure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
33
34 _cleanup()
35 {
36     cd /
37     rm -f $tmp.*
38 }
39
40 # get standard environment, filters and checks
41 . ./common.rc
42 . ./common.filter
43 . ./common.log
44
45 #
46 # filter out counts which will vary
47 #   - extsz, blocks, agsize, agcount, device name, rtextents
48 # filter out differences between linux and irix:
49 #   - sectsz on Linux
50 #   - mmr, mixed-case on IRIX
51 #   - lazy-count on IRIX
52 #   - inode-paths on IRIX
53 #   - trailing spaces on Linux but not on IRIX
54 #
55 # Example output:
56 #  meta-data=DEV isize=256    agcount=N, agsize=N blks
57 #  data     =                       bsize=4096   blocks=N, imaxpct=25
58 #           =                       sunit=65     swidth=65 blks, unwritten=1
59 #  naming   =version 2              bsize=4096
60 #  log      =internal log           bsize=4096   blocks=N, version=1
61 #           =                       sunit=0 blks
62 #  realtime =none                   extsz=65536  blocks=N, rtextents=N
63 #
64 _mkfs_filter()
65 {
66    tee -a $seq.full | \
67    sed \
68         -e 's/extsz=[0-9][0-9]*[ ]*/extsz=N, /' \
69         -e 's/blocks=[0-9][0-9]*/blocks=N/' \
70         -e 's/imaxpct=[0-9][0-9]*/imaxpct=N/' \
71         -e 's/agsize=[0-9][0-9]*/agsize=N/' \
72         -e 's/agcount=[0-9][0-9]*/agcount=N/' \
73         -e 's/swidth=[0-9][0-9]* blks$/&, unwritten=1/' \
74         -e 's/rtextents=[0-9][0-9]*/rtextents=N/' \
75         -e 's/meta-data=[^ ]*/meta-data=DEV/' \
76         -e 's/ *isize/ isize/' \
77         -e '/ *= *sectsz=[0-9][0-9]* *attr=[0-9][0-9]*.*$/d' \
78         -e '/ *= *mmr=[0-9][0-9]* *$/d' \
79         -e 's/ *mixed-case=[YN]//' \
80         -e 's/ *ascii-ci=[01]//' \
81         -e 's/sectsz=[0-9][0-9]* *//' \
82         -e 's/, lazy-count.*//' \
83         -e '/inode-paths/d' \
84         -e 's/\(log[    ]*=\).*bsize/\1LOG                    bsize/' \
85         -e 's/\(realtime[       ]*=\).*extsz/\1REALTIME               extsz/' \
86         -e '/.*crc=/d' \
87         -e 's/ *$//' \
88    | grep -v parent
89 }
90
91 # real QA test starts here
92 rm -f $seq.full
93
94 # Modify as appropriate.
95 _supported_fs xfs
96 _supported_os IRIX Linux
97 _require_scratch
98 _require_v2log
99
100 # choose .out file based on internal/external log
101 rm -f $seq.out
102 if [ "$USE_EXTERNAL" = yes ]; then
103         ln -s $seq.external $seq.out
104 else
105         ln -s $seq.internal $seq.out
106 fi
107
108 # maximum log record size
109 max_lr_size=`expr 256 \* 1024`
110
111 big_su=`expr $max_lr_size + 4096`
112
113 #
114 # Test out various mkfs param combinations
115 #
116 cat >$tmp.seq.params <<EOF
117 # su too big but must be a multiple of fs block size too
118   -l version=2,su=`expr $max_lr_size + 512`
119 # test log stripe greater than LR size
120   -l version=2,su=$big_su
121 # same test but get log stripe from data stripe
122   -l version=2 -d su=$big_su,sw=1
123 # test out data stripe
124   -l version=1 -d su=$big_su,sw=1
125 # test out data stripe the same but using sunit & swidth
126   -l version=1 -d sunit=`expr $big_su / 512`,swidth=`expr $big_su / 512`
127 EOF
128
129
130 #
131 # call mkfs in a loop for various params
132 #
133 echo ""
134 cat $tmp.seq.params \
135 | while read mkfs
136 do
137     if echo $mkfs | grep -q '^#'; then
138         # print out header & ignore comment
139         echo $mkfs
140         continue
141     fi
142     echo "--- mkfs=$mkfs ---"
143     export MKFS_OPTIONS="$mkfs"
144     _scratch_mkfs_xfs | _mkfs_filter
145     echo ""
146     echo ""
147 done
148
149 # success, all done
150 status=0
151 exit