README 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. _ _ ____ _
  2. ___| | | | _ \| |
  3. / __| | | | |_) | |
  4. | (__| |_| | _ <| |___
  5. \___|\___/|_| \_\_____|
  6. The curl Test Suite
  7. 1. Running
  8. 1.1 Requires to run
  9. 1.2 Port numbers used by test servers
  10. 1.3 Test servers
  11. 1.4 Run
  12. 1.5 Shell startup scripts
  13. 1.6 Memory test
  14. 1.7 Debug
  15. 1.8 Logs
  16. 1.9 Test input files
  17. 1.10 Code coverage
  18. 1.11 Remote testing
  19. 2. Numbering
  20. 2.1 Test case numbering
  21. 3. Write tests
  22. 3.1 test data
  23. 3.2 curl tests
  24. 3.3 libcurl tests
  25. 3.4 unit tests
  26. 4. TODO
  27. 4.1 More protocols
  28. 4.2 SOCKS auth
  29. ==============================================================================
  30. 1. Running
  31. 1.1 Requires to run
  32. perl (and a unix-style shell)
  33. python (and a unix-style shell)
  34. diff (when a test fails, a diff is shown)
  35. stunnel (for HTTPS and FTPS tests)
  36. OpenSSH or SunSSH (for SCP, SFTP and SOCKS4/5 tests)
  37. nghttpx (for HTTP/2 tests)
  38. nroff (for --manual tests)
  39. 1.2 Port numbers used by test servers
  40. - TCP/8990 for HTTP
  41. - TCP/8991 for HTTPS
  42. - TCP/8992 for FTP
  43. - TCP/8993 for FTPS
  44. - TCP/8994 for HTTP IPv6
  45. - TCP/8995 for FTP (2)
  46. - TCP/8996 for FTP IPv6
  47. - UDP/8997 for TFTP
  48. - UDP/8998 for TFTP IPv6
  49. - TCP/8999 for SCP/SFTP
  50. - TCP/9000 for SOCKS
  51. - TCP/9001 for POP3
  52. - TCP/9002 for POP3 IPv6
  53. - TCP/9003 for IMAP
  54. - TCP/9004 for IMAP IPv6
  55. - TCP/9005 for SMTP
  56. - TCP/9006 for SMTP IPv6
  57. - TCP/9007 for RTSP
  58. - TCP/9008 for RTSP IPv6
  59. - TCP/9009 for GOPHER
  60. - TCP/9010 for GOPHER IPv6
  61. - TCP/9011 for HTTPS server with TLS-SRP support
  62. - TCP/9012 for HTTPS IPv6 server with TLS-SRP support
  63. - TCP/9013 for HTTP proxy server for CONNECT
  64. - TCP/9014 for HTTP pipelining server
  65. - TCP/9015 for HTTP/2 server
  66. - TCP/9016 for DICT server
  67. - TCP/9017 for SMB server
  68. - TCP/9018 for SMBS server (reserved)
  69. - TCP/9019 for TELNET server with negotiation support
  70. 1.3 Test servers
  71. The test suite runs simple FTP, POP3, IMAP, SMTP, HTTP and TFTP stand-alone
  72. servers on the ports listed above to which it makes requests. For SSL tests,
  73. it runs stunnel to handle encryption to the regular servers. For SSH, it
  74. runs a standard OpenSSH server. For SOCKS4/5 tests SSH is used to perform
  75. the SOCKS functionality and requires a SSH client and server.
  76. The base port number (8990), which all the individual port numbers are
  77. indexed from, can be set explicitly using runtests.pl' -b option to allow
  78. running more than one instance of the test suite simultaneously on one
  79. machine, or just move the servers in case you have local services on any of
  80. those ports.
  81. The HTTP server supports listening on a Unix domain socket, the default
  82. location is 'http.sock'.
  83. 1.4 Run
  84. './configure && make && make test'. This builds the test suite support code
  85. and invokes the 'runtests.pl' perl script to run all the tests. Edit the top
  86. variables of that script in case you have some specific needs, or run the
  87. script manually (after the support code has been built).
  88. The script breaks on the first test that doesn't do OK. Use -a to prevent
  89. the script from aborting on the first error. Run the script with -v for more
  90. verbose output. Use -d to run the test servers with debug output enabled as
  91. well. Specifying -k keeps all the log files generated by the test intact.
  92. Use -s for shorter output, or pass test numbers to run specific tests only
  93. (like "./runtests.pl 3 4" to test 3 and 4 only). It also supports test case
  94. ranges with 'to', as in "./runtests 3 to 9" which runs the seven tests from
  95. 3 to 9. Any test numbers starting with ! are disabled, as are any test
  96. numbers found in the files data/DISABLED or data/DISABLED.local (one per
  97. line). The latter is meant for local temporary disables and will be ignored
  98. by git.
  99. When -s is not present, each successful test will display on one line the
  100. test number and description and on the next line a set of flags, the test
  101. result, current test sequence, total number of tests to be run and an
  102. estimated amount of time to complete the test run. The flags consist of
  103. these letters describing what is checked in this test:
  104. s stdout
  105. d data
  106. u upload
  107. p protocol
  108. o output
  109. e exit code
  110. m memory
  111. v valgrind
  112. 1.5 Shell startup scripts
  113. Tests which use the ssh test server, SCP/SFTP/SOCKS tests, might be badly
  114. influenced by the output of system wide or user specific shell startup
  115. scripts, .bashrc, .profile, /etc/csh.cshrc, .login, /etc/bashrc, etc. which
  116. output text messages or escape sequences on user login. When these shell
  117. startup messages or escape sequences are output they might corrupt the
  118. expected stream of data which flows to the sftp-server or from the ssh
  119. client which can result in bad test behaviour or even prevent the test
  120. server from running.
  121. If the test suite ssh or sftp server fails to start up and logs the message
  122. 'Received message too long' then you are certainly suffering the unwanted
  123. output of a shell startup script. Locate, cleanup or adjust the shell
  124. script.
  125. 1.6 Memory test
  126. The test script will check that all allocated memory is freed properly IF
  127. curl has been built with the CURLDEBUG define set. The script will
  128. automatically detect if that is the case, and it will use the
  129. 'memanalyze.pl' script to analyze the memory debugging output.
  130. Also, if you run tests on a machine where valgrind is found, the script will
  131. use valgrind to run the test with (unless you use -n) to further verify
  132. correctness.
  133. runtests.pl's -t option will enable torture testing mode, which runs each
  134. test many times and makes each different memory allocation fail on each
  135. successive run. This tests the out of memory error handling code to ensure
  136. that memory leaks do not occur even in those situations. It can help to
  137. compile curl with CPPFLAGS=-DMEMDEBUG_LOG_SYNC when using this option, to
  138. ensure that the memory log file is properly written even if curl crashes.
  139. 1.7 Debug
  140. If a test case fails, you can conveniently get the script to invoke the
  141. debugger (gdb) for you with the server running and the exact same command
  142. line parameters that failed. Just invoke 'runtests.pl <test number> -g' and
  143. then just type 'run' in the debugger to perform the command through the
  144. debugger.
  145. 1.8 Logs
  146. All logs are generated in the log/ subdirectory (it is emptied first in the
  147. runtests.pl script). Use runtests.pl -k to force it to keep the temporary
  148. files after the test run since successful runs will clean it up otherwise.
  149. 1.9 Test input files
  150. All test cases are put in the data/ subdirectory. Each test is stored in the
  151. file named according to the test number.
  152. See FILEFORMAT for the description of the test case files.
  153. 1.10 Code coverage
  154. gcc provides a tool that can determine the code coverage figures for
  155. the test suite. To use it, configure curl with
  156. CFLAGS='-fprofile-arcs -ftest-coverage -g -O0'. Make sure you run the normal
  157. and torture tests to get more full coverage, i.e. do:
  158. make test
  159. make test-torture
  160. The graphical tool ggcov can be used to browse the source and create
  161. coverage reports on *NIX hosts:
  162. ggcov -r lib src
  163. The text mode tool gcov may also be used, but it doesn't handle object files
  164. in more than one directory very well.
  165. 1.11 Remote testing
  166. The runtests.pl script provides some hooks to allow curl to be tested on a
  167. machine where perl can not be run. The test framework in this case runs on
  168. a workstation where perl is available, while curl itself is run on a remote
  169. system using ssh or some other remote execution method. See the comments at
  170. the beginning of runtests.pl for details.
  171. 2. Numbering
  172. 2.1 Test case numbering
  173. 1 - 99 HTTP
  174. 100 - 199 FTP
  175. 200 - 299 FILE
  176. 300 - 399 HTTPS
  177. 400 - 499 FTPS
  178. 500 - 599 libcurl source code tests, not using the curl command tool
  179. 600 - 699 SCP/SFTP
  180. 700 - 799 SOCKS4 (even numbers) and SOCK5 (odd numbers)
  181. 800 - 849 IMAP
  182. 850 - 899 POP3
  183. 900 - 999 SMTP
  184. 1000 - 1299 miscellaneous
  185. 1300 - 1399 unit tests
  186. 1400 - 1499 miscellaneous
  187. 1500 - 1599 libcurl source code tests, not using the curl command tool
  188. (same as 5xx)
  189. 1600 - 1699 unit tests
  190. 2000 - x multiple sequential protocols per test case
  191. There's nothing in the system that *requires* us to keep within these number
  192. series.
  193. 3. Write tests
  194. Here's a quick description on writing test cases. We basically have three
  195. kinds of tests: the ones that test the curl tool, the ones that build small
  196. applications and test libcurl directly and the unit tests that test
  197. individual (possibly internal) functions.
  198. 3.1 test data
  199. Each test has a master file that controls all the test data. What to read,
  200. what the protocol exchange should look like, what exit code to expect and
  201. what command line arguments to use etc.
  202. These files are tests/data/test[num] where [num] is described in section 2
  203. of this document, and the XML-like file format of them is described in the
  204. separate tests/FILEFORMAT document.
  205. 3.2 curl tests
  206. A test case that runs the curl tool and verifies that it gets the correct
  207. data, it sends the correct data, it uses the correct protocol primitives
  208. etc.
  209. 3.3 libcurl tests
  210. The libcurl tests are identical to the curl ones, except that they use a
  211. specific and dedicated custom-built program to run instead of "curl". This
  212. tool is built from source code placed in tests/libtest and if you want to
  213. make a new libcurl test that is where you add your code.
  214. 3.4 unit tests
  215. Unit tests are tests in the 13xx sequence and they are placed in tests/unit.
  216. There's a tests/unit/README describing the specific set of checks and macros
  217. that may be used when writing tests that verify behaviors of specific
  218. individual functions.
  219. The unit tests depend on curl being built with debug enabled.
  220. 4. TODO
  221. 4.1 More protocols
  222. Add tests for TELNET, LDAP, DICT...
  223. 4.2 SOCKS auth
  224. SOCKS4/5 test deficiencies - no proxy authentication tests as SSH (the
  225. test mechanism) doesn't support them