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
86 WORKSPACE
=${WORKSPACE:-}
92 test_type
=${test_type:-}
94 DEPS_INC
="$WORKSPACE/deps/build/include"
95 DEPS_LIB
="$WORKSPACE/deps/build/lib"
96 DEPS_PKGCONFIG
="$DEPS_LIB/pkgconfig"
97 DEPS_BIN
="$WORKSPACE/deps/build/bin"
98 DEPS_JAVA
="$WORKSPACE/deps/build/share/java"
100 export PATH
="$DEPS_BIN:$PATH"
101 export LD_LIBRARY_PATH
="$DEPS_LIB:${LD_LIBRARY_PATH:-}"
102 export PKG_CONFIG_PATH
="$DEPS_PKGCONFIG"
103 export CPPFLAGS
="-I$DEPS_INC"
104 export LDFLAGS
="-L$DEPS_LIB"
106 SRCDIR
="$WORKSPACE/src/lttng-tools"
107 TAPDIR
="$WORKSPACE/tap"
111 # Create tmp directory
112 TMPDIR
="$WORKSPACE/tmp"
115 # Use a symlink in /tmp to point to the the tmp directory
116 # inside the workspace, this is to work around the path length
117 # limit of unix sockets which are created by the test suite.
119 ln -sf "$TMPDIR" "$tmpdir"
120 export TMPDIR
="$tmpdir"
122 # Create a symlink to "babeltrace" when the "babeltrace2" executable is found.
123 # This is a temporary workaround until lttng-tools either allows the override of
124 # the trace reader in its test suite or that we move to only supporting
126 if [ -x "$DEPS_BIN/babeltrace2" ]; then
127 ln -s "$DEPS_BIN/babeltrace2" "$DEPS_BIN/babeltrace"
130 # When using babeltrace2 make sure that it finds its plugins and
132 export BABELTRACE_PLUGIN_PATH
="$DEPS_LIB/babeltrace2/plugins/"
133 export LIBBABELTRACE2_PLUGIN_PROVIDER_DIR
="$DEPS_LIB/babeltrace2/plugin-providers/"
135 export CFLAGS
="-g -O2"
137 # Set compiler variables
169 export CXX
=clang
++-3.9
173 export CXX
=clang
++-4.0
177 export CXX
=clang
++-5.0
181 export CXX
=clang
++-6.0
188 if [ "x$cc" != "x" ]; then
194 if [ "x${CC:-}" != "x" ]; then
195 echo "Selected compiler:"
199 # Set platform variables
205 export PATH
="/opt/csw/bin:/usr/ccs/bin:$PATH"
206 export CPPFLAGS
="-I/opt/csw/include -D_XOPEN_SOURCE=500 $CPPFLAGS"
207 export LDFLAGS
="-L/opt/csw/lib -R/opt/csw/lib $LDFLAGS"
208 export PKG_CONFIG_PATH
="$PKG_CONFIG_PATH:/opt/csw/lib/pkgconfig"
209 export PYTHON
="python3"
210 export PYTHON_CONFIG
="python3-config"
219 export PATH
="/opt/csw/bin:$PATH:/usr/perl5/bin"
220 export CPPFLAGS
="-D_XOPEN_SOURCE=500 $CPPFLAGS"
221 export PYTHON
="python3"
222 export PYTHON_CONFIG
="python3-config"
223 export PKG_CONFIG_PATH
="$PKG_CONFIG_PATH:/usr/lib/pkgconfig"
231 export NPROC
="getconf _NPROCESSORS_ONLN"
232 export PATH
="/opt/local/bin:/opt/local/sbin:$PATH"
233 export CPPFLAGS
="-I/opt/local/include $CPPFLAGS"
234 export LDFLAGS
="-L/opt/local/lib $LDFLAGS"
235 export PYTHON
="python3"
236 export PYTHON_CONFIG
="python3-config"
241 cygwin|cygwin64|msys32|msys64
)
259 P2_VERSION
=$
($PYTHON2 -c "import sys;print(sys.version[:3])")
260 P3_VERSION
=$
($PYTHON3 -c "import sys;print(sys.version[:3])")
262 DEPS_PYTHON2
="$WORKSPACE/deps/build/lib/python$P2_VERSION/site-packages"
263 DEPS_PYTHON3
="$WORKSPACE/deps/build/lib/python$P3_VERSION/site-packages"
269 RUN_TESTS_LONG_REGRESSION
="yes"
272 RUN_TESTS_LONG_REGRESSION
="no"
276 # If we have modules, build them
277 if [ -d "$WORKSPACE/src/lttng-modules" ]; then
278 cd "$WORKSPACE/src/lttng-modules"
279 $MAKE -j"$($NPROC)" V
=1
280 $MAKE modules_install V
=1
284 # Print build env details
286 print_tooling || true
288 # Enter the source directory
291 # Run bootstrap in the source directory prior to configure
294 # Get source version from configure script
295 eval "$(grep '^PACKAGE_VERSION=' ./configure)"
296 PACKAGE_VERSION
=${PACKAGE_VERSION//\-pre*/}
299 # The switch to build without UST changed in 2.8
300 if vergte
"$PACKAGE_VERSION" "2.8"; then
301 NO_UST
="--without-lttng-ust"
303 NO_UST
="--disable-lttng-ust"
306 # Most build configs require the python bindings
307 CONF_OPTS
=("--prefix=$PREFIX" "--enable-python-bindings")
311 # Set configure options and environment variables for each build
315 echo "Static lib only configuration"
317 CONF_OPTS
+=("--enable-static" "--disable-shared")
321 echo "Build without UST support"
322 CONF_OPTS
+=("$NO_UST")
323 DIST_CONF_OPTS
+=("$NO_UST")
327 echo "Java and Python agents configuration"
329 export JAVA_HOME
="/usr/lib/jvm/default-java"
330 export CLASSPATH
="$DEPS_JAVA/*:/usr/share/java/*"
331 export PYTHONPATH
="$DEPS_PYTHON2:$DEPS_PYTHON3"
333 CONF_OPTS
+=("--enable-test-java-agent-all" "--enable-test-python-agent-all")
337 echo "Relayd only configuration"
339 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")
343 echo "Enable RCU sanity checks for debugging"
345 export CPPFLAGS
="$CPPFLAGS -DDEBUG_RCU"
349 echo "Standard configuration"
354 # oot : out-of-tree build
355 # dist : build via make dist
356 # oot-dist: build via make dist out-of-tree
357 # * : normal tree build
359 # Make sure to move to the build directory and run configure
363 echo "Out of tree build"
365 # Create and enter a temporary build directory
366 builddir
=$
(mktemp
-d)
369 "$SRCDIR/configure" "${CONF_OPTS[@]}" || failed_configure
373 echo "Distribution in-tree build"
375 # Run configure and generate the tar file
376 # in the source directory
377 .
/configure
"${DIST_CONF_OPTS[@]}" || failed_configure
380 # Create and enter a temporary build directory
381 builddir
=$
(mktemp
-d)
384 # Extract the distribution tar in the build directory,
385 # ignore the first directory level
386 $TAR xvf
"$SRCDIR"/*.
tar.
* --strip 1
388 # Build in extracted source tree
389 .
/configure
"${CONF_OPTS[@]}" || failed_configure
393 echo "Distribution out of tree build"
395 # Create and enter a temporary build directory
396 builddir
=$
(mktemp
-d)
399 # Run configure out of tree and generate the tar file
400 "$SRCDIR/configure" "${DIST_CONF_OPTS[@]}" || failed_configure
403 dist_srcdir
="$(mktemp -d)"
406 # Extract the distribution tar in the new source directory,
407 # ignore the first directory level
408 $TAR xvf
"$builddir"/*.
tar.
* --strip 1
410 # Create and enter a second temporary build directory
411 builddir
="$(mktemp -d)"
414 # Run configure from the extracted distribution tar,
415 # out of the source tree
416 "$dist_srcdir/configure" "${CONF_OPTS[@]}" || failed_configure
420 echo "Standard in-tree build"
421 .
/configure
"${CONF_OPTS[@]}" || failed_configure
425 # We are now inside a configured build directory
428 $MAKE -j "$($NPROC)" V
=1
430 # Install in the workspace
431 $MAKE install DESTDIR
="$WORKSPACE"
433 # Run tests for all configs except 'no-ust'
435 if [ "$RUN_TESTS" = "yes" ] && [ "$conf" != "no-ust" ]; then
439 # Force the lttng-sessiond path to /bin/true to prevent the spawing of a
440 # lttng-sessiond --daemonize on "lttng create"
441 export LTTNG_SESSIOND_PATH
="/bin/true"
443 # Run 'unit_tests', 2.8 and up has a new test suite
444 if vergte
"$PACKAGE_VERSION" "2.8"; then
445 # It is implied that tests depending on LTTNG_ENABLE_DESTRUCTIVE_TESTS
446 # only run for the root user. Note that here `destructive` means that
447 # operations are performed at the host level (add user etc.) that
448 # effectively modify the host. Running those tests are acceptable on our
449 # CI and root jobs since we always run root tests against a `snapshot`
451 if [ "$(id -u)" == "0" ]; then
452 export LTTNG_ENABLE_DESTRUCTIVE_TESTS
="will-break-my-system"
454 make --keep-going check || failed_tests
=1
455 rsync
-a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests
/ "$TAPDIR"
458 mkdir
-p "$TAPDIR/unit"
459 mkdir
-p "$TAPDIR/fast_regression"
460 mkdir
-p "$TAPDIR/with_bindings_regression"
461 prove
--merge -v --exec '' - < unit_tests
--archive "$TAPDIR/unit/" || failed_tests
=1
462 prove
--merge -v --exec '' - < fast_regression
--archive "$TAPDIR/fast_regression/" || failed_tests
=1
463 prove
--merge -v --exec '' - < with_bindings_regression
--archive "$TAPDIR/with_bindings_regression/" || failed_tests
=1
467 if [ "$RUN_TESTS_LONG_REGRESSION" = "yes" ]; then
469 mkdir
-p "$TAPDIR/long_regression"
470 prove
--merge -v --exec '' - < long_regression
--archive "$TAPDIR/long_regression/" || failed_tests
=1
474 # TAP plugin is having a hard time with .yml files.
475 find "$TAPDIR" -name "meta.yml" -exec rm -f {} \
;
477 # The TAP plugin will fail the job if no test logs are present
478 mkdir
-p "$TAPDIR/no-tests"
479 echo "1..1" > "$TAPDIR/no-tests/tests.log"
480 echo "ok 1 - Test suite disabled" >> "$TAPDIR/no-tests/tests.log"
483 # Clean the build directory
486 # Cleanup rpath in executables and shared libraries
487 find "$WORKSPACE/$PREFIX/bin" -type f
-perm -0500 -exec chrpath
--delete {} \
;
488 find "$WORKSPACE/$PREFIX/lib" -name "*.so" -exec chrpath
--delete {} \
;
490 # Remove libtool .la files
491 find "$WORKSPACE/$PREFIX/lib" -name "*.la" -exec rm -f {} \
;
493 # Exit with failure if any of the tests failed