README 9.9 KB

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