Merge Debian 3.0.33-2 (UNRELEASED) changes.
[privoxy.git] / debian / tests / privoxy-regression-test
1 #!/bin/sh
2 #
3 # Run privoxy-regression-test.pl on a configuration extended by
4 # regression-tests.action.
5 #
6 # (c) 2018-2022 Roland Rosenfeld <roland@debian.org>
7
8 PORT=8119
9
10 if [ -z "$AUTOPKGTEST_TMP" ]; then
11     AUTOPKGTEST_TMP=$(mktemp -d)
12 fi
13
14 trap 'rm -rf "$AUTOPKGTEST_TMP"' EXIT
15
16 CONFIG=$AUTOPKGTEST_TMP/config
17 PIDFILE=$AUTOPKGTEST_TMP/privoxy.pid
18 PRIVOXY=$AUTOPKGTEST_TMP/privoxy
19
20 cp /usr/sbin/privoxy "$PRIVOXY"
21
22 http_proxy=http://127.0.0.1:$PORT/
23 export http_proxy
24
25 OUTFILE=$AUTOPKGTEST_TMP/output
26
27
28 echo "#### pass 1: some optiones disabled"
29
30 sed -e "s/^listen-address.*/listen-address 127.0.0.1:$PORT/" \
31     -e "s%^logdir.*%logdir $AUTOPKGTEST_TMP%" \
32     -e "s/^keep-alive-timeout.*/keep-alive-timeout 21/" \
33     -e "s/^#connection-sharing.*/connection-sharing 0/" \
34     < /usr/share/privoxy/config > "$CONFIG"
35 echo "actionsfile regression-tests.action" >> "$CONFIG"
36
37 echo "Starting privoxy on port $PORT"
38 $PRIVOXY --pidfile "$PIDFILE" "$CONFIG"
39
40 /usr/bin/privoxy-regression-test --max-level 200 --show-skipped-tests \
41     | tee "$OUTFILE" 2>&1
42
43
44 echo "#### pass 2 with some more options enabled"
45
46 sed -e "s/^listen-address.*/listen-address 127.0.0.1:$PORT/" \
47     -e "s%^logdir.*%logdir $AUTOPKGTEST_TMP%" \
48     -e "s/^enable-remote-toggle.*/enable-remote-toggle 1/" \
49     -e "s/^enable-edit-actions.*/enable-edit-actions 1/" \
50     -e "s/^enable-proxy-authentication-forwarding.*/enable-proxy-authentication-forwarding 1/" \
51     -e "s/^keep-alive-timeout.*/keep-alive-timeout 21/" \
52     -e "s/^#connection-sharing.*/connection-sharing 1/" \
53     < /usr/share/privoxy/config > "$CONFIG"
54 echo "actionsfile regression-tests.action" >> "$CONFIG"
55
56 /usr/bin/privoxy-regression-test --max-level 200 --show-skipped-tests \
57     | tee -a "$OUTFILE" 2>&1
58
59
60 echo "Stopping privoxy on port $PORT"
61 kill "$(cat "$PIDFILE")"
62
63 # Check that 2 passes have both 0 failures:
64 if [ "$(grep -c 'Executed.*, 0 failures' "$OUTFILE")" = 2 ]
65 then
66     exit 0
67 else
68     exit 1
69 fi
70