8d5ce3dc346480e574a924b6db732fddbf07b025
[privoxy.git] / doc / webserver / developer-manual / testing.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
3 <html>
4 <head>
5   <title>Testing Guidelines</title>
6   <meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.79">
7   <link rel="HOME" title="Privoxy Developer Manual" href="index.html">
8   <link rel="PREVIOUS" title="Coding Guidelines" href="coding.html">
9   <link rel="NEXT" title="Releasing a New Version" href="newrelease.html">
10   <link rel="STYLESHEET" type="text/css" href="../p_doc.css">
11   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
12 </head>
13 <body class="SECT1" bgcolor="#EEEEEE" text="#000000" link="#0000FF" vlink="#840084" alink="#0000FF">
14   <div class="NAVHEADER">
15     <table summary="Header navigation table" width="100%" border="0" cellpadding="0" cellspacing="0">
16       <tr>
17         <th colspan="3" align="center">Privoxy Developer Manual</th>
18       </tr>
19       <tr>
20         <td width="10%" align="left" valign="bottom"><a href="coding.html" accesskey="P">Prev</a></td>
21         <td width="80%" align="center" valign="bottom"></td>
22         <td width="10%" align="right" valign="bottom"><a href="newrelease.html" accesskey="N">Next</a></td>
23       </tr>
24     </table>
25     <hr align="left" width="100%">
26   </div>
27   <div class="SECT1">
28     <h1 class="SECT1"><a name="TESTING" id="TESTING">5. Testing Guidelines</a></h1>
29     <p>To be filled.</p>
30     <div class="SECT2">
31       <h2 class="SECT2"><a name="TESTING-PLAN" id="TESTING-PLAN">5.1. Testplan for releases</a></h2>
32       <p>Explain release numbers. major, minor. developer releases. etc.</p>
33       <ol type="1">
34         <li>
35           <p>Remove any existing rpm with rpm -e</p>
36         </li>
37         <li>
38           <p>Remove any file that was left over. This includes (but is not limited to)</p>
39           <ul>
40             <li>
41               <p>/var/log/privoxy</p>
42             </li>
43             <li>
44               <p>/etc/privoxy</p>
45             </li>
46             <li>
47               <p>/usr/sbin/privoxy</p>
48             </li>
49             <li>
50               <p>/etc/init.d/privoxy</p>
51             </li>
52             <li>
53               <p>/usr/doc/privoxy*</p>
54             </li>
55           </ul>
56         </li>
57         <li>
58           <p>Install the rpm. Any error messages?</p>
59         </li>
60         <li>
61           <p>start,stop,status <span class="APPLICATION">Privoxy</span> with the specific script (e.g.
62           /etc/rc.d/init/privoxy stop). Reboot your machine. Does autostart work?</p>
63         </li>
64         <li>
65           <p>Start browsing. Does <span class="APPLICATION">Privoxy</span> work? Logfile written?</p>
66         </li>
67         <li>
68           <p>Remove the rpm. Any error messages? All files removed?</p>
69         </li>
70       </ol>
71     </div>
72     <div class="SECT2">
73       <h2 class="SECT2"><a name="PRIVOXY-REGRESSION-TEST" id="PRIVOXY-REGRESSION-TEST">5.2. Testing with <span class=
74       "APPLICATION">Privoxy-Regression-Test</span></a></h2>
75       <p>If you compiled, packaged or merely installed Privoxy, it is recommended to run <span class=
76       "APPLICATION">Privoxy-Regression-Test</span> to verify that at least the tested parts of <span class=
77       "APPLICATION">Privoxy</span> are working as expected.</p>
78       <p>This is actually pretty easy. For details, please see <b class="COMMAND">perldoc
79       privoxy-regression-test.pl</b>.</p>
80       <p>Here is an example of what <span class="APPLICATION">Privoxy-Regression-Test</span> can do for you:</p>
81       <table border="0" bgcolor="#E0E0E0" width="100%">
82         <tr>
83           <td>
84             <pre class="PROGRAMLISTING">  # Run all the tests
85   fk@t520 ~ $privoxy-regression-test.pl
86   2020-12-14 12:16:32: Asking Privoxy for the number of action files available ...
87   2020-12-14 12:16:32: Gathering regression tests from 9 action file(s) delivered by Privoxy 3.0.30.
88   2020-12-14 12:16:32: Executing regression tests ...
89   2020-12-14 12:16:41: Ooops. Expected removal but: 'Referer: https://p.p/' is still there.
90   2020-12-14 12:16:41: Failure for test 785. Header 'Referer: https://p.p/' and tag 'hide-referrer{conditional-block}'
91   2020-12-14 12:16:41: Ooops. Got: 'Referer: https://p.p/' while expecting: 'Referer: http://p.p/'
92   2020-12-14 12:16:41: Failure for test 791. Header 'Referer: https://p.p/' and tag 'hide-referrer{conditional-forge}'
93   2020-12-14 12:16:44: Executed 1087 regression tests. Skipped 115. 1085 successes, 2 failures.
94   # Repeat one of the failing tests and get a curl command to quickly reproduce the problem
95   # without causing too much log noise.
96   fk@t520 ~ $privoxy-regression-test.pl --test-number 785 --verbose --debug 4
97   2020-12-14 12:17:55: Asking Privoxy for the number of action files available ...
98   [...]
99   2020-12-14 12:17:56: Executing regression tests ...
100   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
101   2020-12-14 12:17:56: Ooops. Expected removal but: 'Referer: https://p.p/' is still there.
102   2020-12-14 12:17:56: Failure for test 785 (0/13/5). Header 'Referer: https://p.p/' and tag 'hide-referrer{conditional-block}'
103   2020-12-14 12:17:56: Executed 1 regression tests. Skipped 1201. 0 successes, 1 failures.</pre>
104           </td>
105         </tr>
106       </table>
107       <p>Use the if the <b class="COMMAND">--privoxy-address</b> option if the http_proxy environment variable isn't
108       configured and you don't want to use the default (http://127.0.0.1:8118/).</p>
109     </div>
110     <div class="SECT2">
111       <h2 class="SECT2"><a name="FUZZING" id="FUZZING">5.3. Fuzzing Privoxy</a></h2>
112       <p>To make fuzzing more convenient, Privoxy can be configured with --enable-fuzz which will result in the --fuzz
113       option becoming available.</p>
114       <p>Example (tested on ElectroBSD):</p>
115       <table border="0" bgcolor="#E0E0E0" width="100%">
116         <tr>
117           <td>
118             <pre class="PROGRAMLISTING">  # Compile Privoxy with instrumentation for afl
119   $ export CC=afl-clang
120   $ export CFLAGS="-fsanitize=address -ggdb"
121   $ export CPPFLAGS=-I/usr/local/include/
122   $ export LDFLAGS="-fsanitize=address -L/usr/local/lib"
123   $ export AFL_USE_ASAN=1
124   $ export AFL_HARDEN=1
125   $ ./configure --with-debug --enable-extended-host-patterns --enable-accept-filter --enable-no-gifs --enable-compression --enable-strptime-sanity-checks --enable-external-filters --enable-fuzz
126
127   $ ./privoxy --fuzz
128   Privoxy version 3.0.24 (http://www.privoxy.org/)
129   Usage: ./privoxy [--config-test] [--chroot] [--help] [--no-daemon] [--pidfile pidfile] [--pre-chroot-nslookup hostname] [--user user[.group]] [--version] [configfile]
130          ./privoxy --fuzz fuzz-mode ./path/to/fuzzed/input [--stfu]
131
132   Supported fuzz modes and the expected input:
133    action: Text to parse as action file.
134    client-request: Client request to parse. Currently incomplete
135    client-header: Client header to parse.
136    chunked-transfer-encoding: Chunk-encoded data to dechunk.
137    deflate: deflate-compressed data to decompress.
138    filter: Text to parse as filter file.
139    gif: gif to deanimate.
140    gzip: gzip-compressed data to decompress.
141    pcrs-substitute: A pcrs-substitute to compile. Not a whole pcrs job! Example: Bla $1 bla C $3 blah.
142    server-header: Server header to parse.
143    server-response: Server response to parse.
144
145   The following fuzz modes read data from stdin if the 'file' is '-'
146    client-request
147    client-header
148    chunked-transfer-encoding
149    deflate
150    gif
151    gzip
152    pcrs-substitute
153    server-header
154    server-response
155
156   Aborting
157
158   $ export ASAN_OPTIONS='abort_on_error=1'
159   $ mkdir input output
160   $ echo '$1 bla fasel $2' &#62; input/pcrs
161   $ afl-fuzz -i input -o output -m none ~/git/privoxy/privoxy --fuzz pcrs-substitute - --stfu
162
163   $ cat &#62;input/pcrs.txt
164   FILTER: bla fasel
165   s@(.{1})[432](\d+)@$1$2$hostname@UgisT
166
167   $ afl-fuzz -i input/ -o output/ -f bla.filter -m none privoxy --fuzz filter bla.filter --stfu</pre>
168           </td>
169         </tr>
170       </table>
171     </div>
172   </div>
173   <div class="NAVFOOTER">
174     <hr align="left" width="100%">
175     <table summary="Footer navigation table" width="100%" border="0" cellpadding="0" cellspacing="0">
176       <tr>
177         <td width="33%" align="left" valign="top"><a href="coding.html" accesskey="P">Prev</a></td>
178         <td width="34%" align="center" valign="top"><a href="index.html" accesskey="H">Home</a></td>
179         <td width="33%" align="right" valign="top"><a href="newrelease.html" accesskey="N">Next</a></td>
180       </tr>
181       <tr>
182         <td width="33%" align="left" valign="top">Coding Guidelines</td>
183         <td width="34%" align="center" valign="top">&nbsp;</td>
184         <td width="33%" align="right" valign="top">Releasing a New Version</td>
185       </tr>
186     </table>
187   </div>
188 </body>
189 </html>