]> git.ipfire.org Git - thirdparty/squid.git/blame - test-builds.sh
Bug #2818: Random unix_group crash at startup due to uninitialized pointer reference
[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}"
9d386365 61 chmod -R 777 ${btlayer}
c2656b9c
AJ
62 rm -f -r ${btlayer} || ( echo "FATAL: Failed to prepare test build sandpit." ; exit 1 )
63 mkdir ${btlayer}
0039f2b3
AJ
64 if test "${verbose}" = "yes" ; then
65 ls -la ${btlayer}
66 fi
90875e5b 67 {
7b332852 68 result=255
90875e5b 69 cd ${btlayer}
f89b784b 70 if test -e $top/test-suite/buildtest.sh ; then
7e790ef3
AR
71 $top/test-suite/buildtest.sh ${opts} 2>&1
72 result=$?
f89b784b 73 elif test -e ../$top/test-suite/buildtest.sh ; then
7e790ef3
AR
74 ../$top/test-suite/buildtest.sh ../${opts} 2>&1
75 result=$?
7b332852 76 else
7e790ef3
AR
77 echo "Error: cannot find $top/test-suite/buildtest.sh script"
78 result=1
f89b784b 79 fi
7e790ef3 80
7b332852
AR
81 # log the result for the outer script to notice
82 echo "buildtest.sh result is $result";
c3927a50 83 } 2>&1 | logtee ${log}
7b332852
AR
84
85 result=1 # failure by default
7e790ef3 86 if grep -q '^buildtest.sh result is 0$' ${log}; then
7b332852
AR
87 result=0
88 fi
89
395093ad
AR
90 # Display BUILD parameters to double check that we are building the
91 # with the right parameters. TODO: Make less noisy.
bc3d3d8c 92 grep -E "BUILD" ${log}
7b332852 93
b719102e 94 errors="^ERROR|\ error:|\ Error\ |No\ such|assertion\ failed|FAIL:|:\ undefined"
c3927a50 95 grep -E "${errors}" ${log}
7b332852 96
7b332852
AR
97 if test $result -eq 0; then
98 # successful execution
0039f2b3 99 if test "${verbose}" = "yes"; then
9d6eb0e0 100 echo "Build OK. Global result is $globalResult."
7b332852 101 fi
c2656b9c
AJ
102 if test "${cleanup}" = "yes" ; then
103 echo "REMOVE DATA: ${btlayer}"
104 chmod -R 777 ${btlayer}
105 rm -f -r ${btlayer}
106 echo "REMOVE LOG: ${log}"
107 rm -f -r ${log}
108 fi
bc3d3d8c 109 else
e7b3cad3 110 if test "${verbose}" != "yes" ; then
0039f2b3
AJ
111 echo "Build Failed. Last log lines are:"
112 tail -20 ${log}
113 else
114 echo "Build FAILED."
115 fi
116 globalResult=1
bc3d3d8c 117 fi
90875e5b
HN
118}
119
8182d08a 120# if using cache, make sure to clear it up first
faa82072 121if [ -n "$cache_file" -a -e "$cache_file" -a "$remove_cache_file" = "true" ]; then
8182d08a
FC
122 rm $cache_file
123fi
124
9d6eb0e0
AR
125# Decide what tests to run, $* contains test spec names or filenames.
126# Use all knows specs if $* is empty or a special macro called 'all'.
7b332852
AR
127if test -n "$*" -a "$*" != all; then
128 tests="$*"
129else
130 tests=`ls -1 $top/test-suite/buildtests/layer*.opts`
bea1ee2e
AJ
131fi
132
7b332852
AR
133for t in $tests; do
134 if test -e "$t"; then
135 # A configuration file
136 cfg="$t"
137 elif test -e "$top/test-suite/buildtests/${t}.opts"; then
138 # A well-known configuration name
139 cfg="$top/test-suite/buildtests/${t}.opts"
140 else
141 echo "Error: Unknown test specs '$t'"
142 cfg=''
143 globalResult=1
144 fi
145
146 # run the test, if any
147 if test -n "$cfg"; then
148 buildtest $cfg
149 fi
150
151 # quit on errors unless we should $keepGoing
152 if test $globalResult -ne 0 -a $keepGoing != yes; then
153 exit $globalResult
154 fi
bea1ee2e 155done
7b332852 156
faa82072
FC
157# if using cache, make sure to clear it up first
158if [ -n "$cache_file" -a -e "$cache_file" -a "$remove_cache_file" = "true" ]; then
159 rm $cache_file
160fi
161
7b332852 162exit $globalResult