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 local i ver1
=($1) ver2
=($2)
30 # fill empty fields in ver1 with zeros
31 for ((i
=${#ver1[@]}; i
<${#ver2[@]}; i
++)); do
34 for ((i
=0; i
<${#ver1[@]}; i
++)); do
35 if [[ -z ${ver2[i]} ]]; then
36 # fill empty fields in ver2 with zeros
39 if ((10#${ver1[i]} > 10#${ver2[i]})); then
42 if ((10#${ver1[i]} < 10#${ver2[i]})); then
51 vercomp
"$1" "$2"; local res
="$?"
52 [ "$res" -eq "0" ] ||
[ "$res" -eq "2" ]
56 vercomp
"$1" "$2"; local res
="$?"
61 vercomp
"$1" "$2"; local res
="$?"
62 [ "$res" -eq "0" ] ||
[ "$res" -eq "1" ]
66 vercomp
"$1" "$2"; local res
="$?"
71 vercomp
"$1" "$2"; local res
="$?"
76 # Assume we are in the configured build directory
77 echo "#################### BEGIN config.log ####################"
79 echo "#################### END config.log ####################"
81 # End the build with failure
85 set_execute_traversal_bit
()
90 if [ ! -d "$path" ]; then
91 fail
"Path is not a directory"
93 while level
="$(dirname "$level")"
95 if [ "$level" = / ]; then
104 WORKSPACE
=${WORKSPACE:-}
106 platform
=${platform:-}
110 test_type
=${test_type:-}
112 DEPS_INC
="$WORKSPACE/deps/build/include"
113 DEPS_LIB
="$WORKSPACE/deps/build/lib"
114 DEPS_PKGCONFIG
="$DEPS_LIB/pkgconfig"
115 DEPS_BIN
="$WORKSPACE/deps/build/bin"
116 DEPS_JAVA
="$WORKSPACE/deps/build/share/java"
118 export PATH
="$DEPS_BIN:$PATH"
119 export LD_LIBRARY_PATH
="$DEPS_LIB:${LD_LIBRARY_PATH:-}"
120 export PKG_CONFIG_PATH
="$DEPS_PKGCONFIG"
121 export CPPFLAGS
="-I$DEPS_INC"
122 export LDFLAGS
="-L$DEPS_LIB"
124 SRCDIR
="$WORKSPACE/src/lttng-tools"
125 TAPDIR
="$WORKSPACE/tap"
129 # Create tmp directory
130 TMPDIR
="$WORKSPACE/tmp"
133 # Use a symlink in /tmp to point to the the tmp directory
134 # inside the workspace, this is to work around the path length
135 # limit of unix sockets which are created by the test suite.
137 ln -sf "$TMPDIR" "$tmpdir"
138 export TMPDIR
="$tmpdir"
140 # Create a symlink to "babeltrace" when the "babeltrace2" executable is found.
141 # This is a temporary workaround until lttng-tools either allows the override of
142 # the trace reader in its test suite or that we move to only supporting
144 if [ -x "$DEPS_BIN/babeltrace2" ]; then
145 ln -s "$DEPS_BIN/babeltrace2" "$DEPS_BIN/babeltrace"
148 # When using babeltrace2 make sure that it finds its plugins and
150 export BABELTRACE_PLUGIN_PATH
="$DEPS_LIB/babeltrace2/plugins/"
151 export LIBBABELTRACE2_PLUGIN_PROVIDER_DIR
="$DEPS_LIB/babeltrace2/plugin-providers/"
153 export CFLAGS
="-g -O2"
154 export CXXFLAGS
="-g -O2"
156 # Set compiler variables
188 export CXX
=clang
++-3.9
192 export CXX
=clang
++-4.0
196 export CXX
=clang
++-5.0
200 export CXX
=clang
++-6.0
207 if [ "x$cc" != "x" ]; then
213 if [ "x${CC:-}" != "x" ]; then
214 echo "Selected compiler:"
218 # Set platform variables
223 export NPROC
="getconf _NPROCESSORS_ONLN"
224 export PATH
="/opt/local/bin:/opt/local/sbin:$PATH"
225 export CPPFLAGS
="-I/opt/local/include $CPPFLAGS"
226 export LDFLAGS
="-L/opt/local/lib $LDFLAGS"
227 export PYTHON
="python3"
228 export PYTHON_CONFIG
="python3-config"
230 LTTNG_TOOLS_RUN_TESTS
="no"
233 cygwin|cygwin64|msys32|msys64
)
238 LTTNG_TOOLS_RUN_TESTS
="no"
246 LTTNG_TOOLS_RUN_TESTS
="yes"
251 if command -v $PYTHON2 >/dev
/null
2>&1; then
252 P2_VERSION
=$
($PYTHON2 -c 'import sys;v = sys.version.split()[0].split("."); print("{}.{}".format(v[0], v[1]))')
253 DEPS_PYTHON2
="$WORKSPACE/deps/build/lib/python$P2_VERSION/site-packages"
256 P3_VERSION
=$
($PYTHON3 -c 'import sys;v = sys.version.split()[0].split("."); print("{}.{}".format(v[0], v[1]))')
257 DEPS_PYTHON3
="$WORKSPACE/deps/build/lib/python$P3_VERSION/site-packages"
259 # Most build configs require access to the babeltrace 2 python bindings.
260 # This also makes the lttngust python agent available for `agents` builds.
261 export PYTHONPATH
="${DEPS_PYTHON2:-}${DEPS_PYTHON2:+:}$DEPS_PYTHON3"
265 # The missing-field-initializers warning code is very dumb in GCC 4.8 on
266 # SLES12, disable it even if it's available.
267 if [[ $platform = sles12sp5
* ]]; then
268 CFLAGS
="$CFLAGS -Wno-missing-field-initializers"
269 CXXFLAGS
="$CXXFLAGS -Wno-missing-field-initializers"
274 LTTNG_TOOLS_RUN_TESTS_LONG_REGRESSION
="yes"
277 LTTNG_TOOLS_RUN_TESTS_LONG_REGRESSION
="no"
281 # If we have modules, build them
282 if [ -d "$WORKSPACE/src/lttng-modules" ]; then
283 cd "$WORKSPACE/src/lttng-modules"
284 $MAKE -j"$($NPROC)" V
=1
285 $MAKE modules_install V
=1
289 # Print build env details
291 print_tooling || true
293 # Enter the source directory
296 # Run bootstrap in the source directory prior to configure
299 # Get source version from configure script
300 eval "$(grep '^PACKAGE_VERSION=' ./configure)"
301 PACKAGE_VERSION
=${PACKAGE_VERSION//\-pre*/}
304 # The switch to build without UST changed in 2.8
305 if vergte
"$PACKAGE_VERSION" "2.8"; then
306 NO_UST
="--without-lttng-ust"
308 NO_UST
="--disable-lttng-ust"
311 # Most build configs require the python bindings
312 CONF_OPTS
=("--prefix=$PREFIX" "--enable-python-bindings")
316 # Set configure options and environment variables for each build
320 echo "Static lib only configuration"
322 CONF_OPTS
+=("--enable-static" "--disable-shared")
326 echo "Build without UST support"
327 CONF_OPTS
+=("$NO_UST")
328 DIST_CONF_OPTS
+=("$NO_UST")
332 echo "Java and Python agents configuration"
334 export JAVA_HOME
="/usr/lib/jvm/default-java"
335 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"
337 CONF_OPTS
+=("--enable-test-java-agent-all" "--enable-test-python-agent-all")
339 # Explicitly add '--enable-test-java-agent-log4j2', it's not part of '-all' in stable 2.12/2.13
340 if verlt
"$PACKAGE_VERSION" "2.14"; then
341 CONF_OPTS
+=("--enable-test-java-agent-log4j2")
346 echo "Relayd only configuration"
348 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")
352 echo "Enable RCU sanity checks for debugging"
354 export CPPFLAGS
="$CPPFLAGS -DDEBUG_RCU"
358 echo "Standard configuration"
363 # oot : out-of-tree build
364 # dist : build via make dist
365 # oot-dist: build via make dist out-of-tree
366 # * : normal tree build
368 # Make sure to move to the build directory and run configure
372 echo "Out of tree build"
374 # Create and enter a temporary build directory
375 builddir
=$
(mktemp
-d)
378 "$SRCDIR/configure" "${CONF_OPTS[@]}" || failed_configure
382 echo "Distribution in-tree build"
384 # Run configure and generate the tar file
385 # in the source directory
386 .
/configure
"${DIST_CONF_OPTS[@]}" || failed_configure
389 # Create and enter a temporary build directory
390 builddir
=$
(mktemp
-d)
393 # Extract the distribution tar in the build directory,
394 # ignore the first directory level
395 $TAR xvf
"$SRCDIR"/*.
tar.
* --strip 1
397 # Build in extracted source tree
398 .
/configure
"${CONF_OPTS[@]}" || failed_configure
402 echo "Distribution out of tree build"
404 # Create and enter a temporary build directory
405 builddir
=$
(mktemp
-d)
408 # Run configure out of tree and generate the tar file
409 "$SRCDIR/configure" "${DIST_CONF_OPTS[@]}" || failed_configure
412 dist_srcdir
="$(mktemp -d)"
415 # Extract the distribution tar in the new source directory,
416 # ignore the first directory level
417 $TAR xvf
"$builddir"/*.
tar.
* --strip 1
419 # Create and enter a second temporary build directory
420 builddir
="$(mktemp -d)"
423 # Run configure from the extracted distribution tar,
424 # out of the source tree
425 "$dist_srcdir/configure" "${CONF_OPTS[@]}" || failed_configure
429 echo "Standard in-tree build"
430 .
/configure
"${CONF_OPTS[@]}" || failed_configure
434 # We are now inside a configured build directory
437 $MAKE -j "$($NPROC)" V
=1
439 # Install in the workspace
440 $MAKE install DESTDIR
="$WORKSPACE"
442 # Run tests for all configs except 'no-ust'
444 if [ "$LTTNG_TOOLS_RUN_TESTS" = "yes" ] && [ "$conf" != "no-ust" ]; then
448 # Force the lttng-sessiond path to /bin/true to prevent the spawing of a
449 # lttng-sessiond --daemonize on "lttng create"
450 export LTTNG_SESSIOND_PATH
="/bin/true"
452 # Run 'unit_tests', 2.8 and up has a new test suite
453 if vergte
"$PACKAGE_VERSION" "2.8"; then
454 # It is implied that tests depending on LTTNG_ENABLE_DESTRUCTIVE_TESTS
455 # only run for the root user. Note that here `destructive` means that
456 # operations are performed at the host level (add user etc.) that
457 # effectively modify the host. Running those tests are acceptable on our
458 # CI and root jobs since we always run root tests against a `snapshot`
460 if [ "$(id -u)" == "0" ]; then
461 # Allow the traversal of all directories leading to the
462 # DEPS_LIBS directory to enable test app run by temp users to
464 set_execute_traversal_bit
"$DEPS_LIB"
465 # Allow `all` to interact with all deps libs.
466 chmod a
+rwx
-R "$DEPS_LIB"
468 export LTTNG_ENABLE_DESTRUCTIVE_TESTS
="will-break-my-system"
470 # Some destructive tests play with the system clock, disable timesyncd
471 systemctl stop systemd-timesyncd.service || true
474 make --keep-going check || failed_tests
=1
475 rsync
-a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests
/ "$TAPDIR"
478 mkdir
-p "$TAPDIR/unit"
479 mkdir
-p "$TAPDIR/fast_regression"
480 mkdir
-p "$TAPDIR/with_bindings_regression"
481 prove
--merge -v --exec '' - < unit_tests
--archive "$TAPDIR/unit/" || failed_tests
=1
482 prove
--merge -v --exec '' - < fast_regression
--archive "$TAPDIR/fast_regression/" || failed_tests
=1
483 prove
--merge -v --exec '' - < with_bindings_regression
--archive "$TAPDIR/with_bindings_regression/" || failed_tests
=1
487 if [ "$LTTNG_TOOLS_RUN_TESTS_LONG_REGRESSION" = "yes" ]; then
489 mkdir
-p "$TAPDIR/long_regression"
490 prove
--merge -v --exec '' - < long_regression
--archive "$TAPDIR/long_regression/" || failed_tests
=1
494 # TAP plugin is having a hard time with .yml files.
495 find "$TAPDIR" -name "meta.yml" -exec rm -f {} \
;
497 # The TAP plugin will fail the job if no test logs are present
498 mkdir
-p "$TAPDIR/no-tests"
499 echo "1..1" > "$TAPDIR/no-tests/tests.log"
500 echo "ok 1 - Test suite disabled" >> "$TAPDIR/no-tests/tests.log"
503 # Clean the build directory
506 # Cleanup rpath in executables
507 find "$WORKSPACE/$PREFIX/bin" -type f
-perm -0500 -exec chrpath
--delete {} \
;
509 # Some configs don't build liblttng-ctl
510 if [ -d "$WORKSPACE/$PREFIX/lib" ]; then
511 # Cleanup rpath in shared libraries
512 find "$WORKSPACE/$PREFIX/lib" -name "*.so" -exec chrpath
--delete {} \
;
513 # Remove libtool .la files
514 find "$WORKSPACE/$PREFIX/lib" -name "*.la" -exec rm -f {} \
;
517 # Exit with failure if any of the tests failed