]> git.ipfire.org Git - thirdparty/squid.git/blame - test-builds.sh
Polish: convert ACLFilledChecklist to CBDATA_CLASS2
[thirdparty/squid.git] / test-builds.sh
CommitLineData
3d885c4d 1#!/bin/sh
bea1ee2e 2#
7b332852 3# Run all or some build tests for a given OS environment.
bea1ee2e 4#
90875e5b 5top=`dirname $0`
bea1ee2e 6
7b332852
AR
7globalResult=0
8
8a062962 9cleanup="no"
90875e5b 10verbose="no"
7b332852 11keepGoing="no"
faa82072 12remove_cache_file="true"
90875e5b
HN
13while [ $# -ge 1 ]; do
14 case "$1" in
15 --cleanup)
8a062962
AJ
16 cleanup="yes"
17 shift
90875e5b
HN
18 ;;
19 --verbose)
20 verbose="yes"
21 shift
22 ;;
7b332852
AR
23 --keep-going)
24 keepGoing="yes"
25 shift
26 ;;
8182d08a
FC
27 --use-config-cache)
28 #environment variable will be picked up by buildtest.sh
29 cache_file=/tmp/config.cache.$$
30 export cache_file
31 shift
32 ;;
faa82072
FC
33 --aggressively-use-config-cache)
34 #environment variable will be picked up by buildtest.sh
35 #note: use ONLY if you know what you're doing
36 cache_file=/tmp/config.cache
37 remove_cache_file="false"
38 export cache_file
39 shift
40 ;;
90875e5b
HN
41 *)
42 break
43 ;;
44 esac
45done
8a062962 46
90875e5b
HN
47logtee() {
48 if [ $verbose = yes ]; then
49 tee $1
50 else
51 cat >$1
52 fi
53}
54
55buildtest() {
56 opts=$1
c3927a50
AJ
57 layer=`basename ${opts} .opts`
58 btlayer="bt${layer}"
90875e5b
HN
59 log=${btlayer}.log
60 echo "TESTING: ${layer}"
1428486f
AR
61 if test -e ${btlayer}; then
62 chmod -R 777 ${btlayer};
63 fi
c2656b9c
AJ
64 rm -f -r ${btlayer} || ( echo "FATAL: Failed to prepare test build sandpit." ; exit 1 )
65 mkdir ${btlayer}
0039f2b3
AJ
66 if test "${verbose}" = "yes" ; then
67 ls -la ${btlayer}
68 fi
90875e5b 69 {
7b332852 70 result=255
90875e5b 71 cd ${btlayer}
f89b784b 72 if test -e $top/test-suite/buildtest.sh ; then
7e790ef3
AR
73 $top/test-suite/buildtest.sh ${opts} 2>&1
74 result=$?
f89b784b 75 elif test -e ../$top/test-suite/buildtest.sh ; then
7e790ef3
AR
76 ../$top/test-suite/buildtest.sh ../${opts} 2>&1
77 result=$?
7b332852 78 else
7e790ef3
AR
79 echo "Error: cannot find $top/test-suite/buildtest.sh script"
80 result=1
f89b784b 81 fi
7e790ef3 82
7b332852
AR
83 # log the result for the outer script to notice
84 echo "buildtest.sh result is $result";
c3927a50 85 } 2>&1 | logtee ${log}
7b332852
AR
86
87 result=1 # failure by default
7e790ef3 88 if grep -q '^buildtest.sh result is 0$' ${log}; then
7b332852
AR
89 result=0
90 fi
91
395093ad
AR
92 # Display BUILD parameters to double check that we are building the
93 # with the right parameters. TODO: Make less noisy.
bc3d3d8c 94 grep -E "BUILD" ${log}
7b332852 95
b719102e 96 errors="^ERROR|\ error:|\ Error\ |No\ such|assertion\ failed|FAIL:|:\ undefined"
c3927a50 97 grep -E "${errors}" ${log}
7b332852 98
7b332852
AR
99 if test $result -eq 0; then
100 # successful execution
0039f2b3 101 if test "${verbose}" = "yes"; then
9d6eb0e0 102 echo "Build OK. Global result is $globalResult."
7b332852 103 fi
c2656b9c
AJ
104 if test "${cleanup}" = "yes" ; then
105 echo "REMOVE DATA: ${btlayer}"
106 chmod -R 777 ${btlayer}
107 rm -f -r ${btlayer}
108 echo "REMOVE LOG: ${log}"
109 rm -f -r ${log}
110 fi
bc3d3d8c 111 else
e7b3cad3 112 if test "${verbose}" != "yes" ; then
0039f2b3
AJ
113 echo "Build Failed. Last log lines are:"
114 tail -20 ${log}
115 else
116 echo "Build FAILED."
117 fi
118 globalResult=1
bc3d3d8c 119 fi
90875e5b
HN
120}
121
8182d08a 122# if using cache, make sure to clear it up first
faa82072 123if [ -n "$cache_file" -a -e "$cache_file" -a "$remove_cache_file" = "true" ]; then
8182d08a
FC
124 rm $cache_file
125fi
126
9d6eb0e0
AR
127# Decide what tests to run, $* contains test spec names or filenames.
128# Use all knows specs if $* is empty or a special macro called 'all'.
7b332852
AR
129if test -n "$*" -a "$*" != all; then
130 tests="$*"
131else
132 tests=`ls -1 $top/test-suite/buildtests/layer*.opts`
bea1ee2e
AJ
133fi
134
7b332852
AR
135for t in $tests; do
136 if test -e "$t"; then
137 # A configuration file
138 cfg="$t"
139 elif test -e "$top/test-suite/buildtests/${t}.opts"; then
140 # A well-known configuration name
141 cfg="$top/test-suite/buildtests/${t}.opts"
142 else
143 echo "Error: Unknown test specs '$t'"
144 cfg=''
145 globalResult=1
146 fi
147
148 # run the test, if any
149 if test -n "$cfg"; then
150 buildtest $cfg
151 fi
152
153 # quit on errors unless we should $keepGoing
154 if test $globalResult -ne 0 -a $keepGoing != yes; then
155 exit $globalResult
156 fi
bea1ee2e 157done
7b332852 158
faa82072
FC
159# if using cache, make sure to clear it up first
160if [ -n "$cache_file" -a -e "$cache_file" -a "$remove_cache_file" = "true" ]; then
161 rm $cache_file
162fi
163
7b332852 164exit $globalResult