2 # shellcheck disable=SC2103
4 # Copyright (C) 2016 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
5 # 2016-2019 Michael Jeanson <mjeanson@efficios.com>
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 # Version compare functions
23 if [[ "$1" == "$2" ]]; then
27 local i ver1
=($1) ver2
=($2)
28 # fill empty fields in ver1 with zeros
29 for ((i
=${#ver1[@]}; i
<${#ver2[@]}; i
++)); do
32 for ((i
=0; i
<${#ver1[@]}; i
++)); do
33 if [[ -z ${ver2[i]} ]]; then
34 # fill empty fields in ver2 with zeros
37 if ((10#${ver1[i]} > 10#${ver2[i]})); then
40 if ((10#${ver1[i]} < 10#${ver2[i]})); then
49 vercomp
"$1" "$2"; local res
="$?"
50 [ "$res" -eq "0" ] ||
[ "$res" -eq "2" ]
54 vercomp
"$1" "$2"; local res
="$?"
59 vercomp
"$1" "$2"; local res
="$?"
60 [ "$res" -eq "0" ] ||
[ "$res" -eq "1" ]
64 vercomp
"$1" "$2"; local res
="$?"
69 vercomp
"$1" "$2"; local res
="$?"
74 WORKSPACE
=${WORKSPACE:-}
80 test_type
=${test_type:-}
82 DEPS_INC
="$WORKSPACE/deps/build/include"
83 DEPS_LIB
="$WORKSPACE/deps/build/lib"
84 DEPS_BIN
="$WORKSPACE/deps/build/bin"
85 DEPS_JAVA
="$WORKSPACE/deps/build/share/java"
87 export PATH
="$DEPS_BIN:$PATH"
88 export LD_LIBRARY_PATH
="$DEPS_LIB:${LD_LIBRARY_PATH:-}"
89 export CPPFLAGS
="-I$DEPS_INC"
90 export LDFLAGS
="-L$DEPS_LIB"
92 SRCDIR
="$WORKSPACE/src/lttng-tools"
93 TAPDIR
="$WORKSPACE/tap"
97 # Create tmp directory
98 TMPDIR
="$WORKSPACE/tmp"
101 # Use a symlink in /tmp to point to the the tmp directory
102 # inside the workspace, this is to work around the path length
103 # limit of unix sockets which are created by the test suite.
105 ln -sf "$TMPDIR" "$tmpdir"
106 export TMPDIR
="$tmpdir"
108 export CFLAGS
="-g -O2"
110 # Set compiler variables
142 export CXX
=clang
++-3.9
146 export CXX
=clang
++-4.0
150 export CXX
=clang
++-5.0
154 export CXX
=clang
++-6.0
161 if [ "x$cc" != "x" ]; then
167 if [ "x${CC:-}" != "x" ]; then
168 echo "Selected compiler:"
172 # Set platform variables
178 export PATH
="/opt/csw/bin:/usr/ccs/bin:$PATH"
179 export CPPFLAGS
="-I/opt/csw/include -D_XOPEN_SOURCE=500 $CPPFLAGS"
180 export LDFLAGS
="-L/opt/csw/lib -R/opt/csw/lib $LDFLAGS"
181 export PKG_CONFIG_PATH
="/opt/csw/lib/pkgconfig"
182 export PYTHON
="python3"
183 export PYTHON_CONFIG
="python3-config"
192 export PATH
="$PATH:/usr/perl5/bin"
193 export CPPFLAGS
="-I/opt/csw/include -D_XOPEN_SOURCE=500 $CPPFLAGS"
194 export LDFLAGS
="-L/opt/csw/lib -R/opt/csw/lib $LDFLAGS"
195 export PYTHON
="python3"
196 export PYTHON_CONFIG
="python3-config"
204 export NPROC
="getconf _NPROCESSORS_ONLN"
205 export PATH
="/opt/local/bin:/opt/local/sbin:$PATH"
206 export CPPFLAGS
="-I/opt/local/include $CPPFLAGS"
207 export LDFLAGS
="-L/opt/local/lib $LDFLAGS"
208 export PYTHON
="python3"
209 export PYTHON_CONFIG
="python3-config"
214 cygwin|cygwin64|msys32|msys64
)
232 P2_VERSION
=$
($PYTHON2 -c "import sys;print(sys.version[:3])")
233 P3_VERSION
=$
($PYTHON3 -c "import sys;print(sys.version[:3])")
235 DEPS_PYTHON2
="$WORKSPACE/deps/build/lib/python$P2_VERSION/site-packages"
236 DEPS_PYTHON3
="$WORKSPACE/deps/build/lib/python$P3_VERSION/site-packages"
242 RUN_TESTS_LONG_REGRESSION
="yes"
245 RUN_TESTS_LONG_REGRESSION
="no"
249 # Enter the source directory
252 # Run bootstrap in the source directory prior to configure
255 # Get source version from configure script
256 eval "$(grep '^PACKAGE_VERSION=' ./configure)"
257 PACKAGE_VERSION
=${PACKAGE_VERSION//\-pre*/}
260 # The switch to build without UST changed in 2.8
261 if vergte
"$PACKAGE_VERSION" "2.8"; then
262 NO_UST
="--without-lttng-ust"
264 NO_UST
="--disable-lttng-ust"
267 # Most build configs require the python bindings
268 CONF_OPTS
=("--prefix=$PREFIX" "--enable-python-bindings")
270 # Set configure options and environment variables for each build
274 echo "Static lib only configuration"
276 CONF_OPTS
+=("--enable-static" "--disable-shared")
280 echo "Build without UST support"
281 CONF_OPTS
+=("$NO_UST")
285 echo "Java and Python agents configuration"
287 export JAVA_HOME
="/usr/lib/jvm/default-java"
288 export CLASSPATH
="$DEPS_JAVA/*:/usr/share/java/*"
289 export PYTHONPATH
="$DEPS_PYTHON2:$DEPS_PYTHON3"
291 CONF_OPTS
+=("--enable-test-java-agent-all" "--enable-test-python-agent-all")
295 echo "Relayd only configuration"
297 CONF_OPTS
=("--prefix=$PREFIX" "--disable-bin-lttng" "--disable-bin-lttng-consumerd" "--disable-bin-lttng-crash" "--disable-bin-lttng-sessiond" "--disable-extras" "--disable-man-pages" "$NO_UST")
301 echo "Enable RCU sanity checks for debugging"
303 export CPPFLAGS
="$CPPFLAGS -DDEBUG_RCU"
307 echo "Standard configuration"
312 # oot : out-of-tree build
313 # dist : build via make dist
314 # oot-dist: build via make dist out-of-tree
315 # * : normal tree build
317 # Make sure to move to the build directory and run configure
321 echo "Out of tree build"
323 # Create and enter a temporary build directory
324 builddir
=$
(mktemp
-d)
327 "$SRCDIR/configure" "${CONF_OPTS[@]}"
331 echo "Distribution in-tree build"
333 # Run configure and generate the tar file
334 # in the source directory
338 # Create and enter a temporary build directory
339 builddir
=$
(mktemp
-d)
342 # Extract the distribution tar in the build directory,
343 # ignore the first directory level
344 $TAR xvf
"$SRCDIR"/*.
tar.
* --strip 1
346 # Build in extracted source tree
347 .
/configure
"${CONF_OPTS[@]}"
351 echo "Distribution out of tree build"
353 # Create and enter a temporary build directory
354 builddir
=$
(mktemp
-d)
357 # Run configure out of tree and generate the tar file
361 dist_srcdir
="$(mktemp -d)"
364 # Extract the distribution tar in the new source directory,
365 # ignore the first directory level
366 $TAR xvf
"$builddir"/*.
tar.
* --strip 1
368 # Create and enter a second temporary build directory
369 builddir
="$(mktemp -d)"
372 # Run configure from the extracted distribution tar,
373 # out of the source tree
374 "$dist_srcdir/configure" "${CONF_OPTS[@]}"
378 echo "Standard in-tree build"
379 .
/configure
"${CONF_OPTS[@]}"
383 # We are now inside a configured build directory
386 $MAKE -j "$($NPROC)" V
=1
388 # Install in the workspace
389 $MAKE install DESTDIR
="$WORKSPACE"
391 # Run tests for all configs except 'no-ust'
393 if [ "$RUN_TESTS" = "yes" ] && [ "$conf" != "no-ust" ]; then
397 # Force the lttng-sessiond path to /bin/true to prevent the spawing of a
398 # lttng-sessiond --daemonize on "lttng create"
399 export LTTNG_SESSIOND_PATH
="/bin/true"
401 # Run 'unit_tests', 2.8 and up has a new test suite
402 if vergte
"$PACKAGE_VERSION" "2.8"; then
403 make --keep-going check || failed_tests
=1
404 rsync
-a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests
/ "$TAPDIR"
407 mkdir
-p "$TAPDIR/unit"
408 mkdir
-p "$TAPDIR/fast_regression"
409 mkdir
-p "$TAPDIR/with_bindings_regression"
410 prove
--merge -v --exec '' - < unit_tests
--archive "$TAPDIR/unit/" || failed_tests
=1
411 prove
--merge -v --exec '' - < fast_regression
--archive "$TAPDIR/fast_regression/" || failed_tests
=1
412 prove
--merge -v --exec '' - < with_bindings_regression
--archive "$TAPDIR/with_bindings_regression/" || failed_tests
=1
416 if [ "$RUN_TESTS_LONG_REGRESSION" = "yes" ]; then
418 mkdir
-p "$TAPDIR/long_regression"
419 prove
--merge -v --exec '' - < long_regression
--archive "$TAPDIR/long_regression/" || failed_tests
=1
423 # TAP plugin is having a hard time with .yml files.
424 find "$TAPDIR" -name "meta.yml" -exec rm -f {} \
;
426 # The TAP plugin will fail the job if no test logs are present
427 mkdir
-p "$TAPDIR/no-tests"
428 echo "1..1" > "$TAPDIR/no-tests/tests.log"
429 echo "ok 1 - Test suite disabled" >> "$TAPDIR/no-tests/tests.log"
432 # Clean the build directory
435 # Cleanup rpath in executables and shared libraries
436 find "$WORKSPACE/$PREFIX/bin" -type f
-perm -0500 -exec chrpath
--delete {} \
;
437 find "$WORKSPACE/$PREFIX/lib" -name "*.so" -exec chrpath
--delete {} \
;
439 # Remove libtool .la files
440 find "$WORKSPACE/$PREFIX/lib" -name "*.la" -exec rm -f {} \
;
442 # Exit with failure if any of the tests failed