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