~ubuntu-branches/ubuntu/saucy/curl/saucy-security

« back to all changes in this revision

Viewing changes to tests/README

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-05-22 14:53:29 UTC
  • mfrom: (3.4.28 sid)
  • Revision ID: package-import@ubuntu.com-20120522145329-hbf1n3zr7qh08qab
Tags: 7.25.0-1ubuntu1
* Merge from Debian testing (LP: #1003049).  Remaining changes:
  - Drop dependencies not in main:
    + Build-Depends: Drop stunnel4 and libssh2-1-dev.
    + Drop libssh2-1-dev from libcurl4-openssl-dev's Depends.
  - Add new libcurl3-udeb package.
  - Add new curl-udeb package.
  - Also closes (LP: #855291)
* debian/patches/CVE-2012-0036.patch: Dropped. CVE resolved upstream.

Show diffs side-by-side

added added

removed removed

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