-
Notifications
You must be signed in to change notification settings - Fork 0
/
autotest_cgal_with_ctest
338 lines (303 loc) · 10.8 KB
/
autotest_cgal_with_ctest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
#!/bin/bash
#usage : script [-c -l -n -s -k] testsuite_dir
##########################
#### LAUNCH CTEST ####
##########################
export SHOW_PROGRESS=""
export KEEP_TESTS=""
export DO_NOT_UPLOAD=""
export DO_NOT_TEST=""
export SCP="scp"
export WGET="wget"
export WGET_OPTS="--no-check-certificate --no-verbose"
export CURL="curl"
export CURL_OPTS="-k --remote-name --silent --location-trusted"
export CGAL_URL="https://cgal.geometryfactory.com/CGAL/Releases"
export UPLOAD_RESULT_DESTINATION="[email protected]:incoming"
export UPLOAD_DEMOS_DESTINATION="[email protected]:public_html/incoming"
export LATEST_LOCATION="${CGAL_URL}/LATEST"
export TAR="tar"
export GUNZIP="gunzip"
export COMPRESSOR="gzip"
export CONSOLE_OUTPUT="y"
export CGAL_HOME=$(pwd | sed -E 's/\/cygdrive\/([a-z])\//\U\1:\//')
export USE_TARGZ="y"
export USE_TARBZ="n"
export CGAL_RELEASE=""
export LOGS_DIR=""
export LOCK_FILE=""
export ACTUAL_LOGFILE=""
export CGAL_DIR=""
export INSTALLATION_DIR=""
export TESTSUITE_DIR=""
USE_LATEST_UNZIPPED=""
# ----------------------------------------------------------------------------------------
# produce a string containing the actual date/time
# (used to identify files)
# ----------------------------------------------------------------------------------------
datestr()
{
date +%d%m%Y%H%M
}
# ----------------------------------------------------------------------------------------
# Logging functions
# ----------------------------------------------------------------------------------------
log()
{
LOGFILE=${1}
shift
if [ -n "${CONSOLE_OUTPUT}" ]; then
printf "${*} ...\n"
fi
printf "\n-------------------------------------------------------\n" >> "${LOGFILE}"
printf " ${*} ...\n" >> "${LOGFILE}"
printf "\n-------------------------------------------------------\n" >> "${LOGFILE}"
}
log_done()
{
if [ -n "${CONSOLE_OUTPUT}" ]; then
printf \
" done\n-------------------------------------------------------\n"
fi
printf "\n-------------------------------------------------------\n" >> "${1}"
printf " **DONE**\n" >> "${1}"
printf "\n-------------------------------------------------------\n" >> "${1}"
}
error()
{
if [ -n "${CONSOLE_OUTPUT}" ]; then
printf "\nERROR: ${*}, exiting.\n" >&2
fi
printf "\nERROR: ${*}, exiting.\n" >> "${ACTUAL_LOGFILE}"
${COMPRESSOR} -9f "${ACTUAL_LOGFILE}"
FILENAME="${CGAL_RELEASE_ID}-log`datestr`.gz"
mv "${ACTUAL_LOGFILE}.gz" "${LOGS_DIR}/${FILENAME}"
if [ ! "${MAIL_ADDRESS}" = "must_be_set_in_.autocgalrc" ]; then
for i in ${MAIL_ADDRESS}; do
printf "ERROR\n${LOGS_DIR}/${FILENAME}\n" | \
${SENDMAIL} -s "completed autotest" "${i}"
done
fi
rm -rf "$LOCK_FILE";
exit 1
}
# ----------------------------------------------------------------------------------------
# Downloads the file "LATEST" whose contents indicates which release to test
# ----------------------------------------------------------------------------------------
download_latest()
{
if [ -r "LATEST" ]; then
rm -rf LATEST
fi
log "${ACTUAL_LOGFILE}" "getting LATEST"
if [ -n "${USE_CURL}" ]; then
echo "using curl..."
${CURL} ${CURL_OPTS} "${LATEST_LOCATION}" >> "${ACTUAL_LOGFILE}" 2>&1
else
echo "using wget..."
${WGET} ${WGET_OPTS} "${LATEST_LOCATION}" >> "${ACTUAL_LOGFILE}" 2>&1
fi
if [ ! -f "LATEST" ]; then
error "COULD NOT DOWNLOAD LATEST!"
fi
}
# ----------------------------------------------------------------------------------------
# Exits the testsuite if the latest release has been already tested.
# This is tested by comparing files LATEST and RELEASE_NR, where
# RELEASE_NR is a copy of the previous LATEST.
# ----------------------------------------------------------------------------------------
abort_if_latest_already_tested()
{
if [ -r "RELEASE_NR" ]; then
if cmp LATEST RELEASE_NR >> "${ACTUAL_LOGFILE}"; then
log "${ACTUAL_LOGFILE}" "This release has already been tested."
rm -f "$LOCK_FILE";
exit 1;
fi
fi
}
# ----------------------------------------------------------------------------------------
# get CGAL
# ----------------------------------------------------------------------------------------
get_cgal()
{
if [ -z "$CGAL_LOCATION" ]; then
for i in `cat LATEST`
do
CGAL_LOCATION="${CGAL_URL}/${i}";
CGAL_ZIPFILE="${i}";
done
else
CGAL_ZIPFILE=`echo "$CGAL_LOCATION" | sed 's|.*/||'`
fi
CGAL_RELEASE_ID=`echo $CGAL_ZIPFILE | sed "s/.tar.gz//"`
echo ${CGAL_RELEASE_ID} |tee last_release_id
if [ ! "${CGAL_RELEASE_ID}" = "${CGAL_ZIPFILE}" ]; then
USE_TARGZ="y"
else
CGAL_RELEASE_ID=`echo $CGAL_ZIPFILE | sed "s/.tar.bz2//"`
if [ ! "${CGAL_RELEASE_ID}" = "${CGAL_ZIPFILE}" ]; then
USE_TARBZ="y"
fi
fi
log "${ACTUAL_LOGFILE}" "CGAL_ZIPFILE = ${CGAL_ZIPFILE}"
log "${ACTUAL_LOGFILE}" "CGAL_RELEASE_ID = ${CGAL_RELEASE_ID}"
log "${ACTUAL_LOGFILE}" "getting CGAL"
rm -f "${CGAL_ZIPFILE}"
if [ -n "${USE_CURL}" ]; then
${CURL} ${CURL_OPTS} "${CGAL_LOCATION}" >> "${ACTUAL_LOGFILE}" 2>&1
else
${WGET} ${WGET_OPTS} "${CGAL_LOCATION}" >> "${ACTUAL_LOGFILE}" 2>&1
fi
if [ ${?} != 0 ]; then
error "Could not get CGAL"
fi
log_done "${ACTUAL_LOGFILE}"
}
# ----------------------------------------------------------------------------------------
# Unzips and untars the downloaded CGAL release
# ----------------------------------------------------------------------------------------
unzip_cgal()
{
cd "${CGAL_HOME}"
log "${ACTUAL_LOGFILE}" "unzipping CGAL"
if [ "${USE_TARGZ}" = "y" ]; then
DECOMPRESSOR="${GUNZIP}"
log_done "${ACTUAL_LOGFILE}"
fi
if [ "${USE_TARBZ}" = "y" ]; then
DECOMPRESSOR="bunzip2"
fi
log "${ACTUAL_LOGFILE}" "untarring CGAL"
${DECOMPRESSOR} -c "${CGAL_ZIPFILE}" | ${TAR} xf - >> "${ACTUAL_LOGFILE}" 2>&1
if [ ${?} != 0 ]; then
error "Could not untar CGAL"
fi
# check, if CGAL_DIR exists
if [ -d "${CGAL_HOME}/${CGAL_RELEASE_ID}" ]; then
# Reset CGAL-I symlink
log "${ACTUAL_LOGFILE}" "Resetting CGAL-I symlink to ${CGAL_HOME}/${CGAL_RELEASE_ID}"
rm -f CGAL-I
ln -s "${CGAL_HOME}/${CGAL_RELEASE_ID}" CGAL-I
# Reset CGAL-3.x-I symlink
CGAL_RELEASE=`echo "${CGAL_RELEASE_ID}" | sed 's/I\([^-]*\)-.*/I\1/'`
log "${ACTUAL_LOGFILE}" "Resetting ${CGAL_RELEASE} symlink to ${CGAL_HOME}/${CGAL_RELEASE_ID}"
rm -f "${CGAL_RELEASE}"
ln -s "${CGAL_HOME}/${CGAL_RELEASE_ID}" "${CGAL_RELEASE}"
else
error "directory ${CGAL_HOME}/${CGAL_RELEASE_ID} does not exist"
fi
log_done "${ACTUAL_LOGFILE}"
}
# Parse command line arguments
for arg in "$@"
do
case "$arg" in
"-c")
echo "Using latest unzipped release instead of getting a new one from the server"
USE_LATEST_UNZIPPED="y"
;;
"-l")
echo "Not uploading results to dashboard"
DO_NOT_UPLOAD="y"
;;
"-n")
echo "No testsuite will be launched. Installation only."
DO_NOT_TEST="y"
;;
"-s")
echo "Showing progress."
SHOW_PROGRESS="y"
;;
"-k")
echo "Compiled test/ directory will be kept."
KEEP_TESTS="y"
;;
"-g")
echo "Run testsuite from GIT branch"
export INSTALLATION_DIR="Installation/"
export TESTSUITE_DIR="Testsuite/"
export SCRIPTS_DIR="Scripts/"
UPLOAD_RESULT_DESTINATION="[email protected]:incoming"
;;
*)
CGAL_LOCATION=$arg
esac
done
# Load settings
if [ -f "${CGAL_HOME}/.autocgalrc" ]; then
. "${CGAL_HOME}/.autocgalrc"
else
echo "CONFIGURATION FILE .autocgalrc NOT FOUND" >&2;
exit 1
fi
LOGS_DIR="${CGAL_HOME}/AUTOTEST_LOGS"
LOCK_FILE="${CGAL_HOME}/autotest_cgal_with_cmake.lock"
# Setup logfile
ACTUAL_LOGFILE="${CGAL_HOME}/`basename ${0}`.log"
rm -f "${ACTUAL_LOGFILE}"
echo "Running `basename ${0}` "'$Revision$' >> "${ACTUAL_LOGFILE}"
cd "$CGAL_HOME"
# Starts the process
if [ -z "${USE_LATEST_UNZIPPED}" -a -z "${SCRIPTS_DIR}" ]; then
if [ -z "$CGAL_LOCATION" ]; then
download_latest
abort_if_latest_already_tested
fi
get_cgal
unzip_cgal
fi
#reset CGAL-DIR with the updated CGAL-I
if [ -n "${SCRIPTS_DIR}" ]; then
CGAL_DIR=`readlink "${CGAL_HOME}/CGAL-git"`
else
CGAL_DIR=`readlink "${CGAL_HOME}/CGAL-I"`
fi
CGAL_DIR=$(echo "$CGAL_DIR" | sed -E 's/\/cygdrive\/([a-z])\//\U\1:\//')
CGAL_RELEASE_ID=$(cat last_release_id)
for HOST in ${BUILD_HOSTS}; do
if [ "$HOST" != "localhost" ]; then
#launch docker container
echo "export SHOW_PROGRESS=$SHOW_PROGRESS"> env.sh
echo "export KEEP_TESTS=$KEEP_TESTS">> env.sh
echo "export DO_NOT_UPLOAD=$DO_NOT_UPLOAD">> env.sh
echo "export DO_NOT_TEST=$DO_NOT_TEST">> env.sh
echo "export SCP=$SCP">> env.sh
echo "export WGET=$WGET">> env.sh
echo "export WGET_OPTS=\"$WGET_OPTS\"">> env.sh
echo "export CURL=$CURL">> env.sh
echo "export CURL_OPTS=\"$CURL_OPTS\"">> env.sh
echo "export CGAL_URL=$CGAL_URL">> env.sh
echo "export UPLOAD_RESULT_DESTINATION=$UPLOAD_RESULT_DESTINATION">> env.sh
echo "export LATEST_LOCATION=$LATEST_LOCATION">> env.sh
echo "export TAR=$TAR">> env.sh
echo "export GUNZIP=$GUNZIP">> env.sh
echo "export COMPRESSOR=$COMPRESSOR">> env.sh
echo "export CONSOLE_OUTPUT=$CONSOLE_OUTPUT">> env.sh
echo "export CGAL_HOME=/cgal_root">> env.sh
echo "export USE_TARGZ=$USE_TARGZ">> env.sh
echo "export USE_TARBZ=$USE_TARBZ">> env.sh
echo "export CGAL_RELEASE=$CGAL_RELEASE">> env.sh
echo "export LOGS_DIR=/cgal_root/AUTOTEST_LOGS">> env.sh
echo "export LOCK_FILE=/cgal_root/autotest_cgal_with_cmake.lock">> env.sh
echo "export ACTUAL_LOGFILE=/cgal_root/\`basename \${0}\`.log">> env.sh
echo "export REFERENCE_PLATFORMS_DIR=$REFERENCE_PLATFORMS_DIR">>env.sh
echo "export INSTALLATION_DIR=$INSTALLATION_DIR">>env.sh
echo "export TESTSUITE_DIR=$TESTSUITE_DIR">>env.sh
echo "export SCRIPTS_DIR=$SCRIPTS_DIR">>env.sh
docker pull cgal/testsuite-docker:debian-stable-cross-compilation-for-arm
if [ -z "${SCRIPTS_DIR}" ]; then #if not from branch
echo "export CGAL_DIR=/cgal_root/\${CGAL_LAST}">>env.sh
docker run --rm -t -e CGAL_LAST="${CGAL_RELEASE_ID}" -e HOST="${HOST}" -v ${CGAL_HOME}/ssh:/tmp_ssh -v ${DEPS_DIR}:/deps -v ${CGAL_HOME}:/cgal_root cgal/testsuite-docker:debian-stable-cross-compilation-for-arm
else
echo "export CGAL_DIR=/cgal_root/CGAL-git">>env.sh
docker run --rm -t -e HOST="${HOST}" -v ${CGAL_HOME}/ssh:/tmp_ssh -v ${DEPS_DIR}:/deps -v ${CGAL_HOME}:/cgal_root -v${CGAL_DIR}:/cgal_root/CGAL-git cgal/testsuite-docker:debian-stable-cross-compilation-for-arm
fi
else
HOST=$HOST bash -$- ${CGAL_DIR}/${SCRIPTS_DIR}developer_scripts/run_testsuite_with_ctest
fi
done
cd "${CGAL_HOME}"
if [ -e "LATEST" ]; then
mv LATEST RELEASE_NR
fi