FILEFORMAT 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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. <datacheck [nonewline="yes"]>
  67. if the data is sent but this is what should be checked afterwards. If
  68. 'nonewline' is set, we will cut off the trailing newline of this given data
  69. before comparing with the one actually received by the client
  70. </datacheck>
  71. <size>
  72. number to return on a ftp SIZE command (set to -1 to make this command fail)
  73. </size>
  74. <mdtm>
  75. what to send back if the client sends a (FTP) MDTM command, set to -1 to
  76. have it return that the file doesn't exist
  77. </mdtm>
  78. <postcmd>
  79. special purpose server-command to control its behavior *after* the
  80. reply is sent
  81. For HTTP/HTTPS, these are supported:
  82. wait [secs]
  83. - Pause for the given time
  84. </postcmd>
  85. <servercmd>
  86. Special-commands for the server.
  87. For FTP, these are supported:
  88. REPLY [command] [return value] [response string]
  89. - Changes how the server responds to the [command]. [response string] is
  90. evaluated as a perl string, so it can contain embedded \r\n, for example.
  91. COUNT [command] [num]
  92. - Do the REPLY change for [command] only [num] times and then go back to the
  93. built-in approach
  94. DELAY [command] [secs]
  95. - Delay responding to this command for the given time
  96. RETRWEIRDO
  97. - Enable the "weirdo" RETR case when multiple response lines appear at once
  98. when a file is transfered
  99. RETRNOSIZE
  100. - Make sure the RETR response doesn't contain the size of the file
  101. NOSAVE
  102. - Don't actually save what is received
  103. SLOWDOWN
  104. - Send FTP responses with 0.01 sec delay between each byte
  105. PASVBADIP
  106. - makes PASV send back an illegal IP in its 227 response
  107. For HTTP/HTTPS:
  108. auth_required if this is set and a POST/PUT is made without auth, the
  109. server will NOT wait for the full request body to get sent
  110. idle do nothing after receiving the request, just "sit idle"
  111. stream continuously send data to the client, never-ending
  112. pipe: [num] tell the server to expect this many HTTP requests before
  113. sending back anything, to allow pipelining tests
  114. skip: [num] instructs the server to ignore reading this many bytes from a PUT
  115. or POST request
  116. </servercmd>
  117. </reply>
  118. <client>
  119. <server>
  120. What server(s) this test case requires/uses:
  121. file
  122. ftp
  123. ftp-ipv6
  124. ftps
  125. http
  126. http-ipv6
  127. https
  128. none
  129. scp
  130. sftp
  131. socks4
  132. socks5
  133. Give only one per line. This subsection is mandatory.
  134. </server>
  135. <features>
  136. A list of features that MUST be present in the client/library for this test to
  137. be able to run (if these features are not present, the test will be
  138. SKIPPED). Features testable here are:
  139. crypto
  140. getrlimit
  141. GnuTLS
  142. idn
  143. ipv6
  144. large_file
  145. libz
  146. netrc_debug
  147. NSS
  148. OpenSSL
  149. SSL
  150. as well as each protocol that curl supports. A protocol only needs to be
  151. specified if it is different from the server (useful when the server
  152. is 'none').
  153. </features>
  154. <killserver>
  155. Using the same syntax as in <server> but when mentioned here these servers
  156. are explicitly KILLED when this test case is completed. Only use this if there
  157. is no other alternatives. Using this of course requires subsequent tests to
  158. restart servers.
  159. </killserver>
  160. <precheck>
  161. A command line that if set gets run by the test script before the test. If an
  162. output is displayed by the command or if the return code is non-zero, the test
  163. will be skipped and the (single-line) output will be displayed as reason for
  164. not running the test. Variables are substituted as in the <command> section.
  165. </precheck>
  166. <postcheck>
  167. A command line that if set gets run by the test script after the test. If
  168. the command exists with a non-zero status code, the test will be considered
  169. to have failed. Variables are substituted as in the <command> section.
  170. </postcheck>
  171. <tool>
  172. Name of tool to use instead of "curl". This tool must be built and exist
  173. in the libtest/ directory.
  174. </tool>
  175. <name>
  176. test case description
  177. </name>
  178. <setenv>
  179. variable1=contents1
  180. variable2=contents2
  181. Set the given environment variables to the specified value before the actual
  182. command is run. They are cleared again after the command has been run.
  183. Variables are first substituted as in the <command> section.
  184. </setenv>
  185. <command [option="no-output"] [timeout="secs"] [delay="secs"]>
  186. command line to run, there's a bunch of %variables that get replaced
  187. accordingly.
  188. Note that the URL that gets passed to the server actually controls what data
  189. that is returned. The last slash in the URL must be followed by a number. That
  190. number (N) will be used by the test-server to load test case N and return the
  191. data that is defined within the <reply><data></data></reply> section.
  192. If a CONNECT is used to the server (to emulate HTTPS etc over proxy), the port
  193. number given in the CONNECT request will be used to identify which test that
  194. is being run, if the proxy host name is said to start with 'test'.
  195. Set option="no-output" to prevent the test script to slap on the --output
  196. argument that directs the output to a file. The --output is also not added if
  197. the verify/stdout section is used.
  198. Set timeout="secs" to override default server logs advisor read lock timeout.
  199. This timeout is used by the test harness, once that the command has completed
  200. execution, to wait for the test server to write out server side log files and
  201. remove the lock that advised not to read them. The "secs" parameter is the not
  202. negative integer number of seconds for the timeout. This 'timeout' attribute
  203. is documented for completeness sake, but is deep test harness stuff and only
  204. needed for very singular and specific test cases. Avoid using it.
  205. Set delay="secs" to introduce a time delay once that the command has completed
  206. execution and before the <postcheck> section runs. The "secs" parameter is the
  207. not negative integer number of seconds for the delay. This 'delay' attribute
  208. is intended for very specific test cases, and normally not needed.
  209. Available substitute variables include:
  210. %CLIENTIP - IPv4 address of the client running curl
  211. %CLIENT6IP - IPv6 address of the client running curl
  212. %HOSTIP - IPv4 address of the host running this test
  213. %HOSTPORT - Port number of the HTTP server
  214. %HOST6IP - IPv6 address of the host running this test
  215. %HOST6PORT - IPv6 port number of the HTTP server
  216. %HTTPSPORT - Port number of the HTTPS server
  217. %FTPPORT - Port number of the FTP server
  218. %FTP6PORT - IPv6 port number of the FTP server
  219. %FTPSPORT - Port number of the FTPS server
  220. %FTP2PORT - Port number of the FTP server 2
  221. %FTPTIME2 - Timeout in seconds that should be just sufficient to receive
  222. a response from the test FTP server
  223. %TFTPPORT - Port number of the TFTP server
  224. %TFTP6PORT - IPv6 port number of the TFTP server
  225. %SSHPORT - Port number of the SCP/SFTP server
  226. %SOCKSPORT - Port number of the SOCKS4/5 server
  227. %SRCDIR - Full path to the source dir
  228. %PWD - Current directory
  229. %CURL - Path to the curl executable
  230. %USER - Login ID of the user running the test
  231. </command>
  232. <file name="log/filename">
  233. This creates the named file with this content before the test case is run,
  234. which is useful if the test case needs a file to act on.
  235. Variables are substituted on the contents of the file as in the <command>
  236. section.
  237. </file>
  238. <stdin>
  239. Pass this given data on stdin to the tool.
  240. </stdin>
  241. </client>
  242. <verify>
  243. <errorcode>
  244. numerical error code curl is supposed to return. Specify a list of accepted
  245. error codes by separating multiple numbers with comma. See test 237 for an
  246. example.
  247. </errorcode>
  248. <strip>
  249. One regex per line that is removed from the protocol dumps before the
  250. comparison is made. This is very useful to remove dependencies on dynamically
  251. changing protocol data such as port numbers or user-agent strings.
  252. </strip>
  253. <strippart>
  254. One perl op per line that operates on the protocol dump. This is pretty
  255. advanced. Example: "s/^EPRT .*/EPRT stripped/"
  256. </strippart>
  257. <protocol [nonewline="yes"]>
  258. the protocol dump curl should transmit, if 'nonewline' is set, we will cut
  259. off the trailing newline of this given data before comparing with the one
  260. actually sent by the client
  261. Variables are substituted as in the <command> section.
  262. </protocol>
  263. <stdout [mode="text"] [nonewline="yes"]>
  264. This verifies that this data was passed to stdout. Variables are
  265. substituted as in the <command> section.
  266. Use the mode="text" attribute if the output is in text mode on platforms that
  267. have a text/binary difference.
  268. If 'nonewline' is set, we will cut off the trailing newline of this given data
  269. before comparing with the one actually received by the client
  270. </stdout>
  271. <file name="log/filename" [mode="text"]>
  272. The file's contents must be identical to this after the test is complete.
  273. Use the mode="text" attribute if the output is in text mode on platforms that
  274. have a text/binary difference.
  275. Variables are substituted as in the <command> section.
  276. </file>
  277. <stripfile>
  278. One perl op per line that operates on the file before being compared. This is
  279. pretty advanced. Example: "s/^EPRT .*/EPRT stripped/"
  280. </stripfile>
  281. <upload>
  282. the contents of the upload data curl should have sent
  283. </upload>
  284. <valgrind>
  285. disable - disables the valgrind log check for this test
  286. </valgrind>
  287. </verify>
  288. </testcase>