tests: document more test identifiers and variables
[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 and for choosing or skipping classes
33 of tests.  "Keywords" must begin with an alphabetic character, "-", "["
34 or "{" and may actually consist of multiple words separated by spaces
35 which are treated together as a single identifier.
36 </keywords>
37 </info>
38
39 <reply>
40 <data [nocheck="yes"] [sendzero="yes"] [base64="yes"]>
41 data to be sent to the client on its request and later verified that it arrived
42 safely. Set nocheck="yes" to prevent the test script from verifying the arrival
43 of this data.
44
45 If the data contains 'swsclose' anywhere within the start and end tag, and
46 this is a HTTP test, then the connection will be closed by the server after
47 this response is sent. If not, the connection will be kept persistent.
48
49 If the data contains 'swsbounce' anywhere within the start and end tag, the
50 HTTP server will detect if this is a second request using the same test and
51 part number and will then increase the part number with one. This is useful
52 for auth tests and similar.
53
54 'sendzero' set to yes means that the (FTP) server will "send" the data even if
55 the size is zero bytes. Used to verify curl's behaviour on zero bytes
56 transfers.
57
58 'base64' set to yes means that the data provided in the test-file is a chunk
59 of data encoded with base64. It is the only way a test case can contain binary
60 data. (This attribute can in fact be used on any section, but it doesn't make
61 much sense for other sections than "data").
62
63 For FTP file listings, the <data> section will be used *only* if you make sure
64 that there has been a CWD done first to a directory named 'test-[num]' where
65 [num] is the test case number. Otherwise the ftp server can't know from which
66 test file to load the list content.
67
68 </data>
69 <dataNUM>
70 Send back this contents instead of the <data> one. The num is set by:
71 A) The test number in the request line is >10000 and this is the remainder
72 of [test case number]%10000.
73 B) The request was HTTP and included digest details, which adds 1000 to NUM
74 C) If a HTTP request is NTLM type-1, it adds 1001 to num
75 D) If a HTTP request is NTLM type-3, it adds 1002 to num
76 E) If a HTTP request is Basic and num is already >=1000, it adds 1 to num
77
78 Dynamically changing num in this way allows the test harness to be used to
79 test authentication negotiation where several different requests must be sent
80 to complete a transfer. The response to each request is found in its own data
81 section.  Validating the entire negotiation sequence can be done by
82 specifying a datacheck section.
83 </dataNUM>
84 <connect>
85 The connect section is used instead of the 'data' for all CONNECT
86 requests. The remainder of the rules for the data section then apply but with
87 a connect prefix.
88 </connect>
89 <datacheck [nonewline="yes"]>
90 if the data is sent but this is what should be checked afterwards. If
91 'nonewline' is set, we will cut off the trailing newline of this given data
92 before comparing with the one actually received by the client
93 </datacheck>
94 <size>
95 number to return on a ftp SIZE command (set to -1 to make this command fail)
96 </size>
97 <mdtm>
98 what to send back if the client sends a (FTP) MDTM command, set to -1 to
99 have it return that the file doesn't exist
100 </mdtm>
101 <postcmd>
102 special purpose server-command to control its behavior *after* the
103 reply is sent
104 For HTTP/HTTPS, these are supported:
105
106 wait [secs]
107  - Pause for the given time
108 </postcmd>
109 <servercmd>
110 Special-commands for the server.
111 For FTP/SMTP/POP/IMAP, these are supported:
112
113 REPLY [command] [return value] [response string]
114  - Changes how the server responds to the [command]. [response string] is
115    evaluated as a perl string, so it can contain embedded \r\n, for example.
116    There's a special [command] named "welcome" (without quotes) which is the
117    string sent immediately on connect as a welcome.
118 COUNT [command] [num]
119  - Do the REPLY change for [command] only [num] times and then go back to the
120    built-in approach
121 DELAY [command] [secs]
122  - Delay responding to this command for the given time
123 RETRWEIRDO
124  - Enable the "weirdo" RETR case when multiple response lines appear at once
125    when a file is transfered
126 RETRNOSIZE
127  - Make sure the RETR response doesn't contain the size of the file
128 NOSAVE
129  - Don't actually save what is received
130 SLOWDOWN
131  - Send FTP responses with 0.01 sec delay between each byte
132 PASVBADIP
133  - makes PASV send back an illegal IP in its 227 response
134 CAPA [capabilities]
135  - Enables support for and specifies a list of space separated capabilities to
136    return to the client for the IMAP CAPABILITY, POP3 CAPA and SMTP EHLO
137    commands
138 AUTH [mechanisms]
139  - Enables support for SASL authentication and specifies a list of space
140    separated mechanisms for IMAP, POP3 and SMTP
141
142 For HTTP/HTTPS:
143 auth_required   if this is set and a POST/PUT is made without auth, the
144                 server will NOT wait for the full request body to get sent
145 idle            do nothing after receiving the request, just "sit idle"
146 stream          continuously send data to the client, never-ending
147 writedelay: [secs] delay this amount between reply packets
148 pipe: [num]     tell the server to expect this many HTTP requests before
149                 sending back anything, to allow pipelining tests
150 skip: [num]     instructs the server to ignore reading this many bytes from a PUT
151                 or POST request
152
153 rtp: part [num] channel [num] size [num]
154                stream a fake RTP packet for the given part on a chosen channel
155                with the given payload size
156
157 connection-monitor When used, this will log [DISCONNECT] to the server.input
158                log when the connection is disconnected.
159
160
161 For TFTP:
162 writedelay: [secs] delay this amount between reply packets (each packet being
163                    512 bytes payload)
164 </servercmd>
165 </reply>
166
167 <client>
168
169 <server>
170 What server(s) this test case requires/uses:
171
172 file
173 ftp
174 ftp-ipv6
175 ftps
176 http
177 http-ipv6
178 http-proxy
179 https
180 httptls+srp
181 httptls+srp-ipv6
182 imap
183 none
184 pop3
185 rtsp
186 rtsp-ipv6
187 scp
188 sftp
189 smtp
190 socks4
191 socks5
192
193 Give only one per line.  This subsection is mandatory.
194 </server>
195
196 <features>
197 A list of features that MUST be present in the client/library for this test to
198 be able to run (if these features are not present, the test will be
199 SKIPPED). Features testable here are:
200
201 axTLS
202 crypto
203 debug
204 getrlimit
205 GnuTLS
206 idn
207 ipv6
208 large_file
209 libz
210 Metalink
211 NSS
212 NTLM
213 OpenSSL
214 socks
215 SSL
216 TLS-SRP
217 TrackMemory
218 unittest
219
220 as well as each protocol that curl supports.  A protocol only needs to be
221 specified if it is different from the server (useful when the server
222 is 'none').
223 </features>
224
225 <killserver>
226 Using the same syntax as in <server> but when mentioned here these servers
227 are explicitly KILLED when this test case is completed. Only use this if there
228 is no other alternatives. Using this of course requires subsequent tests to
229 restart servers.
230 </killserver>
231
232 <precheck>
233 A command line that if set gets run by the test script before the test. If an
234 output is displayed by the command or if the return code is non-zero, the test
235 will be skipped and the (single-line) output will be displayed as reason for
236 not running the test.  Variables are substituted as in the <command> section.
237 </precheck>
238
239 <postcheck>
240 A command line that if set gets run by the test script after the test. If
241 the command exists with a non-zero status code, the test will be considered
242 to have failed. Variables are substituted as in the <command> section.
243 </postcheck>
244
245 <tool>
246 Name of tool to use instead of "curl". This tool must be built and exist
247 either in the libtest/ directory (if the tool starts with 'lib') or in the
248 unit/ directory (if the tool starts with 'unit').
249 </tool>
250
251 <name>
252 test case description
253 </name>
254
255 <setenv>
256 variable1=contents1
257 variable2=contents2
258
259 Set the given environment variables to the specified value before the actual
260 command is run. They are cleared again after the command has been run.
261 Variables are first substituted as in the <command> section.
262 </setenv>
263
264 <command [option="no-output/no-include"] [timeout="secs"] [delay="secs"]
265          [type="perl"]>
266 command line to run, there's a bunch of %variables that get replaced
267 accordingly.
268
269 Note that the URL that gets passed to the server actually controls what data
270 that is returned. The last slash in the URL must be followed by a number. That
271 number (N) will be used by the test-server to load test case N and return the
272 data that is defined within the <reply><data></data></reply> section.
273
274 If there's no test number found above, the HTTP test server will use the
275 number following the last dot in the given hostname (made so that a CONNECT
276 can still pass on test number) so that "foo.bar.123" gets treated as test case
277 123. Alternatively, if an ipv6-address is provided to CONNECT, the last
278 hexadecimal group in the address will be used as the test numer! For example
279 the address "[1234::ff]" would be treated as test case 255.
280
281 Set type="perl" to write the test case as a perl script. It implies that
282 there's no memory debugging and valgrind gets shut off for this test.
283
284 Set option="no-output" to prevent the test script to slap on the --output
285 argument that directs the output to a file. The --output is also not added if
286 the verify/stdout section is used.
287
288 Set option="no-include" to prevent the test script to slap on the --include
289 argument.
290
291 Set timeout="secs" to override default server logs advisor read lock timeout.
292 This timeout is used by the test harness, once that the command has completed
293 execution, to wait for the test server to write out server side log files and
294 remove the lock that advised not to read them. The "secs" parameter is the not
295 negative integer number of seconds for the timeout. This 'timeout' attribute
296 is documented for completeness sake, but is deep test harness stuff and only
297 needed for very singular and specific test cases. Avoid using it.
298
299 Set delay="secs" to introduce a time delay once that the command has completed
300 execution and before the <postcheck> section runs. The "secs" parameter is the
301 not negative integer number of seconds for the delay. This 'delay' attribute
302 is intended for very specific test cases, and normally not needed.
303
304 Available substitute variables include:
305 %CLIENT6IP - IPv6 address of the client running curl
306 %CLIENTIP  - IPv4 address of the client running curl
307 %CURL      - Path to the curl executable
308 %FTP2PORT  - Port number of the FTP server 2
309 %FTP6PORT  - IPv6 port number of the FTP server
310 %FTPPORT   - Port number of the FTP server
311 %FTPSPORT  - Port number of the FTPS server
312 %FTPTIME2  - Timeout in seconds that should be just sufficient to receive
313              a response from the test FTP server
314 %FTPTIME3  - Even longer than %FTPTIME2
315 %GOPHER6PORT  - IPv6 port number of the Gopher server
316 %GOPHERPORT   - Port number of the Gopher server
317 %HOST6IP      - IPv6 address of the host running this test
318 %HOSTIP       - IPv4 address of the host running this test
319 %HTTP6PORT    - IPv6 port number of the HTTP server
320 %HTTPPIPEPORT - Port number of the HTTP pipelining server
321 %HTTPPORT     - Port number of the HTTP server
322 %HTTPSPORT    - Port number of the HTTPS server
323 %HTTPTLS6PORT - IPv6 port number of the HTTP TLS server
324 %HTTPTLSPORT  - Port number of the HTTP TLS server
325 %IMAP6PORT - IPv6 port number of the IMAP server
326 %IMAPPORT  - Port number of the IMAP server
327 %POP36PORT - IPv6 ort number of the POP3 server
328 %POP3PORT  - Port number of the POP3 server
329 %PROXYPORT - Port number of the HTTP proxy
330 %PWD       - Current directory
331 %RTSP6PORT - IPv6 port number of the RTSP server
332 %RTSPPORT  - Port number of the RTSP server
333 %SMTP6PORT - IPv6 port number of the SMTP server
334 %SMTPPORT  - Port number of the SMTP server
335 %SOCKSPORT - Port number of the SOCKS4/5 server
336 %SRCDIR    - Full path to the source dir
337 %SSHPORT   - Port number of the SCP/SFTP server
338 %TFTP6PORT - IPv6 port number of the TFTP server
339 %TFTPPORT  - Port number of the TFTP server
340 %USER      - Login ID of the user running the test
341 </command>
342
343 <file name="log/filename">
344 This creates the named file with this content before the test case is run,
345 which is useful if the test case needs a file to act on.
346 Variables are substituted on the contents of the file as in the <command>
347 section.
348 </file>
349
350 <stdin [nonewline="yes"]>
351 Pass this given data on stdin to the tool.
352
353 If 'nonewline' is set, we will cut off the trailing newline of this given data
354 before comparing with the one actually received by the client
355 </stdin>
356
357 </client>
358
359 <verify>
360 <errorcode>
361 numerical error code curl is supposed to return. Specify a list of accepted
362 error codes by separating multiple numbers with comma. See test 237 for an
363 example.
364 </errorcode>
365 <strip>
366 One regex per line that is removed from the protocol dumps before the
367 comparison is made. This is very useful to remove dependencies on dynamically
368 changing protocol data such as port numbers or user-agent strings.
369 </strip>
370 <strippart>
371 One perl op per line that operates on the protocol dump. This is pretty
372 advanced. Example: "s/^EPRT .*/EPRT stripped/"
373 </strippart>
374
375 <protocol [nonewline="yes"]>
376
377 the protocol dump curl should transmit, if 'nonewline' is set, we will cut off
378 the trailing newline of this given data before comparing with the one actually
379 sent by the client Variables are substituted as in the <command> section.  The
380 <strip> and <strippart> rules are applied before comparisons are made.
381
382 </protocol>
383
384 <proxy [nonewline="yes"]>
385
386 The protocol dump curl should transmit to a HTTP proxy (when the http-proxy
387 server is used), if 'nonewline' is set, we will cut off the trailing newline
388 of this given data before comparing with the one actually sent by the client
389 Variables are substituted as in the <command> section. The <strip> and
390 <strippart> rules are applied before comparisons are made.
391
392 </proxy>
393
394 <stdout [mode="text"] [nonewline="yes"]>
395 This verifies that this data was passed to stdout.  Variables are
396 substituted as in the <command> section.
397
398 Use the mode="text" attribute if the output is in text mode on platforms that
399 have a text/binary difference.
400
401 If 'nonewline' is set, we will cut off the trailing newline of this given data
402 before comparing with the one actually received by the client
403 </stdout>
404 <file name="log/filename" [mode="text"]>
405 The file's contents must be identical to this after the test is complete.
406 Use the mode="text" attribute if the output is in text mode on platforms that
407 have a text/binary difference.
408 Variables are substituted as in the <command> section.
409 </file>
410 <stripfile>
411 One perl op per line that operates on the file before being compared. This is
412 pretty advanced. Example: "s/^EPRT .*/EPRT stripped/"
413 </stripfile>
414 <upload>
415 the contents of the upload data curl should have sent
416 </upload>
417 <valgrind>
418 disable - disables the valgrind log check for this test
419 </valgrind>
420 </verify>
421
422 </testcase>