Update developer manual with new macOS packaging instructions
[privoxy.git] / doc / webserver / developer-manual / testing.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <HTML
3 ><HEAD
4 ><TITLE
5 >Testing Guidelines</TITLE
6 ><META
7 NAME="GENERATOR"
8 CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
9 REL="HOME"
10 TITLE="Privoxy Developer Manual"
11 HREF="index.html"><LINK
12 REL="PREVIOUS"
13 TITLE="Coding Guidelines"
14 HREF="coding.html"><LINK
15 REL="NEXT"
16 TITLE="Releasing a New Version"
17 HREF="newrelease.html"><LINK
18 REL="STYLESHEET"
19 TYPE="text/css"
20 HREF="../p_doc.css"><META
21 HTTP-EQUIV="Content-Type"
22 CONTENT="text/html;
23 charset=ISO-8859-1"></HEAD
24 ><BODY
25 CLASS="SECT1"
26 BGCOLOR="#EEEEEE"
27 TEXT="#000000"
28 LINK="#0000FF"
29 VLINK="#840084"
30 ALINK="#0000FF"
31 ><DIV
32 CLASS="NAVHEADER"
33 ><TABLE
34 SUMMARY="Header navigation table"
35 WIDTH="100%"
36 BORDER="0"
37 CELLPADDING="0"
38 CELLSPACING="0"
39 ><TR
40 ><TH
41 COLSPAN="3"
42 ALIGN="center"
43 >Privoxy Developer Manual</TH
44 ></TR
45 ><TR
46 ><TD
47 WIDTH="10%"
48 ALIGN="left"
49 VALIGN="bottom"
50 ><A
51 HREF="coding.html"
52 ACCESSKEY="P"
53 >Prev</A
54 ></TD
55 ><TD
56 WIDTH="80%"
57 ALIGN="center"
58 VALIGN="bottom"
59 ></TD
60 ><TD
61 WIDTH="10%"
62 ALIGN="right"
63 VALIGN="bottom"
64 ><A
65 HREF="newrelease.html"
66 ACCESSKEY="N"
67 >Next</A
68 ></TD
69 ></TR
70 ></TABLE
71 ><HR
72 ALIGN="LEFT"
73 WIDTH="100%"></DIV
74 ><DIV
75 CLASS="SECT1"
76 ><H1
77 CLASS="SECT1"
78 ><A
79 NAME="TESTING"
80 >5. Testing Guidelines</A
81 ></H1
82 ><P
83 >To be filled.</P
84 ><DIV
85 CLASS="SECT2"
86 ><H2
87 CLASS="SECT2"
88 ><A
89 NAME="TESTING-PLAN"
90 >5.1. Testplan for releases</A
91 ></H2
92 ><P
93 >       Explain release numbers. major, minor. developer releases. etc.
94       </P
95 ><P
96 ></P
97 ><OL
98 TYPE="1"
99 ><LI
100 ><P
101 >Remove any existing rpm with rpm -e</P
102 ></LI
103 ><LI
104 ><P
105 >Remove any file that was left over. This includes (but is not limited to)
106           </P
107 ><P
108 ></P
109 ><UL
110 ><LI
111 ><P
112 >/var/log/privoxy</P
113 ></LI
114 ><LI
115 ><P
116 >/etc/privoxy</P
117 ></LI
118 ><LI
119 ><P
120 >/usr/sbin/privoxy</P
121 ></LI
122 ><LI
123 ><P
124 >/etc/init.d/privoxy</P
125 ></LI
126 ><LI
127 ><P
128 >/usr/doc/privoxy*</P
129 ></LI
130 ></UL
131 ></LI
132 ><LI
133 ><P
134 >Install the rpm. Any error messages?</P
135 ></LI
136 ><LI
137 ><P
138 >start,stop,status <SPAN
139 CLASS="APPLICATION"
140 >Privoxy</SPAN
141 > with the specific script
142       (e.g. /etc/rc.d/init/privoxy stop). Reboot your machine. Does
143       autostart work?</P
144 ></LI
145 ><LI
146 ><P
147 >Start browsing. Does <SPAN
148 CLASS="APPLICATION"
149 >Privoxy</SPAN
150 > work? Logfile written?</P
151 ></LI
152 ><LI
153 ><P
154 >Remove the rpm. Any error messages? All files removed?</P
155 ></LI
156 ></OL
157 ></DIV
158 ><DIV
159 CLASS="SECT2"
160 ><H2
161 CLASS="SECT2"
162 ><A
163 NAME="PRIVOXY-REGRESSION-TEST"
164 >5.2. Testing with <SPAN
165 CLASS="APPLICATION"
166 >Privoxy-Regression-Test</SPAN
167 ></A
168 ></H2
169 ><P
170 >       If you compiled, packaged or merely installed Privoxy, it is recommended to run
171        <SPAN
172 CLASS="APPLICATION"
173 >Privoxy-Regression-Test</SPAN
174 > to verify that at least
175        the tested parts of <SPAN
176 CLASS="APPLICATION"
177 >Privoxy</SPAN
178 > are working as expected.
179      </P
180 ><P
181 >       This is actually pretty easy. For details, please see
182        <B
183 CLASS="COMMAND"
184 >perldoc privoxy-regression-test.pl</B
185 >.
186      </P
187 ><P
188 >      Here is an example of what <SPAN
189 CLASS="APPLICATION"
190 >Privoxy-Regression-Test</SPAN
191 > can do for you:
192      </P
193 ><TABLE
194 BORDER="0"
195 BGCOLOR="#E0E0E0"
196 WIDTH="100%"
197 ><TR
198 ><TD
199 ><PRE
200 CLASS="PROGRAMLISTING"
201 >  # Run all the tests
202   fk@t520 ~ $privoxy-regression-test.pl
203   2020-12-14 12:16:32: Asking Privoxy for the number of action files available ...
204   2020-12-14 12:16:32: Gathering regression tests from 9 action file(s) delivered by Privoxy 3.0.30.
205   2020-12-14 12:16:32: Executing regression tests ...
206   2020-12-14 12:16:41: Ooops. Expected removal but: 'Referer: https://p.p/' is still there.
207   2020-12-14 12:16:41: Failure for test 785. Header 'Referer: https://p.p/' and tag 'hide-referrer{conditional-block}'
208   2020-12-14 12:16:41: Ooops. Got: 'Referer: https://p.p/' while expecting: 'Referer: http://p.p/'
209   2020-12-14 12:16:41: Failure for test 791. Header 'Referer: https://p.p/' and tag 'hide-referrer{conditional-forge}'
210   2020-12-14 12:16:44: Executed 1087 regression tests. Skipped 115. 1085 successes, 2 failures.
211   # Repeat one of the failing tests and get a curl command to quickly reproduce the problem
212   # without causing too much log noise.
213   fk@t520 ~ $privoxy-regression-test.pl --test-number 785 --verbose --debug 4
214   2020-12-14 12:17:55: Asking Privoxy for the number of action files available ...
215   [...]
216   2020-12-14 12:17:56: Executing regression tests ...
217   2020-12-14 12:17:56: Executing: curl --include  -H 'Proxy-Connection:'  -H 'Connection: close'  -s  -S  --user-agent 'Privoxy-Regression-Test 0.7.2'  --max-time '5'  --globoff  -H 'X-Privoxy-Control: hide-referrer{conditional-block}' -H 'Referer: https://p.p/'  http://p.p/show-request 2&#62;&#38;1
218   2020-12-14 12:17:56: Ooops. Expected removal but: 'Referer: https://p.p/' is still there.
219   2020-12-14 12:17:56: Failure for test 785 (0/13/5). Header 'Referer: https://p.p/' and tag 'hide-referrer{conditional-block}'
220   2020-12-14 12:17:56: Executed 1 regression tests. Skipped 1201. 0 successes, 1 failures.</PRE
221 ></TD
222 ></TR
223 ></TABLE
224 ><P
225 >      Use the if the <B
226 CLASS="COMMAND"
227 >--privoxy-address</B
228 > option if the
229       http_proxy environment variable isn't configured and you don't want
230       to use the default (http://127.0.0.1:8118/).
231      </P
232 ></DIV
233 ><DIV
234 CLASS="SECT2"
235 ><H2
236 CLASS="SECT2"
237 ><A
238 NAME="FUZZING"
239 >5.3. Fuzzing Privoxy</A
240 ></H2
241 ><P
242 >       To make fuzzing more convenient, Privoxy can be configured
243        with --enable-fuzz which will result in the --fuzz option
244        becoming available.
245      </P
246 ><P
247 >      Example (tested on ElectroBSD):
248      </P
249 ><TABLE
250 BORDER="0"
251 BGCOLOR="#E0E0E0"
252 WIDTH="100%"
253 ><TR
254 ><TD
255 ><PRE
256 CLASS="PROGRAMLISTING"
257 >  # Compile Privoxy with instrumentation for afl
258   $ export CC=afl-clang
259   $ export CFLAGS="-fsanitize=address -ggdb"
260   $ export CPPFLAGS=-I/usr/local/include/
261   $ export LDFLAGS="-fsanitize=address -L/usr/local/lib"
262   $ export AFL_USE_ASAN=1
263   $ export AFL_HARDEN=1
264   $ ./configure --with-debug --enable-extended-host-patterns --enable-accept-filter --enable-no-gifs --enable-compression --enable-strptime-sanity-checks --enable-external-filters --enable-fuzz
265
266   $ ./privoxy --fuzz
267   Privoxy version 3.0.24 (http://www.privoxy.org/)
268   Usage: ./privoxy [--config-test] [--chroot] [--help] [--no-daemon] [--pidfile pidfile] [--pre-chroot-nslookup hostname] [--user user[.group]] [--version] [configfile]
269          ./privoxy --fuzz fuzz-mode ./path/to/fuzzed/input [--stfu]
270
271   Supported fuzz modes and the expected input:
272    action: Text to parse as action file.
273    client-request: Client request to parse. Currently incomplete
274    client-header: Client header to parse.
275    chunked-transfer-encoding: Chunk-encoded data to dechunk.
276    deflate: deflate-compressed data to decompress.
277    filter: Text to parse as filter file.
278    gif: gif to deanimate.
279    gzip: gzip-compressed data to decompress.
280    pcrs-substitute: A pcrs-substitute to compile. Not a whole pcrs job! Example: Bla $1 bla C $3 blah.
281    server-header: Server header to parse.
282    server-response: Server response to parse.
283
284   The following fuzz modes read data from stdin if the 'file' is '-'
285    client-request
286    client-header
287    chunked-transfer-encoding
288    deflate
289    gif
290    gzip
291    pcrs-substitute
292    server-header
293    server-response
294
295   Aborting
296
297   $ export ASAN_OPTIONS='abort_on_error=1'
298   $ mkdir input output
299   $ echo '$1 bla fasel $2' &#62; input/pcrs
300   $ afl-fuzz -i input -o output -m none ~/git/privoxy/privoxy --fuzz pcrs-substitute - --stfu
301
302   $ cat &#62;input/pcrs.txt
303   FILTER: bla fasel
304   s@(.{1})[432](\d+)@$1$2$hostname@UgisT
305
306   $ afl-fuzz -i input/ -o output/ -f bla.filter -m none privoxy --fuzz filter bla.filter --stfu</PRE
307 ></TD
308 ></TR
309 ></TABLE
310 ></DIV
311 ></DIV
312 ><DIV
313 CLASS="NAVFOOTER"
314 ><HR
315 ALIGN="LEFT"
316 WIDTH="100%"><TABLE
317 SUMMARY="Footer navigation table"
318 WIDTH="100%"
319 BORDER="0"
320 CELLPADDING="0"
321 CELLSPACING="0"
322 ><TR
323 ><TD
324 WIDTH="33%"
325 ALIGN="left"
326 VALIGN="top"
327 ><A
328 HREF="coding.html"
329 ACCESSKEY="P"
330 >Prev</A
331 ></TD
332 ><TD
333 WIDTH="34%"
334 ALIGN="center"
335 VALIGN="top"
336 ><A
337 HREF="index.html"
338 ACCESSKEY="H"
339 >Home</A
340 ></TD
341 ><TD
342 WIDTH="33%"
343 ALIGN="right"
344 VALIGN="top"
345 ><A
346 HREF="newrelease.html"
347 ACCESSKEY="N"
348 >Next</A
349 ></TD
350 ></TR
351 ><TR
352 ><TD
353 WIDTH="33%"
354 ALIGN="left"
355 VALIGN="top"
356 >Coding Guidelines</TD
357 ><TD
358 WIDTH="34%"
359 ALIGN="center"
360 VALIGN="top"
361 >&nbsp;</TD
362 ><TD
363 WIDTH="33%"
364 ALIGN="right"
365 VALIGN="top"
366 >Releasing a New Version</TD
367 ></TR
368 ></TABLE
369 ></DIV
370 ></BODY
371 ></HTML
372 >