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