]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - test-suite/testheaders.sh
Renamed squid.h to squid-old.h and config.h to squid.h
[thirdparty/squid.git] / test-suite / testheaders.sh
index 6ab0bde5e6b37e68cf1679f626196794d5db2e1b..1036dcd3196b49c8097ef045bfbb016a85eea383 100755 (executable)
@@ -9,36 +9,36 @@
 # This script should be run from the makefile with the directory path and ccflags
 #
 cc="${1}"
+shift
+for dir in /usr/bin /usr/local/bin /usr/gnu/bin
+do
+       test -x ${dir}/true && TRUE=${dir}/true
+done
+TRUE=${TRUE:-/bin/true}
 
-if test "${2}" = ""; then
-       dir="."
-else
-       dir="${2}"
-fi
-
-for f in `cd ${dir} && ls -1 *.h 2>/dev/null`; do
-       echo -n "Testing ${dir}/${f} ..."
-       if [[ "${f}" == "cf_gen_defines.h" || "${f}" == "cf_parser.h" ]]; then
-               echo " IGNORED!"
-               continue
-       fi
-       if [ ${dir}/${f} -nt ./testHeaderDeps_${f/.h/}.o ]; then
-               (       echo "/* This file is AUTOMATICALLY GENERATED. DO NOT ALTER IT */"
-                       echo "#include \"${dir}/${f}\" "
-                       echo "int main( int argc, char* argv[] ) { return 0; } "
-               ) >./testHeaderDeps_${f/.h/}.cc
+exitCode=0
 
-               # run compile test on the new file.
-               # DEBUG: echo "TRY: ${cc} -o testHeaderDeps.o ./testHeaderDeps_${f/.h/}.cc"
-               ${cc} -o testHeaderDeps_${f/.h/}.o ./testHeaderDeps_${f/.h/}.cc
-               rm ./testHeaderDeps_${f/.h/}.cc
-       fi
-       if [ ! -f testHeaderDeps_${f/.h/}.o ]; then
-               rm testHeaders
-               exit 1
-       fi
-       echo "OK."
-       # unit-tests require an app to run.
-       # our most-recent object suits this purpose
-       cp ./testHeaderDeps_${f/.h/}.o ./testHeaders
+for f in $@; do
+       echo -n "Testing ${f} ..."
+    t="testhdr_`basename ${f}`"
+    if [ ! -f "$t.o" -o $f -nt "$t.o" ]; then
+        echo >$t.cc <<EOF
+/* This file is AUTOMATICALLY GENERATED. DO NOT ALTER IT */
+#include "squid.h"
+#include "${f}"
+int main( int argc, char* argv[] ) { return 0; }
+EOF
+        if ${cc} -c -o $t.o $t.cc ; then 
+            echo "Ok."
+        else
+            echo "Fail."
+            exitCode=1
+        fi
+        rm $t.cc $t.o
+    fi
+    test $exitCode -eq 0 || break
 done
+
+#who ever said that the test program needs to be meaningful?
+test $exitCode -eq 0 && cp ${TRUE} testHeaders
+exit $exitCode