b22ee84217f20726103a59fba1c9e734026f4092
[platform/upstream/curl.git] / tests / FILEFORMAT
1  The test suite's file format is very simple and extensible, closely
2 resembling XML. All data for a single test case resides in a single
3 ASCII file. Labels mark the beginning and the end of all sections, and each
4 label must be written in its own line.  Comments are either XML-style
5 (enclosed with <!-- and -->) or C-style (beginning with #) and must appear
6 on their own lines and not alongside actual test data.  Most test data files
7 are syntactically valid XML, although a few files are not (lack of
8 support for character entities and the preservation of CR/LF characters at
9 the end of lines are the biggest differences).
10
11  The file begins with a 'testcase' tag, which encompasses the remainder of
12 the file.
13
14 <testcase>
15
16  Each file is split up in three main sections: reply, client and verify. The
17 reply section is used for the server to know what to send as a reply for the
18 requests curl sends, the client section defines how the client should behave
19 while the verify section defines how to verify that the data stored after a
20 command has been run ended up correctly.
21
22  Each main section has a number of available subsections that can be
23 specified, that will be checked/used if specified. This document includes all
24 the subsections currently supported.
25
26 Main sections are 'info', 'reply', 'client' and 'verify'.
27
28 <info>
29 <keywords>
30 A newline-separated list of keywords describing what this test case uses and
31 tests. Try to use an already used keyword. These keywords will be used for
32 statistical/informational purposes.
33 </keywords>
34 </info>
35
36 <reply>
37 <data [nocheck="1"] [sendzero="yes"] [base64="yes"]>
38 data to be sent to the client on its request and later verified that it arrived
39 safely. Set the nocheck=1 to prevent the test script to verify the arrival
40 of this data.
41
42 If the data contains 'swsclose' anywhere within the start and end tag, and
43 this is a HTTP test, then the connection will be closed by the server after
44 this response is sent. If not, the connection will be kept persistent.
45
46 If the data contains 'swsbounce' anywhere within the start and end tag, the
47 HTTP server will detect if this is a second request using the same test and
48 part number and will then increase the part number with one. This is useful
49 for auth tests and similar.
50
51 'sendzero' set to yes means that the (FTP) server will "send" the data even if
52 the size is zero bytes. Used to verify curl's behaviour on zero bytes
53 transfers.
54
55 'base64' set to yes means that the data provided in the test-file is a chunk
56 of data encoded with base64. It is the only way a test case can contain binary
57 data. (This attribute can in fact be used on any section, but it doesn't make
58 much sense for other sections than "data").
59 </data>
60 <dataNUM>
61 Send back this contents instead of the <data> one. The num is set by:
62 A) The test number in the request line is >10000 and this is the remainder
63 of [test case number]%10000.
64 B) The request was HTTP and included digest details, which adds 1000 to NUM
65 C) If a HTTP request is NTLM type-1, it adds 1001 to num
66 D) If a HTTP request is NTLM type-3, it adds 1002 to num
67 </dataNUM>
68 <datacheck [nonewline="yes"]>
69 if the data is sent but this is what should be checked afterwards. If
70 'nonewline' is set, we will cut off the trailing newline of this given data
71 before comparing with the one actually received by the client
72 </datacheck>
73 <size>
74 number to return on a ftp SIZE command (set to -1 to make this command fail)
75 </size>
76 <mdtm>
77 what to send back if the client sends a (FTP) MDTM command, set to -1 to
78 have it return that the file doesn't exist
79 </mdtm>
80 <postcmd>
81 special purpose server-command to control its behavior *after* the
82 reply is sent
83 For HTTP/HTTPS, these are supported:
84
85 wait [secs]
86  - Pause for the given time
87 </postcmd>
88 <servercmd>
89 Special-commands for the server.
90 For FTP, these are supported:
91
92 REPLY [command] [return value] [response string]
93  - Changes how the server responds to the [command]
94 COUNT [command] [num]
95  - Do the REPLY change for [command] only [num] times and then go back to the
96    built-in approach
97 DELAY [command] [secs]
98  - Delay responding to this command for the given time
99 RETRWEIRDO
100  - Enable the "weirdo" RETR case when multiple response lines appear at once
101    when a file is transfered
102 RETRNOSIZE
103  - Make sure the RETR response doesn't contain the size of the file
104 NOSAVE
105  - Don't actually save what is received
106 SLOWDOWN
107  - Send FTP responses with 0.1 sec delay between each byte
108 PASVBADIP
109  - makes PASV send back an illegal IP in its 227 response
110
111 For HTTP/HTTPS:
112 auth_required - if this is set and a POST/PUT is made without auth, the
113                 server will NOT wait for the full request body to get sent
114 idle -          do nothing after receiving the request, just "sit idle"
115 stream -        continuously send data to the client, never-ending
116 pipe: [num] -   tell the server to expect this many HTTP requests before
117                 sending back anything, to allow pipelining tests
118 </servercmd>
119 </reply>
120
121 <client>
122
123 <server>
124 What server(s) this test case requires/uses:
125
126 file
127 ftp
128 ftp-ipv6
129 ftps
130 http
131 http-ipv6
132 https
133 none
134 scp
135 sftp
136 socks4
137 socks5
138
139 Give only one per line.  This subsection is mandatory.
140 </server>
141
142 <features>
143 A list of features that MUST be present in the client/library for this test to
144 be able to run (if these features are not present, the test will be
145 SKIPPED). Features testable here are:
146
147 crypto
148 getrlimit
149 GnuTLS
150 idn
151 ipv6
152 large_file
153 libz
154 netrc_debug
155 NSS
156 OpenSSL
157 SSL
158
159 as well as each protocol that curl supports.  A protocol only needs to be
160 specified if it is different from the server (useful when the server
161 is 'none').
162 </features>
163
164 <killserver>
165 Using the same syntax as in <server> but when mentioned here these servers
166 are explicitly KILLED when this test case is completed. Only use this if there
167 is no other alternatives. Using this of course requires subsequent tests to
168 restart servers.
169 </killserver>
170
171 <precheck>
172 A command line that if set gets run by the test script before the test. If an
173 output is displayed by the command, the test will be skipped and the
174 (single-line) output will be displayed as reason for not running the test.
175 Variables are substituted as in the <command> section.
176 </precheck>
177
178 <postcheck>
179 A command line that if set gets run by the test script after the test. If
180 the command exists with a non-zero status code, the test will be considered
181 to have failed. Variables are substituted as in the <command> section.
182 </postcheck>
183
184 <tool>
185 Name of tool to use instead of "curl". This tool must be built and exist
186 in the libtest/ directory.
187 </tool>
188
189 <name>
190 test case description
191 </name>
192
193 <setenv>
194 variable1=contents1
195 variable2=contents2
196
197 Set the given environment variables to the specified value before the actual
198 command is run. They are cleared again after the command has been run.
199 Variables are first substituted as in the <command> section.
200 </setenv>
201
202 <command [option="no-output"]>
203 command line to run, there's a bunch of %variables that get replaced
204 accordingly.
205
206 Note that the URL that gets passed to the server actually controls what data
207 that is returned. The last slash in the URL must be followed by a number. That
208 number (N) will be used by the test-server to load test case N and return the
209 data that is defined within the <reply><data></data></reply> section.
210
211 If a CONNECT is used to the server (to emulate HTTPS etc over proxy), the port
212 number given in the CONNECT request will be used to identify which test that
213 is being run, if the proxy host name is said to start with 'test'.
214
215 Set 'option=no-output' to prevent the test script to slap on the --output
216 argument that directs the output to a file. The --output is also not added if
217 the client/stdout section is used.
218
219 Available substitute variables include:
220 %HOSTIP    - IPv6 address of the host running this test
221 %HOSTPORT  - Port number of the HTTP server
222 %HOST6IP   - IPv6 address of the host running this test
223 %HOST6PORT - IPv6 port number of the HTTP server
224 %HTTPSPORT - Port number of the HTTPS server
225 %FTPPORT   - Port number of the FTP server
226 %FTP6PORT  - IPv6 port number of the FTP server
227 %FTPSPORT  - Port number of the FTPS server
228 %FTP2PORT  - Port number of the FTP server 2
229 %TFTPPORT  - Port number of the TFTP server
230 %TFTP6PORT - IPv6 port number of the TFTP server
231 %SSHPORT   - Port number of the SCP/SFTP server
232 %SOCKSPORT - Port number of the SOCKS4/5 server
233 %SRCDIR    - Full path to the source dir
234 %PWD       - Current directory
235 %CURL      - Path to the curl executable
236 %USER      - Login ID of the user running the test
237 </command>
238
239 <file name="log/filename">
240 This creates the named file with this content before the test case is run,
241 which is useful if the test case needs a file to act on.
242 Variables are substituted on the contents of the file as in the <command>
243 section.
244 </file>
245
246 <stdin>
247 Pass this given data on stdin to the tool.
248 </stdin>
249
250 </client>
251
252 <verify>
253 <errorcode>
254 numerical error code curl is supposed to return. Specify a list of accepted
255 error codes by separating multiple numbers with comma. See test 237 for an
256 example.
257 </errorcode>
258 <strip>
259 One regex per line that is removed from the protocol dumps before the
260 comparison is made. This is very useful to remove dependencies on dynamically
261 changing protocol data such as port numbers or user-agent strings.
262 </strip>
263 <strippart>
264 One perl op per line that operates on the protocol dump. This is pretty
265 advanced. Example: "s/^EPRT .*/EPRT stripped/"
266 </strippart>
267 <protocol [nonewline="yes"]>
268 the protocol dump curl should transmit, if 'nonewline' is set, we will cut
269 off the trailing newline of this given data before comparing with the one
270 actually sent by the client
271 Variables are substituted as in the <command> section.
272 </protocol>
273 <stdout [mode="text"]>
274 This verifies that this data was passed to stdout.
275
276 Use the mode="text" attribute if the output is in text mode on platforms that
277 have a text/binary difference.
278 </stdout>
279 <file name="log/filename" [mode="text"]>
280 The file's contents must be identical to this after the test is complete.
281
282 Use the mode="text" attribute if the output is in text mode on platforms that
283 have a text/binary difference.
284 </file>
285 <stripfile>
286 One perl op per line that operates on the file before being compared. This is
287 pretty advanced. Example: "s/^EPRT .*/EPRT stripped/"
288 </stripfile>
289 <upload>
290 the contents of the upload data curl should have sent
291 </upload>
292 <valgrind>
293 disable - disables the valgrind log check for this test
294 </valgrind>
295 </verify>
296
297 </testcase>