Debian Codegraph @

doc/howto/Testing.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>ProFTPD: Testsuite</title>
5 </head>
6
7 <body bgcolor=white>
8
9 <hr>
10 <center><h2><b>ProFTPD: Testsuite</b></h2></center>
11 <hr>
12
13 <p>
14 The proftpd source code is accompanied by a testsuite, for testing various
15 features and functionality. At present, the testsuite is divided into two
16 main parts: the API-level tests, and the integration tests. The API tests
17 are written in C, and exercise the various APIs that proftpd provides to
18 module developers. The integration tests are currently written in Perl, and
19 seek to check a compiled <code>proftpd</code>'s run-time behavior.
20
21 <p>
22 In order to run the testsuite, you must configure your proftpd build so that
23 the testsuite is prepared. You do this by using the <code>--enable-tests</code>
24 configure option, along with your other build options, <i>e.g.</i>:
25 <pre>
26 $ ./configure --enable-tests ...
27 </pre>
28
29 <p>
30 <b>API Tests</b><br>
31 The API tests use the <code>libcheck</code> library; see:
32 <pre>
33 <a href="http://check.sourceforge.net/">http://check.sourceforge.net/</a>
34 </pre>
35 This library must be installed on your machine in order to run the API tests.
36 When the <code>--enable-tests</code> configure option is used, proftpd's
37 configure script will check for libcheck, and will fail unless the library
38 is present. If no <code>libcheck</code> is found and you've used
39 <code>--enable-tests</code>, you will see:
40 <pre>
41 checking for tcase_create in -lcheck... no
42 configure: error: libcheck support, required for tests, not present -- aborting
43 </pre>
44 Note that, if necessary, the <code>--with-includes</code> and
45 <code>--with-libraries</code> configure options can be used to specify the
46 locations of the <code>libcheck</code> headers and libraries.
47
48 <p>
49 To run the testsuite, use the <code>make check</code> target:
50 <pre>
51 $ ./configure --enable-tests ...
52 $ make
53 ...
54 $ make check
55 ...
56 $ ./api-tests
57 Running suite(s): pool
58 array
59 str
60 sets
61 timers
62 table
63 var
64 event
65 env
66 version
67 feat
68 netaddr
69 netacl
70 class
71 regexp
72 expr
73 scoreboard
74 modules
75 100%: Checks: 140, Failures: 0, Errors: 0
76 </pre>
77 The <code>make check</code> will also go on to run the integration tests,
78 if the API tests all pass.
79
80 <p>
81 If one of the API tests fails, you will see an error message like:
82 <pre>
83 99%: Checks: 140, Failures: 1, Errors: 0
84 api/env.c:53:F:base:env_get_test:0: Failed to handle null arguments
85 -------------------------------------------------
86 FAILED 1 test
87
88 Please send email to:
89
90 [email protected]
91
92 containing the `api-tests.log' file (in the tests/ directory)
93 and the output from running `proftpd -V'
94 -------------------------------------------------
95 </pre>
96 Please do follow those instructions; you will be helping in proftpd
97 development!
98
99 <p>
100 <b>Expected Failures</b><br>
101 Unfortunately, due to variations in system configurations, it's possible
102 that some of the API tests will fail, without it necessarily being an
103 indication of a regression or problem.
104
105 <p>
106 Most notably, some of the most brittle tests make assumptions about the
107 host's <code>/etc/hosts</code> file, particularly the list of names
108 associated with the address <code>127.0.0.1</code>. If the
109 <code>/etc/hosts</code> file has a name other than "localhost" or
110 "localhost.localdomain" immediately after the 127.0.0.1 address, <i>e.g.</i>:
111 <pre>
112 127.0.0.1 some.other.name localhost
113 </pre>
114 Then the API tests may fail with errors like this:
115 <pre>
116 98%: Checks: 152, Failures: 2, Errors: 0
117 api/netaddr.c:344:F:base:netaddr_get_dnsstr_test:0: Expected 'localhost or localhost.localdomain', got '<i>some.other.name</i>'
118 api/netacl.c:535:F:base:netacl_match_test:0: Failed to positively match ACL to addr: No such file or directory
119 </pre>
120 If this is the case, it is an <i>expected failure</i>; please do not report
121 the issue as a bug. (Unfortunately, I have not been able to think of a good
122 solution/workaround for these situations other than ignoring the test failure,
123 but I would rather not do that if possible.)
124
125 <p>
126 <b>Integration Tests</b><br>
127 The current integration tests are written in Perl, and rely on the
128 <code>Test-Unit</code> Perl package. Specifically, you <b>must</b> use
129 <code>Test-Unit-0.14</code>, <b>not</b> <code>Test-Unit-0.25</code>. Not sure
130 which version of <code>Test-Unit</code> you have, if at all? Run the following
131 command:
132 <pre>
133 $ perl -MTest::Unit -e 'print $Test::Unit::VERSION, "\n";'
134 0.14
135 </pre>
136
137 <p>
138 To run the integration tests manually, use the <code>tests.pl</code> script:
139 <pre>
140 $ cd tests/
141 $ perl tests.pl
142 t/logins.....................ok
143 t/commands/user..............ok
144 t/commands/pass..............ok
145 t/commands/pwd...............ok
146 t/commands/cwd...............ok
147 t/commands/cdup..............ok
148 t/commands/syst..............ok
149 t/commands/type..............ok
150 t/commands/mkd...............ok
151 t/commands/rmd...............ok
152 t/commands/dele..............ok
153 t/commands/mdtm..............ok
154 t/commands/size..............ok
155 t/commands/mode..............ok
156 t/commands/stru..............ok
157 t/commands/allo..............ok
158 t/commands/noop..............ok
159 t/commands/feat..............ok
160 t/commands/help..............ok
161 t/commands/quit..............ok
162 t/commands/rnfr..............ok
163 t/commands/rnto..............ok
164 t/commands/rest..............ok
165 t/commands/pasv..............ok
166 t/commands/epsv..............ok
167 t/commands/port..............ok
168 t/commands/eprt..............ok
169 t/commands/nlst..............ok
170 t/commands/list..............ok
171 t/commands/retr..............ok
172 t/commands/stor..............ok
173 t/commands/appe..............ok
174 t/config/displayconnect......ok
175 t/config/displaylogin........ok
176 t/config/maxloginattempts....ok
177 t/config/serverident.........ok
178 All tests successful.
179 Files=37, Tests=141, 160 wallclock secs ( 4.33 cusr + 4.74 csys = 9.07 CPU)
180 </pre>
181
182 <p>
183 Some of the integration require root privileges in order to perform the
184 test properly, <i>e.g.</i> for
185 <code>&lt;Anonymous&gt;</code>/<code>DefaultRoot</code> logins, <i>etc</i>.
186 If you do <i>not</i> run `make check' as root, those tests which require
187 root privileges are automatically skipped. Thus for doing a full regression,
188 run the integration tests as the root user.
189
190 <p>
191 <b>Adding New Tests</b><br>
192 The following information is for those who are interested in adding new
193 tests, updating existing tests, or otherwise helping with the testsuite
194 development.
195
196 <p>
197 The API tests driver, <code>api-tests</code>, honors the
198 <code>PR_TEST_SUITE</code> environment variable. This is useful for running
199 just the test cases associated with a particular suite, such as <i>env</i> or
200 <i>pool</i>. Only <b>one</b> suite can be specified using the
201 <code>PR_TEST_SUITE</code> environment variable:
202 <pre>
203 $ make check
204 $ cd tests/
205 $ PR_TEST_SUITE=pool ./api-tests
206 Running suite(s): pool
207 100%: Checks: 5, Failures: 0, Errors: 0
208 </pre>
209 This way, when you are adding to an existing test case or adding a new test
210 case to an existing suite, you need not run the entire API testsuite in order
211 to run your changes.
212
213 <p><a name="FAQ">
214 <b>Frequently Asked Questions</b><br>
215 <p>
216 <font color=red>Question</font>: I have installed the <code>check</code>
217 library, and I am using the <code>--enable-tests</code> configure option, but
218 the configure command fails with:
219 <pre>
220 checking check.h usability... yes
221 checking check.h presence... yes
222 checking for check.h... yes
223 checking for tcase_create in -lcheck... no
224 configure: error: libcheck support, required for tests, not present -- aborting
225 </pre>
226 What am I missing?<br>
227 <p>
228 <font color=blue>Answer</font>: To properly answer this, we would need to look
229 in the log file generated by the configure script, <i>i.e.</i> the
230 <code>config.log</code> file.
231
232 I suspect that looking in that <code>config.log</code> file, you would see
233 something like this:
234 <pre>
235 configure:20568: checking for tcase_create in -lcheck
236 configure:20603: gcc -o conftest -g2 -g -O2 -fdebug-prefix-map=/home/hille/devel/proftp/pftp_build/proftpd-dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -Wall -fno-omit-frame-pointer -Werror=implicit-function-declaration -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include/mysql -I/usr/include/postgresql -L$(top_srcdir)/lib -Wl,-z,relro -rdynamic conftest.c -lcheck -ldl >&amp;5
237 /usr/lib/gcc/i686-linux-gnu/7/../../../i386-linux-gnu/libcheck.a(check.o): In function `tcase_create':
238 (.text+0x1ce): undefined reference to `floor'
239 /usr/lib/gcc/i686-linux-gnu/7/../../../i386-linux-gnu/libcheck.a(check.o): In function `tcase_set_timeout':
240 (.text+0x513): undefined reference to `floor'
241 /usr/lib/gcc/i686-linux-gnu/7/../../../i386-linux-gnu/libcheck.a(check.o): In function `check_get_clockid':
242 (.text+0xc1d): undefined reference to `timer_create'
243 (.text+0xc48): undefined reference to `timer_delete'
244 /usr/lib/gcc/i686-linux-gnu/7/../../../i386-linux-gnu/libcheck.a(check_pack.o): In function `ppack':
245 (.text+0x5b1): undefined reference to `__pthread_register_cancel'
246 (.text+0x5fc): undefined reference to `__pthread_unregister_cancel'
247 collect2: error: ld returned 1 exit status
248 </pre>
249
250 Newer versions of the <code>check</code> library have dependencies on other
251 libraries, which need to be declared explicitly. Thus to address these
252 dependency linker errors, you would need to re-run your configure command and
253 provide those linker dependencies:
254 <pre>
255 $ make clean
256 $ ./configure LIBS="-lm -lrt -pthread" ...
257 </pre>
258 <i>Note</i> that even after doing the above, you <i>still</i> may have the
259 configure command fail to detect the <code>check</code> library. There are
260 reports that using <code>check</code> 0.10.0 and later <i>also</i> require the
261 <code>subunit</code> library, and thus you may need to use:
262 <pre>
263 $ make clean
264 $ ./configure LIBS="-lsubunit -lm -lrt -pthread" ...
265 </pre>
266
267 <p>
268 <hr>
269 <font size=2><b><i>
270 &copy; Copyright 2017-2018 The ProFTPD Project<br>
271 All Rights Reserved<br>
272 </i></b></font>
273 <hr>
274
275 </body>
276 </html>