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