]>
Commit | Line | Data |
---|---|---|
3d885c4d | 1 | #!/bin/sh |
bea1ee2e | 2 | # |
a151895d | 3 | ## |
b8ae064d | 4 | ## Copyright (C) 1996-2023 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 | ;; | |
6f920816 FC |
36 | --progress) |
37 | verbose="progress" | |
38 | shift | |
39 | ;; | |
7b332852 AR |
40 | --keep-going) |
41 | keepGoing="yes" | |
42 | shift | |
43 | ;; | |
8182d08a FC |
44 | --use-config-cache) |
45 | #environment variable will be picked up by buildtest.sh | |
e28ca412 | 46 | cache_file=${cache_file:-/tmp/config.cache.$$} |
8182d08a FC |
47 | export cache_file |
48 | shift | |
49 | ;; | |
faa82072 FC |
50 | --aggressively-use-config-cache) |
51 | #environment variable will be picked up by buildtest.sh | |
52 | #note: use ONLY if you know what you're doing | |
e28ca412 | 53 | cache_file=${cache_file:-/tmp/config.cache} |
faa82072 FC |
54 | remove_cache_file="false" |
55 | export cache_file | |
56 | shift | |
57 | ;; | |
e28ca412 FC |
58 | --config-cache-file) |
59 | cache_file="$2" | |
60 | remove_cache_file="false" | |
61 | export cache_file | |
62 | shift 2 | |
63 | ;; | |
90875e5b HN |
64 | *) |
65 | break | |
66 | ;; | |
67 | esac | |
68 | done | |
8a062962 | 69 | |
90875e5b | 70 | logtee() { |
6f920816 FC |
71 | case $verbose in |
72 | yes) | |
73 | tee $1 | |
74 | ;; | |
75 | progress) | |
76 | tee $1 | awk '{printf "."; n++; if (!(n % 80)) print "" } END {print ""}' | |
77 | ;; | |
78 | *) | |
79 | cat >$1 | |
80 | esac | |
90875e5b HN |
81 | } |
82 | ||
83 | buildtest() { | |
84 | opts=$1 | |
61cd5ace | 85 | action=$2 |
c3927a50 AJ |
86 | layer=`basename ${opts} .opts` |
87 | btlayer="bt${layer}" | |
90875e5b HN |
88 | log=${btlayer}.log |
89 | echo "TESTING: ${layer}" | |
1428486f AR |
90 | if test -e ${btlayer}; then |
91 | chmod -R 777 ${btlayer}; | |
92 | fi | |
c2656b9c AJ |
93 | rm -f -r ${btlayer} || ( echo "FATAL: Failed to prepare test build sandpit." ; exit 1 ) |
94 | mkdir ${btlayer} | |
0039f2b3 AJ |
95 | if test "${verbose}" = "yes" ; then |
96 | ls -la ${btlayer} | |
97 | fi | |
90875e5b | 98 | { |
7b332852 | 99 | result=255 |
90875e5b | 100 | cd ${btlayer} |
f89b784b | 101 | if test -e $top/test-suite/buildtest.sh ; then |
61cd5ace | 102 | $top/test-suite/buildtest.sh "${action}" ${opts} 2>&1 |
7e790ef3 | 103 | result=$? |
f89b784b | 104 | elif test -e ../$top/test-suite/buildtest.sh ; then |
61cd5ace | 105 | ../$top/test-suite/buildtest.sh "${action}" ../${opts} 2>&1 |
7e790ef3 | 106 | result=$? |
7b332852 | 107 | else |
7e790ef3 AR |
108 | echo "Error: cannot find $top/test-suite/buildtest.sh script" |
109 | result=1 | |
f89b784b | 110 | fi |
7e790ef3 | 111 | |
7b332852 AR |
112 | # log the result for the outer script to notice |
113 | echo "buildtest.sh result is $result"; | |
c3927a50 | 114 | } 2>&1 | logtee ${log} |
7b332852 AR |
115 | |
116 | result=1 # failure by default | |
7e790ef3 | 117 | if grep -q '^buildtest.sh result is 0$' ${log}; then |
7b332852 AR |
118 | result=0 |
119 | fi | |
120 | ||
395093ad AR |
121 | # Display BUILD parameters to double check that we are building the |
122 | # with the right parameters. TODO: Make less noisy. | |
bc3d3d8c | 123 | grep -E "BUILD" ${log} |
7b332852 | 124 | |
395c3e2a | 125 | errors="^ERROR|[ ]error:|[ ]Error[ ]|No[ ]such|assertion[ ]failed|FAIL:|:[ ]undefined" |
c3927a50 | 126 | grep -E "${errors}" ${log} |
7b332852 | 127 | |
7b332852 AR |
128 | if test $result -eq 0; then |
129 | # successful execution | |
0039f2b3 | 130 | if test "${verbose}" = "yes"; then |
9d6eb0e0 | 131 | echo "Build OK. Global result is $globalResult." |
7b332852 | 132 | fi |
c2656b9c AJ |
133 | if test "${cleanup}" = "yes" ; then |
134 | echo "REMOVE DATA: ${btlayer}" | |
135 | chmod -R 777 ${btlayer} | |
136 | rm -f -r ${btlayer} | |
137 | echo "REMOVE LOG: ${log}" | |
138 | rm -f -r ${log} | |
139 | fi | |
bc3d3d8c | 140 | else |
e7b3cad3 | 141 | if test "${verbose}" != "yes" ; then |
96356d4e FC |
142 | echo "Build Failed." |
143 | echo "Log start: ${log}" | |
144 | cat ${log} | |
145 | echo "Log end: ${log}" | |
0039f2b3 AJ |
146 | else |
147 | echo "Build FAILED." | |
148 | fi | |
149 | globalResult=1 | |
bc3d3d8c | 150 | fi |
90875e5b HN |
151 | } |
152 | ||
8182d08a | 153 | # if using cache, make sure to clear it up first |
faa82072 | 154 | if [ -n "$cache_file" -a -e "$cache_file" -a "$remove_cache_file" = "true" ]; then |
8182d08a FC |
155 | rm $cache_file |
156 | fi | |
157 | ||
395d284b FC |
158 | if [ -f "$top/configure" -a -f "$top/libltdl/configure" ]; then |
159 | echo "Already bootstrapped, skipping step" | |
160 | else | |
161 | (cd "$top"; ./bootstrap.sh) | |
162 | fi | |
163 | ||
9d6eb0e0 AR |
164 | # Decide what tests to run, $* contains test spec names or filenames. |
165 | # Use all knows specs if $* is empty or a special macro called 'all'. | |
7b332852 AR |
166 | if test -n "$*" -a "$*" != all; then |
167 | tests="$*" | |
168 | else | |
169 | tests=`ls -1 $top/test-suite/buildtests/layer*.opts` | |
bea1ee2e AJ |
170 | fi |
171 | ||
7b332852 | 172 | for t in $tests; do |
9603207d | 173 | if test -e "$t"; then |
7b332852 AR |
174 | # A configuration file |
175 | cfg="$t" | |
176 | elif test -e "$top/test-suite/buildtests/${t}.opts"; then | |
177 | # A well-known configuration name | |
178 | cfg="$top/test-suite/buildtests/${t}.opts" | |
179 | else | |
180 | echo "Error: Unknown test specs '$t'" | |
181 | cfg='' | |
182 | globalResult=1 | |
183 | fi | |
184 | ||
185 | # run the test, if any | |
186 | if test -n "$cfg"; then | |
61cd5ace | 187 | buildtest "$cfg" "$action" |
7b332852 AR |
188 | fi |
189 | ||
190 | # quit on errors unless we should $keepGoing | |
191 | if test $globalResult -ne 0 -a $keepGoing != yes; then | |
192 | exit $globalResult | |
193 | fi | |
bea1ee2e | 194 | done |
7b332852 | 195 | |
faa82072 FC |
196 | # if using cache, make sure to clear it up first |
197 | if [ -n "$cache_file" -a -e "$cache_file" -a "$remove_cache_file" = "true" ]; then | |
198 | rm $cache_file | |
199 | fi | |
200 | ||
7b332852 | 201 | exit $globalResult |