xfs: test mkfs.xfs config files
[xfstests-dev.git] / tests / xfs / 522
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (c) 2020 Oracle.  All Rights Reserved.
4 #
5 # FS QA Test No. 522
6 #
7 # Feed valid mkfs config files to the mkfs parser to ensure that they are
8 # recognized as valid.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap '_cleanup; exit $status' 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -f $tmp.* $def_cfgfile $fsimg
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28
29 # remove previous $seqres.full before test
30 rm -f $seqres.full
31
32 # real QA test starts here
33
34 # Modify as appropriate.
35 _supported_fs xfs
36 _require_test
37 _require_scratch_nocheck
38 _require_xfs_mkfs_cfgfile
39
40 def_cfgfile=$TEST_DIR/a
41 fsimg=$TEST_DIR/a.img
42 rm -f $def_cfgfile $fsimg
43 $XFS_IO_PROG -c "truncate 20t" -f $fsimg
44
45 test_mkfs_config() {
46         local cfgfile="$1"
47         if [ -z "$cfgfile" ] || [ "$cfgfile" = "-" ]; then
48                 cfgfile=$def_cfgfile
49                 cat > $cfgfile
50         fi
51         $MKFS_XFS_PROG -c options=$cfgfile -f -N $fsimg >> $seqres.full 2> $tmp.err
52         cat $tmp.err | _filter_test_dir
53 }
54
55 echo Simplest config file
56 cat > $def_cfgfile << ENDL
57 [metadata]
58 crc = 0
59 ENDL
60 test_mkfs_config $def_cfgfile
61
62 echo Piped-in config file
63 test_mkfs_config << ENDL
64 [metadata]
65 crc = 0
66 ENDL
67 test_mkfs_config << ENDL
68 [metadata]
69 crc = 1
70 ENDL
71
72 echo Full line comment
73 test_mkfs_config << ENDL
74 # This is a full line comment.
75 [metadata]
76 crc = 0
77 ENDL
78 test_mkfs_config << ENDL
79  # This is a full line comment.
80 [metadata]
81 crc = 0
82 ENDL
83 test_mkfs_config << ENDL
84 #This is a full line comment.
85 [metadata]
86 crc = 0
87 ENDL
88
89 echo End of line comment
90 test_mkfs_config << ENDL
91 [metadata]
92 crc = 0 ; This is an eol comment.
93 ENDL
94 test_mkfs_config << ENDL
95 [metadata]
96 crc = 0 ;This is an eol comment.
97 ENDL
98
99 echo Multiple directives
100 test_mkfs_config << ENDL
101 [metadata]
102 crc = 0
103 finobt = 0
104 ENDL
105
106 echo Multiple sections
107 test_mkfs_config << ENDL
108 [metadata]
109 crc = 0
110
111 [inode]
112 sparse = 0
113 ENDL
114
115 echo No directives at all
116 test_mkfs_config << ENDL
117 [metadata]
118 ENDL
119
120 echo Space around the section name
121 test_mkfs_config << ENDL
122  [metadata]
123 crc = 0
124 ENDL
125 test_mkfs_config << ENDL
126 [metadata] 
127 crc = 0
128 ENDL
129 test_mkfs_config << ENDL
130  [metadata] 
131 crc = 0
132 ENDL
133
134 echo Single space around the key/value directive
135 test_mkfs_config << ENDL
136 [metadata]
137  crc=0
138 ENDL
139 test_mkfs_config << ENDL
140 [metadata]
141 crc =0
142 ENDL
143 test_mkfs_config << ENDL
144 [metadata]
145 crc= 0
146 ENDL
147 test_mkfs_config << ENDL
148 [metadata]
149 crc=0 
150 ENDL
151
152 echo Two spaces around the key/value directive
153 test_mkfs_config << ENDL
154 [metadata]
155  crc =0
156 ENDL
157 test_mkfs_config << ENDL
158 [metadata]
159  crc= 0
160 ENDL
161 test_mkfs_config << ENDL
162 [metadata]
163  crc=0 
164 ENDL
165 test_mkfs_config << ENDL
166 [metadata]
167 crc = 0
168 ENDL
169 test_mkfs_config << ENDL
170 [metadata]
171 crc =0 
172 ENDL
173 test_mkfs_config << ENDL
174 [metadata]
175 crc= 0 
176 ENDL
177
178 echo Three spaces around the key/value directive
179 test_mkfs_config << ENDL
180 [metadata]
181  crc = 0
182 ENDL
183 test_mkfs_config << ENDL
184 [metadata]
185  crc= 0 
186 ENDL
187 test_mkfs_config << ENDL
188 [metadata]
189 crc = 0 
190 ENDL
191
192 echo Four spaces around the key/value directive
193 test_mkfs_config << ENDL
194 [metadata]
195  crc = 0 
196 ENDL
197
198 echo Arbitrary spaces and tabs
199 test_mkfs_config << ENDL
200 [metadata]
201           crc           =                0                        
202 ENDL
203
204 echo ambiguous comment/section names
205 test_mkfs_config << ENDL
206 [metadata]
207 #[data]
208 crc = 0
209 ENDL
210
211 echo ambiguous comment/variable names
212 test_mkfs_config << ENDL
213 [metadata]
214 #foo = 0 ; is this a comment or a key '#foo' ?
215 ENDL
216
217 # success, all done
218 status=0
219 exit