Debian Codegraph @

deps/curl/tests/FILEFORMAT

raw
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 F) If a HTTP request is Negotiate, num gets incremented by one for each
78 request with Negotiate authorization header on the same test case.
79
80 Dynamically changing num in this way allows the test harness to be used to
81 test authentication negotiation where several different requests must be sent
82 to complete a transfer. The response to each request is found in its own data
83 section. Validating the entire negotiation sequence can be done by
84 specifying a datacheck section.
85 </dataNUM>
86 <connect>
87 The connect section is used instead of the 'data' for all CONNECT
88 requests. The remainder of the rules for the data section then apply but with
89 a connect prefix.
90 </connect>
91 <datacheck [mode="text"] [nonewline="yes"]>
92 if the data is sent but this is what should be checked afterwards. If
93 'nonewline' is set, we will cut off the trailing newline of this given data
94 before comparing with the one actually received by the client.
95
96 Use the mode="text" attribute if the output is in text mode on platforms that
97 have a text/binary difference.
98 </datacheck>
99 <datacheckNUM [nonewline="yes"] [mode="text"]>
100 The contents of numbered datacheck sections are appended to the non-numbered
101 one.
102 </datacheckNUM>
103 <size>
104 number to return on a ftp SIZE command (set to -1 to make this command fail)
105 </size>
106 <mdtm>
107 what to send back if the client sends a (FTP) MDTM command, set to -1 to
108 have it return that the file doesn't exist
109 </mdtm>
110 <postcmd>
111 special purpose server-command to control its behavior *after* the
112 reply is sent
113 For HTTP/HTTPS, these are supported:
114
115 wait [secs]
116 - Pause for the given time
117 </postcmd>
118 <servercmd>
119 Special-commands for the server.
120 For FTP/SMTP/POP/IMAP, these are supported:
121
122 REPLY [command] [return value] [response string]
123 - Changes how the server responds to the [command]. [response string] is
124 evaluated as a perl string, so it can contain embedded \r\n, for example.
125 There's a special [command] named "welcome" (without quotes) which is the
126 string sent immediately on connect as a welcome.
127 REPLYLF (like above but sends the response terminated with LF-only and not
128 CRLF)
129 COUNT [command] [num]
130 - Do the REPLY change for [command] only [num] times and then go back to the
131 built-in approach
132 DELAY [command] [secs]
133 - Delay responding to this command for the given time
134 RETRWEIRDO
135 - Enable the "weirdo" RETR case when multiple response lines appear at once
136 when a file is transferred
137 RETRNOSIZE
138 - Make sure the RETR response doesn't contain the size of the file
139 NOSAVE
140 - Don't actually save what is received
141 SLOWDOWN
142 - Send FTP responses with 0.01 sec delay between each byte
143 PASVBADIP
144 - makes PASV send back an illegal IP in its 227 response
145 CAPA [capabilities]
146 - Enables support for and specifies a list of space separated capabilities to
147 return to the client for the IMAP CAPABILITY, POP3 CAPA and SMTP EHLO
148 commands
149 AUTH [mechanisms]
150 - Enables support for SASL authentication and specifies a list of space
151 separated mechanisms for IMAP, POP3 and SMTP
152
153 For HTTP/HTTPS:
154 auth_required if this is set and a POST/PUT is made without auth, the
155 server will NOT wait for the full request body to get sent
156 idle do nothing after receiving the request, just "sit idle"
157 stream continuously send data to the client, never-ending
158 writedelay: [secs] delay this amount between reply packets
159 skip: [num] instructs the server to ignore reading this many bytes from a
160 PUT or POST request
161 rtp: part [num] channel [num] size [num]
162 stream a fake RTP packet for the given part on a chosen channel
163 with the given payload size
164 connection-monitor When used, this will log [DISCONNECT] to the server.input
165 log when the connection is disconnected.
166 upgrade when an HTTP upgrade header is found, the server will upgrade
167 to http2
168 swsclose instruct server to close connection after response
169 no-expect don't read the request body if Expect: is present
170
171 For TFTP:
172 writedelay: [secs] delay this amount between reply packets (each packet being
173 512 bytes payload)
174 </servercmd>
175 </reply>
176
177 <client>
178
179 <server>
180 What server(s) this test case requires/uses:
181
182 file
183 ftp
184 ftp-ipv6
185 ftps
186 http
187 http-ipv6
188 http-proxy
189 http-unix
190 https
191 httptls+srp
192 httptls+srp-ipv6
193 http/2
194 imap
195 none
196 pop3
197 rtsp
198 rtsp-ipv6
199 scp
200 sftp
201 smtp
202 socks4
203 socks5
204
205 Give only one per line. This subsection is mandatory.
206 </server>
207
208 <features>
209 A list of features that MUST be present in the client/library for this test to
210 be able to run. If a required feature is not present then the test will be
211 SKIPPED.
212
213 Alternatively a feature can be prefixed with an exclamation mark to indicate a
214 feature is NOT required. If the feature is present then the test will be
215 SKIPPED.
216
217 Features testable here are:
218
219 alt-svc
220 crypto
221 debug
222 getrlimit
223 GnuTLS
224 GSS-API
225 http/2
226 idn
227 ipv6
228 Kerberos
229 large_file
230 ld_preload
231 libz
232 manual
233 Metalink
234 NSS
235 NTLM
236 OpenSSL
237 PSL
238 socks
239 SPNEGO
240 SSL
241 SSLpinning
242 SSPI
243 threaded-resolver
244 TLS-SRP
245 TrackMemory
246 unittest
247 unix-sockets
248 win32
249 WinSSL
250
251 as well as each protocol that curl supports. A protocol only needs to be
252 specified if it is different from the server (useful when the server
253 is 'none').
254 </features>
255
256 <killserver>
257 Using the same syntax as in <server> but when mentioned here these servers
258 are explicitly KILLED when this test case is completed. Only use this if there
259 is no other alternatives. Using this of course requires subsequent tests to
260 restart servers.
261 </killserver>
262
263 <precheck>
264 A command line that if set gets run by the test script before the test. If an
265 output is displayed by the command or if the return code is non-zero, the test
266 will be skipped and the (single-line) output will be displayed as reason for
267 not running the test. Variables are substituted as in the <command> section.
268 </precheck>
269
270 <postcheck>
271 A command line that if set gets run by the test script after the test. If
272 the command exists with a non-zero status code, the test will be considered
273 to have failed. Variables are substituted as in the <command> section.
274 </postcheck>
275
276 <tool>
277 Name of tool to use instead of "curl". This tool must be built and exist
278 either in the libtest/ directory (if the tool starts with 'lib') or in the
279 unit/ directory (if the tool starts with 'unit').
280 </tool>
281
282 <name>
283 test case description
284 </name>
285
286 <setenv>
287 variable1=contents1
288 variable2=contents2
289
290 Set the given environment variables to the specified value before the actual
291 command is run. They are cleared again after the command has been run.
292 Variables are first substituted as in the <command> section.
293 </setenv>
294
295 <command [option="no-output/no-include/force-output"] [timeout="secs"]
296 [delay="secs"][type="perl"]>
297 command line to run, there's a bunch of %variables that get replaced
298 accordingly.
299
300 Note that the URL that gets passed to the server actually controls what data
301 that is returned. The last slash in the URL must be followed by a number. That
302 number (N) will be used by the test-server to load test case N and return the
303 data that is defined within the <reply><data></data></reply> section.
304
305 If there's no test number found above, the HTTP test server will use the
306 number following the last dot in the given hostname (made so that a CONNECT
307 can still pass on test number) so that "foo.bar.123" gets treated as test case
308 123. Alternatively, if an IPv6 address is provided to CONNECT, the last
309 hexadecimal group in the address will be used as the test number! For example
310 the address "[1234::ff]" would be treated as test case 255.
311
312 Set type="perl" to write the test case as a perl script. It implies that
313 there's no memory debugging and valgrind gets shut off for this test.
314
315 Set option="no-output" to prevent the test script to slap on the --output
316 argument that directs the output to a file. The --output is also not added if
317 the verify/stdout section is used.
318
319 Set option="force-output" to make use of --output even when the test is
320 otherwise written to verify stdout.
321
322 Set option="no-include" to prevent the test script to slap on the --include
323 argument.
324
325 Set timeout="secs" to override default server logs advisor read lock timeout.
326 This timeout is used by the test harness, once that the command has completed
327 execution, to wait for the test server to write out server side log files and
328 remove the lock that advised not to read them. The "secs" parameter is the not
329 negative integer number of seconds for the timeout. This 'timeout' attribute
330 is documented for completeness sake, but is deep test harness stuff and only
331 needed for very singular and specific test cases. Avoid using it.
332
333 Set delay="secs" to introduce a time delay once that the command has completed
334 execution and before the <postcheck> section runs. The "secs" parameter is the
335 not negative integer number of seconds for the delay. This 'delay' attribute
336 is intended for very specific test cases, and normally not needed.
337
338 Available substitute variables include:
339 %CLIENT6IP - IPv6 address of the client running curl
340 %CLIENTIP - IPv4 address of the client running curl
341 %CURL - Path to the curl executable
342 %FTP2PORT - Port number of the FTP server 2
343 %FTP6PORT - IPv6 port number of the FTP server
344 %FTPPORT - Port number of the FTP server
345 %FTPSPORT - Port number of the FTPS server
346 %FTPTIME2 - Timeout in seconds that should be just sufficient to receive
347 a response from the test FTP server
348 %FTPTIME3 - Even longer than %FTPTIME2
349 %GOPHER6PORT - IPv6 port number of the Gopher server
350 %GOPHERPORT - Port number of the Gopher server
351 %HOST6IP - IPv6 address of the host running this test
352 %HOSTIP - IPv4 address of the host running this test
353 %HTTP6PORT - IPv6 port number of the HTTP server
354 %HTTPUNIXPATH - Path to the Unix socket of the HTTP server
355 %HTTPPORT - Port number of the HTTP server
356 %HTTPSPORT - Port number of the HTTPS server
357 %HTTPTLS6PORT - IPv6 port number of the HTTP TLS server
358 %HTTPTLSPORT - Port number of the HTTP TLS server
359 %IMAP6PORT - IPv6 port number of the IMAP server
360 %IMAPPORT - Port number of the IMAP server
361 %POP36PORT - IPv6 port number of the POP3 server
362 %POP3PORT - Port number of the POP3 server
363 %PROXYPORT - Port number of the HTTP proxy
364 %PWD - Current directory
365 %POSIX_PWD - Current directory somewhat mingw friendly
366 %FILE_PWD - Current directory, on windows prefixed with a slash
367 %RTSP6PORT - IPv6 port number of the RTSP server
368 %RTSPPORT - Port number of the RTSP server
369 %SMTP6PORT - IPv6 port number of the SMTP server
370 %SMTPPORT - Port number of the SMTP server
371 %SOCKSPORT - Port number of the SOCKS4/5 server
372 %SRCDIR - Full path to the source dir
373 %SSHPORT - Port number of the SCP/SFTP server
374 %TFTP6PORT - IPv6 port number of the TFTP server
375 %TFTPPORT - Port number of the TFTP server
376 %USER - Login ID of the user running the test
377 </command>
378
379 <file name="log/filename">
380 This creates the named file with this content before the test case is run,
381 which is useful if the test case needs a file to act on.
382 Variables are substituted on the contents of the file as in the <command>
383 section.
384 </file>
385
386 <stdin [nonewline="yes"]>
387 Pass this given data on stdin to the tool.
388
389 If 'nonewline' is set, we will cut off the trailing newline of this given data
390 before comparing with the one actually received by the client
391 </stdin>
392
393 </client>
394
395 <verify>
396 <errorcode>
397 numerical error code curl is supposed to return. Specify a list of accepted
398 error codes by separating multiple numbers with comma. See test 237 for an
399 example.
400 </errorcode>
401 <strip>
402 One regex per line that is removed from the protocol dumps before the
403 comparison is made. This is very useful to remove dependencies on dynamically
404 changing protocol data such as port numbers or user-agent strings.
405 </strip>
406 <strippart>
407 One perl op per line that operates on the protocol dump. This is pretty
408 advanced. Example: "s/^EPRT .*/EPRT stripped/"
409 </strippart>
410
411 <protocol [nonewline="yes"]>
412
413 the protocol dump curl should transmit, if 'nonewline' is set, we will cut off
414 the trailing newline of this given data before comparing with the one actually
415 sent by the client Variables are substituted as in the <command> section. The
416 <strip> and <strippart> rules are applied before comparisons are made.
417
418 </protocol>
419
420 <proxy [nonewline="yes"]>
421
422 The protocol dump curl should transmit to a HTTP proxy (when the http-proxy
423 server is used), if 'nonewline' is set, we will cut off the trailing newline
424 of this given data before comparing with the one actually sent by the client
425 Variables are substituted as in the <command> section. The <strip> and
426 <strippart> rules are applied before comparisons are made.
427
428 </proxy>
429
430 <stdout [mode="text"] [nonewline="yes"]>
431 This verifies that this data was passed to stdout. Variables are
432 substituted as in the <command> section.
433
434 Use the mode="text" attribute if the output is in text mode on platforms that
435 have a text/binary difference.
436
437 If 'nonewline' is set, we will cut off the trailing newline of this given data
438 before comparing with the one actually received by the client
439 </stdout>
440 <file name="log/filename" [mode="text"]>
441 The file's contents must be identical to this after the test is complete.
442 Use the mode="text" attribute if the output is in text mode on platforms that
443 have a text/binary difference.
444 Variables are substituted as in the <command> section.
445 </file>
446 <file1>
447 1 to 4 can be appended to 'file' to compare more files.
448 </file1>
449 <file2>
450 </file2>
451 <file3>
452 </file3>
453 <file4>
454 </file4>
455 <stripfile>
456 One perl op per line that operates on the output file or stdout before being
457 compared with what is stored in the test file. This is pretty
458 advanced. Example: "s/^EPRT .*/EPRT stripped/"
459 </stripfile>
460 <stripfile1>
461 1 to 4 can be appended to 'stripfile' to strip the correspending <fileN>
462 content
463 </stripfile1>
464 <stripfile2>
465 </stripfile2>
466 <stripfile3>
467 </stripfile3>
468 <stripfile4>
469 </stripfile4>
470 <upload>
471 the contents of the upload data curl should have sent
472 </upload>
473 <valgrind>
474 disable - disables the valgrind log check for this test
475 </valgrind>
476 </verify>
477
478 </testcase>