runtests.1 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .\"
  25. .TH runtests.pl 1 "06 Jun 2023" runtests runtests
  26. .SH NAME
  27. runtests.pl \- run one or more test cases
  28. .SH SYNOPSIS
  29. .B runtests.pl [options] [tests]
  30. .SH DESCRIPTION
  31. \fIruntests.pl\fP runs one, several or all the existing test cases in curl's
  32. test suite. It is often called from the root Makefile of the curl package with
  33. \&'make test'.
  34. .SH "TESTS"
  35. Specify which test(s) to run by specifying test numbers or keywords.
  36. If no test number or keyword is given, all existing tests that the script can
  37. find will be considered for running. You can specify single test cases to run
  38. by specifying test numbers space-separated, like "1 3 5 7 11", and you can
  39. specify a range of tests like "45 to 67".
  40. Specify tests to not run with a leading exclamation point, like "!66", which
  41. runs all available tests except number 66.
  42. Prefix a test number with a tilde (~) to still run it, but ignore the results.
  43. It is also possible to specify tests based on a keyword describing the test(s)
  44. to run, like "FTPS". The keywords are strings used in the individual tests.
  45. You can also specify keywords with a leading exclamation point and the keyword
  46. or phrase, like "!HTTP NTLM auth" to run all tests \fBexcept\fP those using
  47. this keyword. Remember that the exclamation marks and spaces will need to be
  48. quoted somehow when entered at many command shells.
  49. Prefix a keyword with a tilde (~) to still run it, but ignore the results.
  50. .SH "OUTPUT"
  51. When running without -s (short output), for instance when running runtests.pl
  52. directly rather than via make, each test will emits a pair of lines like this:
  53. Test 0045...[simple HTTP Location: without protocol in initial URL]
  54. --pd---e-v- OK (45 out of 1427, remaining: 16:08, took 6.188s, duration: 00:31)
  55. the first line contains the test number and a description. On the second line,
  56. the characters at the beginning are flags indicating which aspects of curl's
  57. behavior were checked by the test:
  58. s stdout
  59. r stderr
  60. p protocol
  61. d data
  62. u upload
  63. P proxy
  64. o output
  65. e exit code
  66. m memory
  67. v valgrind
  68. E the test was run event-based
  69. The remainder of the second line contains the test result, current test sequence,
  70. total number of tests to be run and an estimated amount of time to complete the
  71. test run.
  72. .SH OPTIONS
  73. .IP "-a"
  74. Continue running the rest of the test cases even if one test fails. By
  75. default, the test script stops as soon as an error is detected.
  76. .IP "-ac <curl>"
  77. Provide a path to a curl binary to talk to APIs (currently only CI test APIs).
  78. .IP "-am"
  79. Display test results in automake style output (PASS/FAIL: [number] [name]).
  80. .IP "-c <curl>"
  81. Provide a path to a custom curl binary to run the tests with. Default is the
  82. curl executable in the build tree.
  83. .IP "-d"
  84. Enable protocol debug: have the servers display protocol output. If used in
  85. conjunction with parallel testing, it will be difficult to associate the logs
  86. with the test being run.
  87. .IP "-E <exclude_file>"
  88. Load the \fBexclude_file\fP with additional reasons why certain tests
  89. should be skipped. Useful when testing with external HTTP proxies in
  90. which case some of the tests aren't appropriate.
  91. The file contains colon-delimited lines. The first field contains the
  92. type of exclusion, the second field contains a pattern and the final
  93. field contains the reason why matching tests should be skipped.
  94. The exclusion types are \fkeyword\fP, \ftest\fP, and \ftool\fP.
  95. .IP "-e"
  96. Run the test event-based (if possible). This will make runtests invoke curl
  97. with --test-event option. This option only works if both curl and libcurl were
  98. built debug-enabled.
  99. .IP "-f"
  100. Force the test to run even if mentioned in DISABLED.
  101. .IP "-g"
  102. Run the given test(s) with gdb. This is best used on a single test case and
  103. curl built --disable-shared. This then fires up gdb with command line set to
  104. run the specified test case. Simply (set a break-point and) type 'run' to
  105. start.
  106. .IP "-gl"
  107. Run the given test(s) with lldb. This is best used on a single test case and
  108. curl built --disable-shared. This then fires up lldb with command line set to
  109. run the specified test case. Simply (set a break-point and) type 'run' to
  110. start.
  111. .IP "-gw"
  112. Run the given test(s) with gdb as a windowed application.
  113. .IP "-h, --help"
  114. Displays a help text about this program's command line options.
  115. .IP "-j[num]"
  116. Spawn num processes to run tests. This defaults to 0 to run tests serially
  117. within a single process. Using a number greater than one allows multiple tests
  118. to run in parallel, speeding up a test run. The optimum number is dependent on
  119. the system and set of tests to run, but 7*number of CPU cores is a good figure
  120. to start with, or 1.3*number of CPU cores if Valgrind is in use. Enabling
  121. parallel tests is not recommended in conjunction with the \-g option.
  122. .IP "-k"
  123. Keep output and log files in log/ after a test run, even if no error was
  124. detected. Useful for debugging.
  125. .IP "-L <file>"
  126. Load and execute the specified file which should contain perl code.
  127. This option allows one to change \fIruntests.pl\fP behaviour by overwriting
  128. functions and variables and is useful when testing external proxies
  129. using curl's regression test suite.
  130. .IP "-l"
  131. Lists all test case names.
  132. .IP "-n"
  133. Disable the check for and use of valgrind.
  134. .IP "--no-debuginfod"
  135. Delete the DEBUGINFOD_URLS variable if that is defined. Makes valgrind, gdb
  136. etc not able to use this functionality.
  137. .IP "-o <variablename=value>"
  138. Overwrite the specified internal \fBvariable\fP with \fBvalue\fP.
  139. Useful to change variables that didn't get a dedicated flag to change them.
  140. Check the source to see which variables are available.
  141. .IP "-P <proxy>"
  142. Use the specified HTTP proxy when executing tests, even if the tests
  143. themselves don't specify a proxy. This option allows one to test external
  144. proxies using curl's regression test suite.
  145. .IP "-p"
  146. Prints out all files in "log/" to stdout when a test case fails. Very
  147. practical when used in the automated and distributed tests since then the
  148. people checking the failures and the reasons for them might not have physical
  149. access to the machine and logs.
  150. .IP "-R"
  151. Run the tests in a scrambled, or randomized, order instead of sequentially.
  152. The random seed initially set for this is fixed per month and can be set with
  153. \fI--seed\fP.
  154. .IP "-r"
  155. Display run time statistics. (Requires Perl Time::HiRes module)
  156. .IP "-rf"
  157. Display full run time statistics. (Requires Perl Time::HiRes module)
  158. .IP "-rm"
  159. Force removal of files by killing locking processes. (Windows only,
  160. requires Sysinternals handle[64].exe to be on PATH)
  161. .IP "--repeat=[num]"
  162. This will repeat the given set of test numbers this many times. If no test
  163. numbers are given, it will repeat ALL tests this many times. It iteratively
  164. adds the new sequence at the end of the initially given one.
  165. If \fB-R\fP is also used, the scrambling is done after the repeats have
  166. extended the test sequence.
  167. .IP "-s"
  168. Shorter output. Speaks less than default.
  169. .IP "--seed=[num]"
  170. When using \fI--shallow\fP or \fI-R\fP that randomize certain aspects of the
  171. behavior, this option can set the initial seed. If not set, the random seed
  172. will be set based on the currently set local year and month and the first line
  173. of the "curl -V" output.
  174. .IP "--shallow=[num]"
  175. Used together with \fB-t\fP. This limits the number of tests to fail in
  176. torture mode to no more than 'num' per test case. If this reduces the amount,
  177. the script will randomly discard entries to fail until the amount is 'num'.
  178. The random seed initially set for this is fixed per month and can be set with
  179. \fI--seed\fP.
  180. .IP "-t[num]"
  181. Selects a \fBtorture\fP test for the given tests. This makes runtests.pl first
  182. run the tests once and count the number of memory allocations made. It then
  183. reruns the test that number of times, each time forcing one of the allocations
  184. to fail until all allocs have been tested. By setting \fInum\fP you can force
  185. the allocation with that number to be set to fail at once instead of looping
  186. through everyone, which is very handy when debugging and then often in
  187. combination with \fI-g\fP.
  188. .IP "-u"
  189. Error instead of warning on server unexpectedly alive.
  190. .IP "-v"
  191. Enable verbose output. Speaks more than by default. If used in conjunction with
  192. parallel testing, it will be difficult to associate the logs with the test
  193. being run.
  194. .IP "-vc <curl>"
  195. Provide a path to a custom curl binary to run when verifying that the servers
  196. running are indeed our test servers. Default is the curl executable in the
  197. build tree.
  198. .SH "RUNNING TESTS"
  199. Many tests have conditions that must be met before the test case can run
  200. fine. They could depend on built-in features in libcurl or features present in
  201. the operating system or even in third-party libraries that curl may or may not
  202. use.
  203. .P
  204. The test script checks most of these by itself to determine when it is
  205. safe to attempt to run each test. Those which cannot be run due to
  206. failed requirements will simply be skipped and listed at the completion
  207. of all test cases. In some unusual configurations, the test script
  208. cannot make the correct determination for all tests. In these cases,
  209. the problematic tests can be skipped using the "!keyword" skip feature
  210. documented earlier.
  211. .SH "WRITING TESTS"
  212. The simplest way to write test cases is to start with a similar existing test,
  213. save it with a new number and then adjust it to fit. There's an attempt to
  214. document the test case file format in the tests/FILEFORMAT.md.