FILEFORMAT 15 KB

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