EXTRA_DIST = \
$(srcdir)/squidconf/* \
+ test-squid-conf.sh \
testheaders.sh
ESI_ALL_TESTS = \
VirtualDeleteOperator.cc \
stub_libmem.cc
-squid-conf-tests: $(top_builddir)/src/squid.conf.default $(srcdir)/squidconf/*
- @failed=0; cfglist="$?"; rm -f $@ || $(TRUE); \
+squid-conf-tests: $(srcdir)/test-squid-conf.sh $(top_builddir)/src/squid.conf.default $(srcdir)/squidconf/*
+ @failed=0; cfglist="$(top_builddir)/src/squid.conf.default $(srcdir)/squidconf/*.conf"; rm -f $@ || $(TRUE); \
for cfg in $$cfglist ; do \
- $(top_builddir)/src/squid -k parse -f $$cfg || \
+ $(srcdir)/test-squid-conf.sh $(top_builddir) $$cfg || \
{ echo "FAIL: squid.conf test: $$cfg" | \
sed s%$(top_builddir)/src/%% | \
sed s%$(srcdir)/squidconf/%% ; \
--- /dev/null
+#!/bin/sh
+#
+## Copyright (C) 1996-2022 The Squid Software Foundation and contributors
+##
+## Squid software is distributed under GPLv2+ license and includes
+## contributions from numerous individuals and organizations.
+## Please see the COPYING and CONTRIBUTORS files for details.
+##
+
+# Orchestrates a "squid -k parse ..." test of a single Squid configuration
+# file (with an optional .instructions file containing testing directions).
+# Usage: test-squid-conf.sh <top_builddir> <squid.conf>
+
+top_builddir=$1
+configFile=$2
+
+instructionsFile="$configFile.instructions"
+if test -e $instructionsFile
+then
+ lineNo=0
+ while read instructionName p1 p2
+ do
+ lineNo=$(($lineNo+1))
+ here="$instructionsFile:$lineNo";
+
+ if test -z "$instructionName"
+ then
+ continue; # skip empty lines
+ fi
+
+ if test "$instructionName" = "#"
+ then
+ continue; # skip comment lines
+ fi
+
+ if test "$instructionName" = "skip-unless-autoconf-defines"
+ then
+ # Skip test unless the given macro is #defined in autoconf.h
+ defineName=$p1
+
+ if test -n "$p2"
+ then
+ echo "$here: ERROR: Bad $instructionName instruction: Unexpected second parameter: $p2";
+ exit 1;
+ fi
+
+ autoconfHeader="$top_builddir/include/autoconf.h"
+ if ! grep -q -w "$defineName" $autoconfHeader
+ then
+ echo "$here: ERROR: Bad $instructionName instruction: Unknown macro $defineName";
+ exit 1;
+ fi
+
+ if grep -q "# *undef *\b$defineName\b" $autoconfHeader
+ then
+ echo "$here: WARNING: Skipping $configFile test because $defineName is not defined in $autoconfHeader";
+ exit 0;
+ fi
+
+ if ! grep -q "# *define *\b$defineName\b" $autoconfHeader
+ then
+ echo "$here: ERROR: Cannot determine status of $defineName macro";
+ exit 1;
+ fi
+ else
+ echo "$here: ERROR: Unknown test-squid-conf.sh instruction name: $instructionName";
+ exit 1;
+ fi
+ done < $instructionsFile
+
+ # TODO: Add support for the "require-failure" instruction.
+fi
+
+exec $top_builddir/src/squid -k parse -f $configFile