File: testheaders.sh

package info (click to toggle)
squid3 3.4.8-6
  • links: PTS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 31,084 kB
  • sloc: cpp: 165,325; ansic: 21,998; sh: 12,166; makefile: 5,964; perl: 2,153; sql: 322; awk: 118
file content (44 lines) | stat: -rwxr-xr-x 1,143 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh
#
# test all header files (.h) for dependancy issues.
#
# Ideally this test should be performed twice before any code is accepted.
# With or without inline enabled.  This is needed because the .cci files
#  are only included into the .h files when inline mode is enabled.
#
# 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}

exitCode=0

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