generic: test MADV_POPULATE_READ with IO errors
[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 . ./common/preamble
11 _begin_fstest auto quick mkfs
12
13 # Override the default cleanup function.
14 _cleanup()
15 {
16         cd /
17         rm -f $tmp.* $def_cfgfile $fsimg
18 }
19
20 # Import common functions.
21 . ./common/filter
22
23 # real QA test starts here
24
25 # Modify as appropriate.
26 _supported_fs xfs
27 _require_test
28 _require_scratch_nocheck
29 _require_xfs_mkfs_cfgfile
30
31 def_cfgfile=$TEST_DIR/a
32 fsimg=$TEST_DIR/a.img
33 rm -f $def_cfgfile $fsimg
34 $XFS_IO_PROG -c "truncate 20t" -f $fsimg
35
36 test_mkfs_config() {
37         local cfgfile="$1"
38         if [ -z "$cfgfile" ] || [ "$cfgfile" = "-" ]; then
39                 cfgfile=$def_cfgfile
40                 cat > $cfgfile
41         fi
42         $MKFS_XFS_PROG -c options=$cfgfile -f -N $fsimg >> $seqres.full 2> $tmp.err
43         cat $tmp.err | _filter_test_dir
44 }
45
46 echo Simplest config file
47 cat > $def_cfgfile << ENDL
48 [metadata]
49 crc = 0
50 ENDL
51 test_mkfs_config $def_cfgfile
52
53 echo Piped-in config file
54 test_mkfs_config << ENDL
55 [metadata]
56 crc = 0
57 ENDL
58 test_mkfs_config << ENDL
59 [metadata]
60 crc = 1
61 ENDL
62
63 echo Full line comment
64 test_mkfs_config << ENDL
65 # This is a full line comment.
66 [metadata]
67 crc = 0
68 ENDL
69 test_mkfs_config << ENDL
70  # This is a full line comment.
71 [metadata]
72 crc = 0
73 ENDL
74 test_mkfs_config << ENDL
75 #This is a full line comment.
76 [metadata]
77 crc = 0
78 ENDL
79
80 echo End of line comment
81 test_mkfs_config << ENDL
82 [metadata]
83 crc = 0 ; This is an eol comment.
84 ENDL
85 test_mkfs_config << ENDL
86 [metadata]
87 crc = 0 ;This is an eol comment.
88 ENDL
89
90 echo Multiple directives
91 test_mkfs_config << ENDL
92 [metadata]
93 crc = 0
94 finobt = 0
95 ENDL
96
97 echo Multiple sections
98 test_mkfs_config << ENDL
99 [metadata]
100 crc = 0
101
102 [inode]
103 sparse = 0
104 ENDL
105
106 echo No directives at all
107 test_mkfs_config << ENDL
108 [metadata]
109 ENDL
110
111 echo Space around the section name
112 test_mkfs_config << ENDL
113  [metadata]
114 crc = 0
115 ENDL
116 test_mkfs_config << ENDL
117 [metadata] 
118 crc = 0
119 ENDL
120 test_mkfs_config << ENDL
121  [metadata] 
122 crc = 0
123 ENDL
124
125 echo Single space around the key/value directive
126 test_mkfs_config << ENDL
127 [metadata]
128  crc=0
129 ENDL
130 test_mkfs_config << ENDL
131 [metadata]
132 crc =0
133 ENDL
134 test_mkfs_config << ENDL
135 [metadata]
136 crc= 0
137 ENDL
138 test_mkfs_config << ENDL
139 [metadata]
140 crc=0 
141 ENDL
142
143 echo Two spaces around the key/value directive
144 test_mkfs_config << ENDL
145 [metadata]
146  crc =0
147 ENDL
148 test_mkfs_config << ENDL
149 [metadata]
150  crc= 0
151 ENDL
152 test_mkfs_config << ENDL
153 [metadata]
154  crc=0 
155 ENDL
156 test_mkfs_config << ENDL
157 [metadata]
158 crc = 0
159 ENDL
160 test_mkfs_config << ENDL
161 [metadata]
162 crc =0 
163 ENDL
164 test_mkfs_config << ENDL
165 [metadata]
166 crc= 0 
167 ENDL
168
169 echo Three spaces around the key/value directive
170 test_mkfs_config << ENDL
171 [metadata]
172  crc = 0
173 ENDL
174 test_mkfs_config << ENDL
175 [metadata]
176  crc= 0 
177 ENDL
178 test_mkfs_config << ENDL
179 [metadata]
180 crc = 0 
181 ENDL
182
183 echo Four spaces around the key/value directive
184 test_mkfs_config << ENDL
185 [metadata]
186  crc = 0 
187 ENDL
188
189 echo Arbitrary spaces and tabs
190 test_mkfs_config << ENDL
191 [metadata]
192           crc           =                0                        
193 ENDL
194
195 echo ambiguous comment/section names
196 test_mkfs_config << ENDL
197 [metadata]
198 #[data]
199 crc = 0
200 ENDL
201
202 echo ambiguous comment/variable names
203 test_mkfs_config << ENDL
204 [metadata]
205 #foo = 0 ; is this a comment or a key '#foo' ?
206 ENDL
207
208 # success, all done
209 status=0
210 exit