]> git.ipfire.org Git - thirdparty/squid.git/blob - test-builds.sh
Bug 2613: test-builds.sh does not test what it claims to test
[thirdparty/squid.git] / test-builds.sh
1 #!/bin/sh
2 #
3 # Run specific build tests for a given OS environment.
4 #
5 top=`dirname $0`
6
7 cleanup="no"
8 verbose="no"
9 while [ $# -ge 1 ]; do
10 case "$1" in
11 --cleanup)
12 cleanup="yes"
13 shift
14 ;;
15 --verbose)
16 verbose="yes"
17 shift
18 ;;
19 *)
20 break
21 ;;
22 esac
23 done
24
25 # Things to catch
26 errors="^ERROR|\ error:|\ Error\ |No\ such|assertion\ failed|FAIL:"
27
28 logtee() {
29 if [ $verbose = yes ]; then
30 tee $1
31 else
32 cat >$1
33 fi
34 }
35
36 buildtest() {
37 opts=$1
38 layer=`basename $opts .opts`
39 btlayer="bt$layer"
40 log=${btlayer}.log
41 echo "TESTING: ${layer}"
42 rm -f -r ${btlayer} && mkdir ${btlayer}
43 {
44 cd ${btlayer}
45 if test -e $top/test-suite/buildtest.sh ; then
46 $top/test-suite/buildtest.sh $opts
47 elif test -e ../$top/test-suite/buildtest.sh ; then
48 ../$top/test-suite/buildtest.sh ../$opts
49 fi
50 } 2>&1 | logtee $log
51 grep -E "BUILD" ${log}
52 grep -E "${errors}" $log && exit 1
53 if test "${cleanup}" = "yes" ; then
54 echo "REMOVE DATA: ${btlayer}"
55 rm -f -r ${btlayer}
56 fi
57 result=`tail -2 $log | head -1`
58 if test "${result}" = "Build Successful." ; then
59 echo "${result}"
60 else
61 echo "Build Failed:"
62 tail -5 $log
63 exit 1
64 fi
65 if test "${cleanup}" = "yes" ; then
66 echo "REMOVE LOG: ${log}"
67 rm -f -r $log
68 fi
69 }
70
71 # Run a single test build by name or opts file
72 if [ -e "$1" ]; then
73
74 buildtest $1
75 exit 0
76 fi
77 tmp=`basename "${1}" .opts`
78 if test -e $top/test-suite/buildtests/${tmp}.opts ; then
79 buildtest $top/test-suite/buildtests/${tmp}.opts
80 exit 0
81 fi
82
83 #
84 # Run specific tests for each combination of configure-time
85 # Options.
86 #
87 # These layers are constructed from detailed knowledge of
88 # component dependencies.
89 #
90 for f in `ls -1 $top/test-suite/buildtests/layer*.opts` ; do
91 buildtest $f
92 done