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