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