2ed7d027cedcd6b6fb8a3188c93884c173daf2fc
[xfstests-dev.git] / 096
1 #! /bin/sh
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 modify it
11 # under the terms of version 2 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, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
18 # Further, this software is distributed without any warranty that it is
19 # free of the rightful claim of any third person regarding infringement
20 # or the like.  Any license provided herein, whether implied or
21 # otherwise, applies only to this software file.  Patent licenses, if
22 # any, provided herein do not apply to combinations of this program with
23 # other software, or any other product whatsoever.
24
25 # You should have received a copy of the GNU General Public License along
26 # with this program; if not, write the Free Software Foundation, Inc., 59
27 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
28
29 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
30 # Mountain View, CA  94043, or:
31
32 # http://www.sgi.com 
33
34 # For further information regarding this notice, see: 
35
36 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
37 #-----------------------------------------------------------------------
38 #
39 # creator
40 owner=tes@sgi.com
41
42 seq=`basename $0`
43 echo "QA output created by $seq"
44
45 here=`pwd`
46 tmp=/tmp/$$
47 status=1        # failure is the default!
48 trap "_cleanup; exit \$status" 0 1 2 3 15
49
50 _cleanup()
51 {
52     cd /
53     rm -f $tmp.*
54 }
55
56 # get standard environment, filters and checks
57 . ./common.rc
58 . ./common.filter
59 . ./common.log
60
61
62 # filter out counts which will vary
63 #   - blocks, agsize, agcount, device name
64 # filter out differences between linux and irix:
65 #   - sectsz on Linux
66 #   - mmr, mixed-case on IRIX
67 #   - lazy-count on IRIX
68 #   - inode-paths on IRIX
69 #   - trailing spaces on Linux but not on IRIX
70 #
71 # Example output:
72 #  meta-data=DEV isize=256    agcount=N, agsize=N blks
73 #  data     =                       bsize=4096   blocks=N, imaxpct=25
74 #           =                       sunit=65     swidth=65 blks, unwritten=1
75 #  naming   =version 2              bsize=4096
76 #  log      =internal log           bsize=4096   blocks=N, version=1
77 #           =                       sunit=0 blks
78 #  realtime =none                   extsz=65536  blocks=N, rtextents=0
79
80 _mkfs_filter()
81 {
82    tee -a $seq.full | \
83    sed \
84         -e 's/blocks=[0-9][0-9]*/blocks=N/' \
85         -e 's/agsize=[0-9][0-9]*/agsize=N/' \
86         -e 's/agcount=[0-9][0-9]*/agcount=N/' \
87         -e 's/meta-data=[^ ]*/meta-data=DEV/' \
88         -e 's/ *isize/ isize/' \
89         -e '/ *= *sectsz=[0-9][0-9]* *$/d' \
90         -e '/ *= *mmr=[0-9][0-9]* *$/d' \
91         -e 's/ *mixed-case=[YN]//' \
92         -e 's/sectsz=[0-9][0-9]* *//' \
93         -e 's/, lazy-count.*//' \
94         -e '/inode-paths/d' \
95         -e 's/\(log[    ]*=\).*bsize/\1LOG                    bsize/' \
96         -e 's/ *$//'
97 }
98
99 # real QA test starts here
100 rm -f $seq.full
101
102 # Modify as appropriate.
103 _supported_fs xfs
104 _supported_os IRIX Linux
105 _require_scratch
106 _require_v2log
107
108 # choose .out file based on internal/external log
109 rm -f $seq.out
110 if [ "$USE_EXTERNAL" = yes ]; then
111         ln -s $seq.external $seq.out
112 else
113         ln -s $seq.internal $seq.out
114 fi
115
116 # maximum log record size
117 max_lr_size=`expr 256 \* 1024`
118
119 big_su=`expr $max_lr_size + 4096`
120
121 #
122 # Test out various mkfs param combinations
123 #
124 cat >$tmp.seq.params <<EOF
125 # su too big but must be a multiple of fs block size too
126   -l version=2,su=`expr $max_lr_size + 512`
127 # test log stripe greater than LR size
128   -l version=2,su=$big_su
129 # same test but get log stripe from data stripe
130   -l version=2 -d su=$big_su,sw=1
131 # test out data stripe
132   -d su=$big_su,sw=1
133 # test out data stripe the same but using sunit & swidth
134   -d sunit=`expr $big_su / 512`,swidth=`expr $big_su / 512`
135 EOF
136
137
138 #
139 # call mkfs in a loop for various params
140 #
141 echo ""
142 cat $tmp.seq.params \
143 | while read mkfs
144 do
145     if echo $mkfs | grep -q '^#'; then
146         # print out header & ignore comment
147         echo $mkfs
148         continue
149     fi
150     echo "--- mkfs=$mkfs ---"
151     export MKFS_OPTIONS="$mkfs"
152     _scratch_mkfs_xfs | _mkfs_filter
153     echo ""
154     echo ""
155 done
156
157 # success, all done
158 status=0
159 exit