2 # shellcheck disable=SC2103
4 # Copyright (C) 2016 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
5 # Copyright (C) 2016-2020 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/>.
22 # Version compare functions
25 if [[ "$1" == "$2" ]]; then
29 # Ignore the shellcheck warning, we want splitting to happen based on IFS.
30 # shellcheck disable=SC2206
31 local i ver1
=($1) ver2
=($2)
32 # fill empty fields in ver1 with zeros
33 for ((i
=${#ver1[@]}; i
<${#ver2[@]}; i
++)); do
36 for ((i
=0; i
<${#ver1[@]}; i
++)); do
37 if [[ -z ${ver2[i]} ]]; then
38 # fill empty fields in ver2 with zeros
41 if ((10#${ver1[i]} > 10#${ver2[i]})); then
44 if ((10#${ver1[i]} < 10#${ver2[i]})); then
53 vercomp
"$1" "$2"; local res
="$?"
54 [ "$res" -eq "0" ] ||
[ "$res" -eq "2" ]
58 vercomp
"$1" "$2"; local res
="$?"
63 vercomp
"$1" "$2"; local res
="$?"
64 [ "$res" -eq "0" ] ||
[ "$res" -eq "1" ]
68 vercomp
"$1" "$2"; local res
="$?"
73 vercomp
"$1" "$2"; local res
="$?"
78 # Assume we are in the configured build directory
79 echo "#################### BEGIN config.log ####################"
81 echo "#################### END config.log ####################"
83 # End the build with failure
87 set_execute_traversal_bit
()
92 if [ ! -d "$path" ]; then
93 fail
"Path is not a directory"
95 while level
="$(dirname "$level")"
97 if [ "$level" = / ]; then
106 WORKSPACE
=${WORKSPACE:-}
108 platform
=${platform:-}
112 test_type
=${test_type:-}
114 SRCDIR
="$WORKSPACE/src/lttng-tools"
115 TAPDIR
="$WORKSPACE/tap"
118 LIBDIR_ARCH
="$LIBDIR"
120 # RHEL and SLES both use lib64 but don't bother shipping a default autoconf
121 # site config that matches this.
122 if [[ ( -f /etc
/redhat-release ||
-f /etc
/products.d
/SLES.prod ||
-f /etc
/yocto-release
) ]]; then
123 # Detect the userspace bitness in a distro agnostic way
124 if file -L /bin
/bash |
grep '64-bit' >/dev
/null
2>&1; then
125 LIBDIR_ARCH
="${LIBDIR}64"
129 DEPS_INC
="$WORKSPACE/deps/build/include"
130 DEPS_LIB
="$WORKSPACE/deps/build/$LIBDIR_ARCH"
131 DEPS_PKGCONFIG
="$DEPS_LIB/pkgconfig"
132 DEPS_BIN
="$WORKSPACE/deps/build/bin"
133 DEPS_JAVA
="$WORKSPACE/deps/build/share/java"
135 export PATH
="$DEPS_BIN:$PATH"
136 export LD_LIBRARY_PATH
="$DEPS_LIB:${LD_LIBRARY_PATH:-}"
137 export PKG_CONFIG_PATH
="$DEPS_PKGCONFIG"
138 export CPPFLAGS
="-I$DEPS_INC"
139 export LDFLAGS
="-L$DEPS_LIB"
142 # Create tmp directory
143 TMPDIR
="$WORKSPACE/tmp"
146 # Use a symlink in /tmp to point to the the tmp directory
147 # inside the workspace, this is to work around the path length
148 # limit of unix sockets which are created by the test suite.
150 ln -sf "$TMPDIR" "$tmpdir"
151 export TMPDIR
="$tmpdir"
153 # Create a symlink to "babeltrace" when the "babeltrace2" executable is found.
154 # This is a temporary workaround until lttng-tools either allows the override of
155 # the trace reader in its test suite or that we move to only supporting
157 if [ -x "$DEPS_BIN/babeltrace2" ]; then
158 ln -s "$DEPS_BIN/babeltrace2" "$DEPS_BIN/babeltrace"
161 # When using babeltrace2 make sure that it finds its plugins and
163 export BABELTRACE_PLUGIN_PATH
="$DEPS_LIB/babeltrace2/plugins/"
164 export LIBBABELTRACE2_PLUGIN_PROVIDER_DIR
="$DEPS_LIB/babeltrace2/plugin-providers/"
166 export CFLAGS
="-g -O2"
167 export CXXFLAGS
="-g -O2"
169 # Set compiler variables
201 export CXX
=clang
++-3.9
205 export CXX
=clang
++-4.0
209 export CXX
=clang
++-5.0
213 export CXX
=clang
++-6.0
220 if [ "x$cc" != "x" ]; then
226 if [ "x${CC:-}" != "x" ]; then
227 echo "Selected compiler:"
231 # Set platform variables
236 export NPROC
="getconf _NPROCESSORS_ONLN"
237 export PATH
="/opt/local/bin:/opt/local/sbin:$PATH"
238 export CPPFLAGS
="-I/opt/local/include $CPPFLAGS"
239 export LDFLAGS
="-L/opt/local/lib $LDFLAGS"
240 export PYTHON
="python3"
241 export PYTHON_CONFIG
="python3-config"
243 LTTNG_TOOLS_RUN_TESTS
="no"
246 cygwin|cygwin64|msys32|msys64
)
251 LTTNG_TOOLS_RUN_TESTS
="no"
259 LTTNG_TOOLS_RUN_TESTS
="yes"
264 if command -v $PYTHON2 >/dev
/null
2>&1; then
265 P2_VERSION
=$
($PYTHON2 -c 'import sys;v = sys.version.split()[0].split("."); print("{}.{}".format(v[0], v[1]))')
266 DEPS_PYTHON2
="$WORKSPACE/deps/build/$LIBDIR/python$P2_VERSION/site-packages"
267 if [ "$LIBDIR" != "$LIBDIR_ARCH" ]; then
268 DEPS_PYTHON2
="$DEPS_PYTHON2:$WORKSPACE/deps/build/$LIBDIR_ARCH/python$P2_VERSION/site-packages"
272 P3_VERSION
=$
($PYTHON3 -c 'import sys;v = sys.version.split()[0].split("."); print("{}.{}".format(v[0], v[1]))')
273 DEPS_PYTHON3
="$WORKSPACE/deps/build/$LIBDIR/python$P3_VERSION/site-packages"
274 if [ "$LIBDIR" != "$LIBDIR_ARCH" ]; then
275 DEPS_PYTHON3
="$DEPS_PYTHON3:$WORKSPACE/deps/build/$LIBDIR_ARCH/python$P3_VERSION/site-packages"
278 # Most build configs require access to the babeltrace 2 python bindings.
279 # This also makes the lttngust python agent available for `agents` builds.
280 export PYTHONPATH
="${DEPS_PYTHON2:-}${DEPS_PYTHON2:+:}$DEPS_PYTHON3"
284 # Some warning flags are very dumb in GCC 4.8 on SLES12 / EL7, disable them
285 # even if they are available.
286 if [[ $platform = sles12sp5
* ]] ||
[[ $platform = el7
* ]]; then
287 CFLAGS
="$CFLAGS -Wno-missing-field-initializers -Wno-shadow"
288 CXXFLAGS
="$CXXFLAGS -Wno-missing-field-initializers -Wno-shadow"
293 LTTNG_TOOLS_RUN_TESTS_LONG_REGRESSION
="yes"
296 LTTNG_TOOLS_RUN_TESTS_LONG_REGRESSION
="no"
300 # If we have modules, build them
301 if [ -d "$WORKSPACE/src/lttng-modules" ]; then
302 cd "$WORKSPACE/src/lttng-modules"
303 $MAKE -j"$($NPROC)" V
=1
304 $MAKE modules_install V
=1
308 # Print build env details
310 print_tooling || true
312 # Enter the source directory
315 # Run bootstrap in the source directory prior to configure
318 # Get source version from configure script
319 eval "$(grep '^PACKAGE_VERSION=' ./configure)"
320 PACKAGE_VERSION
=${PACKAGE_VERSION//\-pre*/}
323 # The switch to build without UST changed in 2.8
324 if vergte
"$PACKAGE_VERSION" "2.8"; then
325 NO_UST
="--without-lttng-ust"
327 NO_UST
="--disable-lttng-ust"
330 # Most build configs require the python bindings
331 CONF_OPTS
=("--prefix=$PREFIX" "--libdir=$PREFIX/$LIBDIR_ARCH" "--enable-python-bindings")
335 # Set configure options and environment variables for each build
339 echo "Static lib only configuration"
341 CONF_OPTS
+=("--enable-static" "--disable-shared")
345 echo "Build without UST support"
346 CONF_OPTS
+=("$NO_UST")
347 DIST_CONF_OPTS
+=("$NO_UST")
351 echo "Java and Python agents configuration"
353 export JAVA_HOME
="/usr/lib/jvm/default-java"
354 export CLASSPATH
="$DEPS_JAVA/lttng-ust-agent-all.jar:/usr/share/java/log4j-api.jar:/usr/share/java/log4j-core.jar:/usr/share/java/log4j-1.2.jar"
356 CONF_OPTS
+=("--enable-test-java-agent-all")
358 # Explicitly add '--enable-test-java-agent-log4j2', it's not part of '-all' in stable 2.12/2.13
359 if verlt
"$PACKAGE_VERSION" "2.14"; then
360 CONF_OPTS
+=("--enable-test-java-agent-log4j2")
363 # Some distros don't ship python2 anymore
364 if command -v $PYTHON2 >/dev
/null
2>&1; then
365 CONF_OPTS
+=("--enable-test-python-agent-all")
367 CONF_OPTS
+=("--enable-test-python3-agent")
372 echo "Relayd only configuration"
374 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")
378 echo "Enable RCU sanity checks for debugging"
380 export CPPFLAGS
="$CPPFLAGS -DDEBUG_RCU"
384 echo "Standard configuration"
386 # Something is broken in docbook-xml on yocto
387 if [[ "$platform" = yocto
* ]]; then
388 CONF_OPTS
+=("--disable-man-pages")
394 # oot : out-of-tree build
395 # dist : build via make dist
396 # oot-dist: build via make dist out-of-tree
397 # * : normal tree build
399 # Make sure to move to the build directory and run configure
403 echo "Out of tree build"
405 # Create and enter a temporary build directory
406 builddir
=$
(mktemp
-d)
409 "$SRCDIR/configure" "${CONF_OPTS[@]}" || failed_configure
413 echo "Distribution in-tree build"
415 # Run configure and generate the tar file
416 # in the source directory
417 .
/configure
"${DIST_CONF_OPTS[@]}" || failed_configure
420 # Create and enter a temporary build directory
421 builddir
=$
(mktemp
-d)
424 # Extract the distribution tar in the build directory,
425 # ignore the first directory level
426 $TAR xvf
"$SRCDIR"/*.
tar.
* --strip 1
428 # Build in extracted source tree
429 .
/configure
"${CONF_OPTS[@]}" || failed_configure
433 echo "Distribution out of tree build"
435 # Create and enter a temporary build directory
436 builddir
=$
(mktemp
-d)
439 # Run configure out of tree and generate the tar file
440 "$SRCDIR/configure" "${DIST_CONF_OPTS[@]}" || failed_configure
443 dist_srcdir
="$(mktemp -d)"
446 # Extract the distribution tar in the new source directory,
447 # ignore the first directory level
448 $TAR xvf
"$builddir"/*.
tar.
* --strip 1
450 # Create and enter a second temporary build directory
451 builddir
="$(mktemp -d)"
454 # Run configure from the extracted distribution tar,
455 # out of the source tree
456 "$dist_srcdir/configure" "${CONF_OPTS[@]}" || failed_configure
460 echo "Standard in-tree build"
461 .
/configure
"${CONF_OPTS[@]}" || failed_configure
465 # We are now inside a configured build directory
468 $MAKE -j "$($NPROC)" V
=1
470 # Install in the workspace
471 $MAKE install DESTDIR
="$WORKSPACE"
473 # Run tests for all configs except 'no-ust'
475 if [ "$LTTNG_TOOLS_RUN_TESTS" = "yes" ] && [ "$conf" != "no-ust" ]; then
479 # Force the lttng-sessiond path to /bin/true to prevent the spawing of a
480 # lttng-sessiond --daemonize on "lttng create"
481 export LTTNG_SESSIOND_PATH
="/bin/true"
483 # Run 'unit_tests', 2.8 and up has a new test suite
484 if vergte
"$PACKAGE_VERSION" "2.8"; then
485 # It is implied that tests depending on LTTNG_ENABLE_DESTRUCTIVE_TESTS
486 # only run for the root user. Note that here `destructive` means that
487 # operations are performed at the host level (add user etc.) that
488 # effectively modify the host. Running those tests are acceptable on our
489 # CI and root jobs since we always run root tests against a `snapshot`
491 if [ "$(id -u)" == "0" ]; then
492 # Allow the traversal of all directories leading to the
493 # DEPS_LIBS directory to enable test app run by temp users to
495 set_execute_traversal_bit
"$DEPS_LIB"
496 # Allow `all` to interact with all deps libs.
497 chmod a
+rwx
-R "$DEPS_LIB"
499 export LTTNG_ENABLE_DESTRUCTIVE_TESTS
="will-break-my-system"
501 # Some destructive tests play with the system clock, disable timesyncd
502 systemctl stop systemd-timesyncd.service || true
505 make --keep-going check || failed_tests
=1
507 # Copy tap logs for the jenkins tap parser before cleaning the build dir
508 rsync
-a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests
/ "$TAPDIR"
510 # Copy the test suites top-level log which includes all tests failures
511 rsync
-a --include 'test-suite.log' --include '*/' --exclude='*' tests
/ "$WORKSPACE/log"
514 mkdir
-p "$TAPDIR/unit"
515 mkdir
-p "$TAPDIR/fast_regression"
516 mkdir
-p "$TAPDIR/with_bindings_regression"
517 prove
--merge -v --exec '' - < unit_tests
--archive "$TAPDIR/unit/" || failed_tests
=1
518 prove
--merge -v --exec '' - < fast_regression
--archive "$TAPDIR/fast_regression/" || failed_tests
=1
519 prove
--merge -v --exec '' - < with_bindings_regression
--archive "$TAPDIR/with_bindings_regression/" || failed_tests
=1
523 if [ "$LTTNG_TOOLS_RUN_TESTS_LONG_REGRESSION" = "yes" ]; then
525 mkdir
-p "$TAPDIR/long_regression"
526 prove
--merge -v --exec '' - < long_regression
--archive "$TAPDIR/long_regression/" || failed_tests
=1
530 # TAP plugin is having a hard time with .yml files.
531 find "$TAPDIR" -name "meta.yml" -exec rm -f {} \
;
533 # The TAP plugin will fail the job if no test logs are present
534 mkdir
-p "$TAPDIR/no-tests"
535 echo "1..1" > "$TAPDIR/no-tests/tests.log"
536 echo "ok 1 - Test suite disabled" >> "$TAPDIR/no-tests/tests.log"
539 # Clean the build directory
542 # Cleanup rpath in executables
543 find "$WORKSPACE/$PREFIX/bin" -type f
-perm -0500 -exec chrpath
--delete {} \
;
545 # Some configs don't build liblttng-ctl
546 if [ -d "$WORKSPACE/$PREFIX/$LIBDIR_ARCH" ]; then
547 # Cleanup rpath in shared libraries
548 find "$WORKSPACE/$PREFIX/$LIBDIR_ARCH" -name "*.so" -exec chrpath
--delete {} \
;
549 # Remove libtool .la files
550 find "$WORKSPACE/$PREFIX/$LIBDIR_ARCH" -name "*.la" -exec rm -f {} \
;
553 # Exit with failure if any of the tests failed