1*6236dae4SAndroid Build Coastguard Worker--- 2*6236dae4SAndroid Build Coastguard Workerc: Copyright (C) Daniel Stenberg, <daniel.se>, et al. 3*6236dae4SAndroid Build Coastguard WorkerSPDX-License-Identifier: curl 4*6236dae4SAndroid Build Coastguard WorkerTitle: runtests.pl 5*6236dae4SAndroid Build Coastguard WorkerSection: 1 6*6236dae4SAndroid Build Coastguard WorkerSource: runtests 7*6236dae4SAndroid Build Coastguard WorkerSee-also: 8*6236dae4SAndroid Build Coastguard Worker - runtests.pl 9*6236dae4SAndroid Build Coastguard WorkerAdded-in: 7.5 10*6236dae4SAndroid Build Coastguard Worker--- 11*6236dae4SAndroid Build Coastguard Worker 12*6236dae4SAndroid Build Coastguard Worker# NAME 13*6236dae4SAndroid Build Coastguard Worker 14*6236dae4SAndroid Build Coastguard Workerruntests.pl - run one or more test cases 15*6236dae4SAndroid Build Coastguard Worker 16*6236dae4SAndroid Build Coastguard Worker# SYNOPSIS 17*6236dae4SAndroid Build Coastguard Worker 18*6236dae4SAndroid Build Coastguard Worker**runtests.pl [options] [tests]** 19*6236dae4SAndroid Build Coastguard Worker 20*6236dae4SAndroid Build Coastguard Worker# DESCRIPTION 21*6236dae4SAndroid Build Coastguard Worker 22*6236dae4SAndroid Build Coastguard Worker*runtests.pl* runs one, several or all the existing test cases in curl's 23*6236dae4SAndroid Build Coastguard Workertest suite. It is often called from the root Makefile of the curl package with 24*6236dae4SAndroid Build Coastguard Worker'make test'. 25*6236dae4SAndroid Build Coastguard Worker 26*6236dae4SAndroid Build Coastguard Worker# TESTS 27*6236dae4SAndroid Build Coastguard Worker 28*6236dae4SAndroid Build Coastguard WorkerSpecify which test(s) to run by specifying test numbers or keywords. 29*6236dae4SAndroid Build Coastguard Worker 30*6236dae4SAndroid Build Coastguard WorkerIf no test number or keyword is given, all existing tests that the script can 31*6236dae4SAndroid Build Coastguard Workerfind are considered for running. You can specify single test cases to run by 32*6236dae4SAndroid Build Coastguard Workerspecifying test numbers space-separated, like `1 3 5 7 11`, and you can 33*6236dae4SAndroid Build Coastguard Workerspecify a range of tests like `45 to 67`. 34*6236dae4SAndroid Build Coastguard Worker 35*6236dae4SAndroid Build Coastguard WorkerSpecify tests to not run with a leading exclamation point, like `!66`, which 36*6236dae4SAndroid Build Coastguard Workerruns all available tests except number 66. 37*6236dae4SAndroid Build Coastguard Worker 38*6236dae4SAndroid Build Coastguard WorkerPrefix a test number with a tilde (~) to still run it, but ignore the results. 39*6236dae4SAndroid Build Coastguard Worker 40*6236dae4SAndroid Build Coastguard WorkerIt is also possible to specify tests based on a keyword describing the test(s) 41*6236dae4SAndroid Build Coastguard Workerto run, like `FTPS`. The keywords are strings used in the individual tests. 42*6236dae4SAndroid Build Coastguard Worker 43*6236dae4SAndroid Build Coastguard WorkerYou can also specify keywords with a leading exclamation point and the keyword 44*6236dae4SAndroid Build Coastguard Workeror phrase, like "!HTTP NTLM auth" to run all tests **except** those using this 45*6236dae4SAndroid Build Coastguard Workerkeyword. Remember that the exclamation marks and spaces need to be quoted 46*6236dae4SAndroid Build Coastguard Workersomehow when entered at many command shells. 47*6236dae4SAndroid Build Coastguard Worker 48*6236dae4SAndroid Build Coastguard WorkerPrefix a keyword with a tilde (~) to still run it, but ignore the results. 49*6236dae4SAndroid Build Coastguard Worker 50*6236dae4SAndroid Build Coastguard Worker# OUTPUT 51*6236dae4SAndroid Build Coastguard Worker 52*6236dae4SAndroid Build Coastguard WorkerWhen running without `-s` (short output), for instance when running 53*6236dae4SAndroid Build Coastguard Workerruntests.pl directly rather than via make, each test emits a pair of lines 54*6236dae4SAndroid Build Coastguard Workerlike this: 55*6236dae4SAndroid Build Coastguard Worker 56*6236dae4SAndroid Build Coastguard Worker Test 0045...[simple HTTP Location: without protocol in initial URL] 57*6236dae4SAndroid Build Coastguard Worker --pd---e-v- OK (45 out of 1427, remaining: 16:08, took 6.188s, duration: 00:31) 58*6236dae4SAndroid Build Coastguard Worker 59*6236dae4SAndroid Build Coastguard Workerthe first line contains the test number and a description. On the second line, 60*6236dae4SAndroid Build Coastguard Workerthe characters at the beginning are flags indicating which aspects of curl's 61*6236dae4SAndroid Build Coastguard Workerbehavior were checked by the test: 62*6236dae4SAndroid Build Coastguard Worker 63*6236dae4SAndroid Build Coastguard Worker s stdout 64*6236dae4SAndroid Build Coastguard Worker r stderr 65*6236dae4SAndroid Build Coastguard Worker p protocol 66*6236dae4SAndroid Build Coastguard Worker d data 67*6236dae4SAndroid Build Coastguard Worker u upload 68*6236dae4SAndroid Build Coastguard Worker P proxy 69*6236dae4SAndroid Build Coastguard Worker o output 70*6236dae4SAndroid Build Coastguard Worker e exit code 71*6236dae4SAndroid Build Coastguard Worker m memory 72*6236dae4SAndroid Build Coastguard Worker v valgrind 73*6236dae4SAndroid Build Coastguard Worker E the test was run event-based 74*6236dae4SAndroid Build Coastguard Worker 75*6236dae4SAndroid Build Coastguard WorkerThe remainder of the second line contains the test result, current test sequence, 76*6236dae4SAndroid Build Coastguard Workertotal number of tests to be run and an estimated amount of time to complete the 77*6236dae4SAndroid Build Coastguard Workertest run. 78*6236dae4SAndroid Build Coastguard Worker 79*6236dae4SAndroid Build Coastguard Worker# OPTIONS 80*6236dae4SAndroid Build Coastguard Worker 81*6236dae4SAndroid Build Coastguard Worker## `-a` 82*6236dae4SAndroid Build Coastguard Worker 83*6236dae4SAndroid Build Coastguard WorkerContinue running the rest of the test cases even if one test fails. By 84*6236dae4SAndroid Build Coastguard Workerdefault, the test script stops as soon as an error is detected. 85*6236dae4SAndroid Build Coastguard Worker 86*6236dae4SAndroid Build Coastguard Worker## `-ac \<curl\>` 87*6236dae4SAndroid Build Coastguard Worker 88*6236dae4SAndroid Build Coastguard WorkerProvide a path to a curl binary to talk to APIs (currently only CI test APIs). 89*6236dae4SAndroid Build Coastguard Worker 90*6236dae4SAndroid Build Coastguard Worker## `-am` 91*6236dae4SAndroid Build Coastguard Worker 92*6236dae4SAndroid Build Coastguard WorkerDisplay test results in automake style output (`PASS/FAIL: [number] [name]`). 93*6236dae4SAndroid Build Coastguard Worker 94*6236dae4SAndroid Build Coastguard Worker## `-bundle` 95*6236dae4SAndroid Build Coastguard Worker 96*6236dae4SAndroid Build Coastguard WorkerRun tests via bundled test binaries. Bundled test binaries contain all tests, 97*6236dae4SAndroid Build Coastguard Workerand the test name passed as the first argument selects which test run. 98*6236dae4SAndroid Build Coastguard Worker 99*6236dae4SAndroid Build Coastguard Worker## `-c\<curl\>` 100*6236dae4SAndroid Build Coastguard Worker 101*6236dae4SAndroid Build Coastguard WorkerProvide a path to a custom curl binary to run the tests with. Default is the 102*6236dae4SAndroid Build Coastguard Workercurl executable in the build tree. 103*6236dae4SAndroid Build Coastguard Worker 104*6236dae4SAndroid Build Coastguard Worker## `-d` 105*6236dae4SAndroid Build Coastguard Worker 106*6236dae4SAndroid Build Coastguard WorkerEnable protocol debug: have the servers display protocol output. If used in 107*6236dae4SAndroid Build Coastguard Workerconjunction with parallel testing, it is difficult to associate the logs with 108*6236dae4SAndroid Build Coastguard Workerthe specific test being run. 109*6236dae4SAndroid Build Coastguard Worker 110*6236dae4SAndroid Build Coastguard Worker## `-E \<exclude_file\>` 111*6236dae4SAndroid Build Coastguard Worker 112*6236dae4SAndroid Build Coastguard WorkerLoad the **exclude_file** with additional reasons why certain tests should be 113*6236dae4SAndroid Build Coastguard Workerskipped. Useful when testing with external HTTP proxies in which case some of 114*6236dae4SAndroid Build Coastguard Workerthe tests are not appropriate. 115*6236dae4SAndroid Build Coastguard Worker 116*6236dae4SAndroid Build Coastguard WorkerThe file contains colon-delimited lines. The first field contains the type of 117*6236dae4SAndroid Build Coastguard Workerexclusion, the second field contains a pattern and the final field contains 118*6236dae4SAndroid Build Coastguard Workerthe reason why matching tests should be skipped. The exclusion types are 119*6236dae4SAndroid Build Coastguard Worker*keyword*, *test*, and *tool*. 120*6236dae4SAndroid Build Coastguard Worker 121*6236dae4SAndroid Build Coastguard Worker## `-e` 122*6236dae4SAndroid Build Coastguard Worker 123*6236dae4SAndroid Build Coastguard WorkerRun the test event-based (if possible). This makes runtests invoke curl with 124*6236dae4SAndroid Build Coastguard Worker--test-event option. This option only works if both curl and libcurl were 125*6236dae4SAndroid Build Coastguard Workerbuilt debug-enabled. 126*6236dae4SAndroid Build Coastguard Worker 127*6236dae4SAndroid Build Coastguard Worker## `-f` 128*6236dae4SAndroid Build Coastguard Worker 129*6236dae4SAndroid Build Coastguard WorkerForce the test to run even if mentioned in DISABLED. 130*6236dae4SAndroid Build Coastguard Worker 131*6236dae4SAndroid Build Coastguard Worker## `-g` 132*6236dae4SAndroid Build Coastguard Worker 133*6236dae4SAndroid Build Coastguard WorkerRun the given test(s) with gdb. This is best used on a single test case and 134*6236dae4SAndroid Build Coastguard Workercurl built --disable-shared. This then fires up gdb with command line set to 135*6236dae4SAndroid Build Coastguard Workerrun the specified test case. Simply (set a break-point and) type 'run' to 136*6236dae4SAndroid Build Coastguard Workerstart. 137*6236dae4SAndroid Build Coastguard Worker 138*6236dae4SAndroid Build Coastguard Worker## `-gl` 139*6236dae4SAndroid Build Coastguard Worker 140*6236dae4SAndroid Build Coastguard WorkerRun the given test(s) with lldb. This is best used on a single test case and 141*6236dae4SAndroid Build Coastguard Workercurl built --disable-shared. This then fires up lldb with command line set to 142*6236dae4SAndroid Build Coastguard Workerrun the specified test case. Simply (set a break-point and) type 'run' to 143*6236dae4SAndroid Build Coastguard Workerstart. 144*6236dae4SAndroid Build Coastguard Worker 145*6236dae4SAndroid Build Coastguard Worker## `-gw` 146*6236dae4SAndroid Build Coastguard Worker 147*6236dae4SAndroid Build Coastguard WorkerRun the given test(s) with gdb as a windowed application. 148*6236dae4SAndroid Build Coastguard Worker 149*6236dae4SAndroid Build Coastguard Worker## `-h, --help` 150*6236dae4SAndroid Build Coastguard Worker 151*6236dae4SAndroid Build Coastguard WorkerDisplays a help text about this program's command line options. 152*6236dae4SAndroid Build Coastguard Worker 153*6236dae4SAndroid Build Coastguard Worker## `-j[num]` 154*6236dae4SAndroid Build Coastguard Worker 155*6236dae4SAndroid Build Coastguard WorkerSpawn the given number of processes to run tests in. This defaults to 0 to run 156*6236dae4SAndroid Build Coastguard Workertests serially within a single process. Using a number greater than one allows 157*6236dae4SAndroid Build Coastguard Workermultiple tests to run in parallel, speeding up a test run. The optimum number 158*6236dae4SAndroid Build Coastguard Workeris dependent on the system and set of tests to run, but 7 times the number of 159*6236dae4SAndroid Build Coastguard WorkerCPU cores is a good figure to start with, or 1.3 times if Valgrind is in use, 160*6236dae4SAndroid Build Coastguard Workeror 5 times for torture tests. Enabling parallel tests is not recommended in 161*6236dae4SAndroid Build Coastguard Workerconjunction with the -g option. 162*6236dae4SAndroid Build Coastguard Worker 163*6236dae4SAndroid Build Coastguard Worker## `-k` 164*6236dae4SAndroid Build Coastguard Worker 165*6236dae4SAndroid Build Coastguard WorkerKeep output and log files in log/ after a test run, even if no error was 166*6236dae4SAndroid Build Coastguard Workerdetected. Useful for debugging. 167*6236dae4SAndroid Build Coastguard Worker 168*6236dae4SAndroid Build Coastguard Worker## `-L \<file\>` 169*6236dae4SAndroid Build Coastguard Worker 170*6236dae4SAndroid Build Coastguard WorkerLoad and execute the specified file which should contain perl code. This 171*6236dae4SAndroid Build Coastguard Workeroption allows one to change *runtests.pl* behavior by overwriting functions 172*6236dae4SAndroid Build Coastguard Workerand variables and is useful when testing external proxies using curl's 173*6236dae4SAndroid Build Coastguard Workerregression test suite. 174*6236dae4SAndroid Build Coastguard Worker 175*6236dae4SAndroid Build Coastguard Worker## `-l` 176*6236dae4SAndroid Build Coastguard Worker 177*6236dae4SAndroid Build Coastguard WorkerLists all test case names. 178*6236dae4SAndroid Build Coastguard Worker 179*6236dae4SAndroid Build Coastguard Worker## `-n` 180*6236dae4SAndroid Build Coastguard Worker 181*6236dae4SAndroid Build Coastguard WorkerDisable the check for and use of valgrind. 182*6236dae4SAndroid Build Coastguard Worker 183*6236dae4SAndroid Build Coastguard Worker## `--no-debuginfod` 184*6236dae4SAndroid Build Coastguard Worker 185*6236dae4SAndroid Build Coastguard WorkerDelete the `DEBUGINFOD_URLS` variable if that is defined. Makes valgrind, gdb 186*6236dae4SAndroid Build Coastguard Workeretc not able to use this functionality. 187*6236dae4SAndroid Build Coastguard Worker 188*6236dae4SAndroid Build Coastguard Worker## `-o \<variablename=value\>` 189*6236dae4SAndroid Build Coastguard Worker 190*6236dae4SAndroid Build Coastguard WorkerOverwrite the specified internal **variable** with **value**. Useful to change 191*6236dae4SAndroid Build Coastguard Workervariables that did not get a dedicated flag to change them. Check the source to 192*6236dae4SAndroid Build Coastguard Workersee which variables are available. 193*6236dae4SAndroid Build Coastguard Worker 194*6236dae4SAndroid Build Coastguard Worker## `-P \<proxy\>` 195*6236dae4SAndroid Build Coastguard Worker 196*6236dae4SAndroid Build Coastguard WorkerUse the specified HTTP proxy when executing tests, even if the tests 197*6236dae4SAndroid Build Coastguard Workerthemselves do not specify a proxy. This option allows one to test external 198*6236dae4SAndroid Build Coastguard Workerproxies using curl's regression test suite. 199*6236dae4SAndroid Build Coastguard Worker 200*6236dae4SAndroid Build Coastguard Worker## `-p` 201*6236dae4SAndroid Build Coastguard Worker 202*6236dae4SAndroid Build Coastguard WorkerPrints out all files in the log directory to stdout when a test case fails. 203*6236dae4SAndroid Build Coastguard WorkerPractical when used in the automated and distributed tests since then the 204*6236dae4SAndroid Build Coastguard Workerpeople checking the failures and the reasons for them might not have physical 205*6236dae4SAndroid Build Coastguard Workeraccess to the machine and logs. 206*6236dae4SAndroid Build Coastguard Worker 207*6236dae4SAndroid Build Coastguard Worker## `-R` 208*6236dae4SAndroid Build Coastguard Worker 209*6236dae4SAndroid Build Coastguard WorkerRun the tests in a scrambled, or randomized, order instead of sequentially. 210*6236dae4SAndroid Build Coastguard Worker 211*6236dae4SAndroid Build Coastguard WorkerThe random seed initially set for this is fixed per month and can be set with 212*6236dae4SAndroid Build Coastguard Worker*--seed*. 213*6236dae4SAndroid Build Coastguard Worker 214*6236dae4SAndroid Build Coastguard Worker## `-r` 215*6236dae4SAndroid Build Coastguard Worker 216*6236dae4SAndroid Build Coastguard WorkerDisplay run time statistics. (Requires the `Perl Time::HiRes` module) 217*6236dae4SAndroid Build Coastguard Worker 218*6236dae4SAndroid Build Coastguard Worker## `-rf` 219*6236dae4SAndroid Build Coastguard Worker 220*6236dae4SAndroid Build Coastguard WorkerDisplay full run time statistics. (Requires the `Perl Time::HiRes` module) 221*6236dae4SAndroid Build Coastguard Worker 222*6236dae4SAndroid Build Coastguard Worker## `-rm` 223*6236dae4SAndroid Build Coastguard Worker 224*6236dae4SAndroid Build Coastguard WorkerForce removal of files by killing locking processes. (Windows only, requires 225*6236dae4SAndroid Build Coastguard Workerthe **Sysinternals** `handle[64].exe` to be on PATH) 226*6236dae4SAndroid Build Coastguard Worker 227*6236dae4SAndroid Build Coastguard Worker## `--repeat=[num]` 228*6236dae4SAndroid Build Coastguard Worker 229*6236dae4SAndroid Build Coastguard WorkerThis repeats the given set of test numbers this many times. If no test numbers 230*6236dae4SAndroid Build Coastguard Workerare given, it repeats ALL tests this many times. It adds the new repeated 231*6236dae4SAndroid Build Coastguard Workersequence at the end of the initially given one. 232*6236dae4SAndroid Build Coastguard Worker 233*6236dae4SAndroid Build Coastguard WorkerIf **-R** option is also used, the scrambling is done after the repeats have 234*6236dae4SAndroid Build Coastguard Workerextended the test sequence. 235*6236dae4SAndroid Build Coastguard Worker 236*6236dae4SAndroid Build Coastguard Worker## `-s` 237*6236dae4SAndroid Build Coastguard Worker 238*6236dae4SAndroid Build Coastguard WorkerShorter output. Speaks less than default. 239*6236dae4SAndroid Build Coastguard Worker 240*6236dae4SAndroid Build Coastguard Worker## `--seed=[num]` 241*6236dae4SAndroid Build Coastguard Worker 242*6236dae4SAndroid Build Coastguard WorkerWhen using *--shallow* or *-R* that randomize certain aspects of the behavior, 243*6236dae4SAndroid Build Coastguard Workerthis option can set the initial seed. If not set, the random seed is set based 244*6236dae4SAndroid Build Coastguard Workeron the currently set local year and month and the first line of the "curl -V" 245*6236dae4SAndroid Build Coastguard Workeroutput. 246*6236dae4SAndroid Build Coastguard Worker 247*6236dae4SAndroid Build Coastguard Worker## `--shallow=[num]` 248*6236dae4SAndroid Build Coastguard Worker 249*6236dae4SAndroid Build Coastguard WorkerUsed together with **-t**. This limits the number of tests to fail in torture 250*6236dae4SAndroid Build Coastguard Workermode to no more than **num** per test case. If this reduces the amount, the 251*6236dae4SAndroid Build Coastguard Workerscript randomly discards entries to fail until the amount is **num**. 252*6236dae4SAndroid Build Coastguard Worker 253*6236dae4SAndroid Build Coastguard WorkerThe random seed initially set for this is fixed per month and can be set with 254*6236dae4SAndroid Build Coastguard Worker*--seed*. 255*6236dae4SAndroid Build Coastguard Worker 256*6236dae4SAndroid Build Coastguard Worker## `-t[num]` 257*6236dae4SAndroid Build Coastguard Worker 258*6236dae4SAndroid Build Coastguard WorkerSelects a **torture** test for the given tests. This makes runtests.pl first 259*6236dae4SAndroid Build Coastguard Workerrun the tests once and count the number of memory allocations made. It then 260*6236dae4SAndroid Build Coastguard Workerreruns the test that number of times, each time forcing one of the allocations 261*6236dae4SAndroid Build Coastguard Workerto fail until all allocations have been tested. By setting *num* you can force 262*6236dae4SAndroid Build Coastguard Workerthe allocation with that number to be set to fail at once instead of looping 263*6236dae4SAndroid Build Coastguard Workerthrough everyone, which is handy when debugging and then often in combination 264*6236dae4SAndroid Build Coastguard Workerwith *-g*. 265*6236dae4SAndroid Build Coastguard Worker 266*6236dae4SAndroid Build Coastguard Worker## `-u` 267*6236dae4SAndroid Build Coastguard Worker 268*6236dae4SAndroid Build Coastguard WorkerError instead of warning on server unexpectedly alive. 269*6236dae4SAndroid Build Coastguard Worker 270*6236dae4SAndroid Build Coastguard Worker## `-v` 271*6236dae4SAndroid Build Coastguard Worker 272*6236dae4SAndroid Build Coastguard WorkerEnable verbose output. Speaks more than by default. If used in conjunction 273*6236dae4SAndroid Build Coastguard Workerwith parallel testing, it is difficult to associate the logs with the specific 274*6236dae4SAndroid Build Coastguard Workertest being run. 275*6236dae4SAndroid Build Coastguard Worker 276*6236dae4SAndroid Build Coastguard Worker## `-vc \<curl\>` 277*6236dae4SAndroid Build Coastguard Worker 278*6236dae4SAndroid Build Coastguard WorkerProvide a path to a custom curl binary to run when verifying that the servers 279*6236dae4SAndroid Build Coastguard Workerrunning are indeed our test servers. Default is the curl executable in the 280*6236dae4SAndroid Build Coastguard Workerbuild tree. 281*6236dae4SAndroid Build Coastguard Worker 282*6236dae4SAndroid Build Coastguard Worker# RUNNING TESTS 283*6236dae4SAndroid Build Coastguard Worker 284*6236dae4SAndroid Build Coastguard WorkerMany tests have conditions that must be met before the test case can run fine. 285*6236dae4SAndroid Build Coastguard WorkerThey could depend on built-in features in libcurl or features present in the 286*6236dae4SAndroid Build Coastguard Workeroperating system or even in third-party libraries that curl may or may not 287*6236dae4SAndroid Build Coastguard Workeruse. 288*6236dae4SAndroid Build Coastguard Worker 289*6236dae4SAndroid Build Coastguard WorkerThe test script checks most of these by itself to determine when it is safe to 290*6236dae4SAndroid Build Coastguard Workerattempt to run each test. Those which cannot be run due to failed requirements 291*6236dae4SAndroid Build Coastguard Workerare simply skipped and listed at the completion of all test cases. In some 292*6236dae4SAndroid Build Coastguard Workerunusual configurations, the test script cannot make the correct determination 293*6236dae4SAndroid Build Coastguard Workerfor all tests. In these cases, the problematic tests can be skipped using the 294*6236dae4SAndroid Build Coastguard Worker"!keyword" skip feature documented earlier. 295*6236dae4SAndroid Build Coastguard Worker 296*6236dae4SAndroid Build Coastguard Worker# WRITING TESTS 297*6236dae4SAndroid Build Coastguard Worker 298*6236dae4SAndroid Build Coastguard WorkerThe simplest way to write test cases is to start with a similar existing test, 299*6236dae4SAndroid Build Coastguard Workersave it with a new number and then adjust it to fit. There is an attempt to 300*6236dae4SAndroid Build Coastguard Workerdocument the test case file format in **tests/FILEFORMAT.md**. 301