Merge Debian 3.0.33-2 (UNRELEASED) changes.
[privoxy.git] / debian / tests / privoxy-regression-test
index 1c29fa0..e8fdd9d 100755 (executable)
@@ -3,7 +3,7 @@
 # Run privoxy-regression-test.pl on a configuration extended by
 # regression-tests.action.
 #
-# (c) 2018-2021 Roland Rosenfeld <roland@debian.org>
+# (c) 2018-2022 Roland Rosenfeld <roland@debian.org>
 
 PORT=8119
 
@@ -11,37 +11,57 @@ if [ -z "$AUTOPKGTEST_TMP" ]; then
     AUTOPKGTEST_TMP=$(mktemp -d)
 fi
 
-trap "rm -rf $AUTOPKGTEST_TMP" EXIT
+trap 'rm -rf "$AUTOPKGTEST_TMP"' EXIT
 
 CONFIG=$AUTOPKGTEST_TMP/config
 PIDFILE=$AUTOPKGTEST_TMP/privoxy.pid
 PRIVOXY=$AUTOPKGTEST_TMP/privoxy
 
+cp /usr/sbin/privoxy "$PRIVOXY"
+
+http_proxy=http://127.0.0.1:$PORT/
+export http_proxy
+
+OUTFILE=$AUTOPKGTEST_TMP/output
+
+
+echo "#### pass 1: some optiones disabled"
+
 sed -e "s/^listen-address.*/listen-address 127.0.0.1:$PORT/" \
     -e "s%^logdir.*%logdir $AUTOPKGTEST_TMP%" \
-    -e "s/^enable-edit-actions.*/enable-edit-actions 1/" \
     -e "s/^keep-alive-timeout.*/keep-alive-timeout 21/" \
-    -e "s/^#connection-sharing.*/connection-sharing 1/" \
-    < /usr/share/privoxy/config > $CONFIG
-echo "actionsfile regression-tests.action" >> $CONFIG
-
-cp /usr/sbin/privoxy $PRIVOXY
+    -e "s/^#connection-sharing.*/connection-sharing 0/" \
+    < /usr/share/privoxy/config > "$CONFIG"
+echo "actionsfile regression-tests.action" >> "$CONFIG"
 
 echo "Starting privoxy on port $PORT"
-$PRIVOXY --pidfile $PIDFILE $CONFIG
+$PRIVOXY --pidfile "$PIDFILE" "$CONFIG"
 
-http_proxy=http://127.0.0.1:$PORT/
-export http_proxy
+/usr/bin/privoxy-regression-test --max-level 200 --show-skipped-tests \
+    | tee "$OUTFILE" 2>&1
 
-OUTFILE=$AUTOPKGTEST_TMP/output
+
+echo "#### pass 2 with some more options enabled"
+
+sed -e "s/^listen-address.*/listen-address 127.0.0.1:$PORT/" \
+    -e "s%^logdir.*%logdir $AUTOPKGTEST_TMP%" \
+    -e "s/^enable-remote-toggle.*/enable-remote-toggle 1/" \
+    -e "s/^enable-edit-actions.*/enable-edit-actions 1/" \
+    -e "s/^enable-proxy-authentication-forwarding.*/enable-proxy-authentication-forwarding 1/" \
+    -e "s/^keep-alive-timeout.*/keep-alive-timeout 21/" \
+    -e "s/^#connection-sharing.*/connection-sharing 1/" \
+    < /usr/share/privoxy/config > "$CONFIG"
+echo "actionsfile regression-tests.action" >> "$CONFIG"
 
 /usr/bin/privoxy-regression-test --max-level 200 --show-skipped-tests \
-    | tee $OUTFILE 2>&1
+    | tee -a "$OUTFILE" 2>&1
+
 
 echo "Stopping privoxy on port $PORT"
-kill $(cat $PIDFILE)
+kill "$(cat "$PIDFILE")"
 
-if grep -q 'Executed.*, 0 failures.' $OUTFILE
+# Check that 2 passes have both 0 failures:
+if [ "$(grep -c 'Executed.*, 0 failures' "$OUTFILE")" = 2 ]
 then
     exit 0
 else