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