blob: 318081be45aeba09b1013bb204476d9bd6193feb (
plain)
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
|
#!/bin/bash
# This script executes the script step when running under travis-ci
# Set-up some bash options
set -o nounset ## set -u : exit the script if you try to use an uninitialised variable
set -o errexit ## set -e : exit the script if any statement returns a non-true return value
set -o pipefail ## Fail on error in pipe
# Set-up some variables
if [ "${OPJ_CI_BUILD_CONFIGURATION:-}" == "" ]; then
export OPJ_CI_BUILD_CONFIGURATION=Release #default
fi
OPJ_SOURCE_DIR=$(cd $(dirname $0)/../.. && pwd)
if [ "${OPJ_DO_SUBMIT:-}" == "" ]; then
OPJ_DO_SUBMIT=0 # Do not flood cdash by default
fi
if [ "${TRAVIS_REPO_SLUG:-}" != "" ]; then
OPJ_OWNER=$(echo "${TRAVIS_REPO_SLUG}" | sed 's/\(^.*\)\/.*/\1/')
OPJ_SITE="${OPJ_OWNER}.travis-ci.org"
if [ "${OPJ_OWNER}" == "uclouvain" ]; then
OPJ_DO_SUBMIT=1
fi
else
OPJ_SITE="$(hostname)"
fi
if [ "${TRAVIS_OS_NAME:-}" == "" ]; then
# Let's guess OS for testing purposes
echo "Guessing OS"
if uname -s | grep -i Darwin &> /dev/null; then
TRAVIS_OS_NAME=osx
elif uname -s | grep -i Linux &> /dev/null; then
TRAVIS_OS_NAME=linux
if [ "${CC:-}" == "" ]; then
# default to gcc
export CC=gcc
fi
else
echo "Failed to guess OS"; exit 1
fi
echo "${TRAVIS_OS_NAME}"
fi
if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
OPJ_OS_NAME=$(sw_vers -productName | tr -d ' ')$(sw_vers -productVersion | sed 's/\([^0-9]*\.[0-9]*\).*/\1/')
OPJ_CC_VERSION=$(xcodebuild -version | grep -i xcode)
OPJ_CC_VERSION=xcode${OPJ_CC_VERSION:6}
elif [ "${TRAVIS_OS_NAME}" == "linux" ]; then
OPJ_OS_NAME=linux
if which lsb_release > /dev/null; then
OPJ_OS_NAME=$(lsb_release -si)$(lsb_release -sr | sed 's/\([^0-9]*\.[0-9]*\).*/\1/')
fi
if [ -z "${CC##*gcc*}" ]; then
OPJ_CC_VERSION=$(${CC} --version | head -1 | sed 's/.*\ \([0-9.]*[0-9]\)/\1/')
if [ -z "${CC##*mingw*}" ]; then
OPJ_CC_VERSION=mingw${OPJ_CC_VERSION}
# disable testing for now
export OPJ_CI_SKIP_TESTS=1
else
OPJ_CC_VERSION=gcc${OPJ_CC_VERSION}
fi
elif [ -z "${CC##*clang*}" ]; then
OPJ_CC_VERSION=clang$(${CC} --version | grep version | sed 's/.*version \([^0-9.]*[0-9.]*\).*/\1/')
else
echo "Compiler not supported: ${CC}"; exit 1
fi
else
echo "OS not supported: ${TRAVIS_OS_NAME}"; exit 1
fi
if [ "${OPJ_CI_ARCH:-}" == "" ]; then
echo "Guessing build architecture"
MACHINE_ARCH=$(uname -m)
if [ "${MACHINE_ARCH}" == "x86_64" ]; then
export OPJ_CI_ARCH=x86_64
fi
echo "${OPJ_CI_ARCH}"
fi
if [ "${TRAVIS_BRANCH:-}" == "" ]; then
echo "Guessing branch"
TRAVIS_BRANCH=$(git -C ${OPJ_SOURCE_DIR} branch | grep '*' | tr -d '*[[:blank:]]') #default to master
fi
OPJ_BUILDNAME=${OPJ_OS_NAME}-${OPJ_CC_VERSION}-${OPJ_CI_ARCH}-${TRAVIS_BRANCH}
OPJ_BUILDNAME_TEST=${OPJ_OS_NAME}-${OPJ_CC_VERSION}-${OPJ_CI_ARCH}
if [ "${TRAVIS_PULL_REQUEST:-}" != "false" ] && [ "${TRAVIS_PULL_REQUEST:-}" != "" ]; then
OPJ_BUILDNAME=${OPJ_BUILDNAME}-pr${TRAVIS_PULL_REQUEST}
fi
OPJ_BUILDNAME=${OPJ_BUILDNAME}-${OPJ_CI_BUILD_CONFIGURATION}-3rdP
OPJ_BUILDNAME_TEST=${OPJ_BUILDNAME_TEST}-${OPJ_CI_BUILD_CONFIGURATION}-3rdP
if [ "${OPJ_CI_ASAN:-}" == "1" ]; then
OPJ_BUILDNAME=${OPJ_BUILDNAME}-ASan
OPJ_BUILDNAME_TEST=${OPJ_BUILDNAME_TEST}-ASan
fi
if [ "${OPJ_NONCOMMERCIAL:-}" == "1" ] && [ "${OPJ_CI_SKIP_TESTS:-}" != "1" ] && [ -d kdu ]; then
echo "
Testing will use Kakadu trial binaries. Here's the copyright notice from kakadu:
Copyright is owned by NewSouth Innovations Pty Limited, commercial arm of the UNSW Australia in Sydney.
You are free to trial these executables and even to re-distribute them,
so long as such use or re-distribution is accompanied with this copyright notice and is not for commercial gain.
Note: Binaries can only be used for non-commercial purposes.
"
fi
if [ -d cmake-install ]; then
export PATH=${PWD}/cmake-install/bin:${PATH}
fi
set -x
# This will print configuration
# travis-ci doesn't dump cmake version in system info, let's print it
cmake --version
export OPJ_SITE=${OPJ_SITE}
export OPJ_BUILDNAME=${OPJ_BUILDNAME}
export OPJ_SOURCE_DIR=${OPJ_SOURCE_DIR}
export OPJ_BUILD_CONFIGURATION=${OPJ_CI_BUILD_CONFIGURATION}
export OPJ_DO_SUBMIT=${OPJ_DO_SUBMIT}
ctest -S ${OPJ_SOURCE_DIR}/tools/ctest_scripts/travis-ci.cmake -V || true
# ctest will exit with various error codes depending on version.
# ignore ctest exit code & parse this ourselves
set +x
# let's parse configure/build/tests for failure
echo "
Parsing logs for failures
"
OPJ_CI_RESULT=0
# 1st configure step
OPJ_CONFIGURE_XML=$(find build -path 'build/Testing/*' -name 'Configure.xml')
if [ ! -f "${OPJ_CONFIGURE_XML}" ]; then
echo "No configure log found"
OPJ_CI_RESULT=1
else
if ! grep '<ConfigureStatus>0</ConfigureStatus>' ${OPJ_CONFIGURE_XML} &> /dev/null; then
echo "Errors were found in configure log"
OPJ_CI_RESULT=1
fi
fi
# 2nd build step
# We must have one Build.xml file
OPJ_BUILD_XML=$(find build -path 'build/Testing/*' -name 'Build.xml')
if [ ! -f "${OPJ_BUILD_XML}" ]; then
echo "No build log found"
OPJ_CI_RESULT=1
else
if grep '<Error>' ${OPJ_BUILD_XML} &> /dev/null; then
echo "Errors were found in build log"
OPJ_CI_RESULT=1
fi
fi
if [ ${OPJ_CI_RESULT} -ne 0 ]; then
# Don't trash output with failing tests when there are configure/build errors
exit ${OPJ_CI_RESULT}
fi
if [ "${OPJ_CI_SKIP_TESTS:-}" != "1" ]; then
OPJ_TEST_XML=$(find build -path 'build/Testing/*' -name 'Test.xml')
if [ ! -f "${OPJ_TEST_XML}" ]; then
echo "No test log found"
OPJ_CI_RESULT=1
else
echo "Parsing tests for new/unknown failures"
# 3rd test step
OPJ_FAILEDTEST_LOG=$(find build -path 'build/Testing/Temporary/*' -name 'LastTestsFailed_*.log')
if [ -f "${OPJ_FAILEDTEST_LOG}" ]; then
awk -F: '{ print $2 }' ${OPJ_FAILEDTEST_LOG} > failures.txt
while read FAILEDTEST; do
# Start with common errors
if grep -x "${FAILEDTEST}" ${OPJ_SOURCE_DIR}/tools/travis-ci/knownfailures-all.txt > /dev/null; then
continue
fi
if [ -f ${OPJ_SOURCE_DIR}/tools/travis-ci/knownfailures-${OPJ_BUILDNAME_TEST}.txt ]; then
if grep -x "${FAILEDTEST}" ${OPJ_SOURCE_DIR}/tools/travis-ci/knownfailures-${OPJ_BUILDNAME_TEST}.txt > /dev/null; then
continue
fi
fi
echo "${FAILEDTEST}"
OPJ_CI_RESULT=1
done < failures.txt
fi
fi
# 4th memcheck step
OPJ_MEMCHECK_XML=$(find build -path 'build/Testing/*' -name 'MemCheck.xml')
if [ -f "${OPJ_MEMCHECK_XML}" ]; then
echo "TODO parse MemCheck.xml"
fi
if [ ${OPJ_CI_RESULT} -eq 0 ]; then
echo "No new/unknown test failure found"
else
echo "
New/unknown test failure found!!!
"
fi
fi
exit ${OPJ_CI_RESULT}
|