]> git.ipfire.org Git - thirdparty/squid.git/blob - test-suite/testheaders.sh
Do not stop on the first error to be compatible with "make -k check".
[thirdparty/squid.git] / test-suite / testheaders.sh
1 #!/bin/sh
2 #
3 # test all header files (.h) for dependancy issues.
4 #
5 # Ideally this test should be performed twice before any code is accepted.
6 # With or without inline enabled. This is needed because the .cci files
7 # are only included into the .h files when inline mode is enabled.
8 #
9 # This script should be run from the makefile with the directory path and ccflags
10 #
11 cc="${1}"
12
13 if test "${2}" = ""; then
14 dir="."
15 else
16 dir="${2}"
17 fi
18
19 exitCode=0
20
21 for f in `cd ${dir} && ls -1 *.h 2>/dev/null`; do
22 echo -n "Testing ${dir}/${f} ..."
23 hdr=`echo "${f}" | sed s/.h//`
24 if [ ! -e ./testHeaderDeps_${hdr}.o -o ${dir}/${f} -nt ./testHeaderDeps_${hdr}.o ]; then
25 ( echo "/* This file is AUTOMATICALLY GENERATED. DO NOT ALTER IT */"
26 echo "#include \"${dir}/${f}\" "
27 echo "int main( int argc, char* argv[] ) { return 0; } "
28 ) >./testHeaderDeps_${hdr}.cc
29
30 # run compile test on the new file.
31 # DEBUG: echo "TRY: ${cc} -o testHeaderDeps.o ./testHeaderDeps_${hdr}.cc"
32 ${cc} -c -o testHeaderDeps_${hdr}.o ./testHeaderDeps_${hdr}.cc
33 rm ./testHeaderDeps_${hdr}.cc
34 fi
35 if [ ! -f testHeaderDeps_${hdr}.o ]; then
36 rm testHeaders
37 exitCode=1
38 else
39 echo "OK."
40 # unit-tests require an app to run.
41 # our most-recent object suits this purpose.
42 # let's link or some tests will fail
43 ${cc} ./testHeaderDeps_${hdr}.o -o ./testHeaders
44 fi
45 done
46
47 exit $exitCode