jjb: Allow unsupported modules to be loaded when testing lttng-tools
[lttng-ci.git] / scripts / lttng-tools / build.sh
CommitLineData
51c9c62d 1#!/bin/bash
b4005bbf 2#
1ad4c3d0
MJ
3# SPDX-FileCopyrightText: 2016 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
4# SPDX-FileCopyrightText: 2016-2023 Michael Jeanson <mjeanson@efficios.com>
5# SPDX-License-Identifier: GPL-2.0-or-later
b4005bbf 6#
1ad4c3d0 7# shellcheck disable=SC2103
b4005bbf 8
51c9c62d
MJ
9set -exu
10
0cdaa21c 11# Version compare functions
b6e62a6a
MJ
12vercomp () {
13 set +u
14 if [[ "$1" == "$2" ]]; then
15 return 0
16 fi
17 local IFS=.
4afa623f
MJ
18 # Ignore the shellcheck warning, we want splitting to happen based on IFS.
19 # shellcheck disable=SC2206
b6e62a6a
MJ
20 local i ver1=($1) ver2=($2)
21 # fill empty fields in ver1 with zeros
22 for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); do
23 ver1[i]=0
24 done
25 for ((i=0; i<${#ver1[@]}; i++)); do
26 if [[ -z ${ver2[i]} ]]; then
27 # fill empty fields in ver2 with zeros
28 ver2[i]=0
29 fi
30 if ((10#${ver1[i]} > 10#${ver2[i]})); then
31 return 1
32 fi
33 if ((10#${ver1[i]} < 10#${ver2[i]})); then
34 return 2
35 fi
36 done
37 set -u
38 return 0
39}
40
0cdaa21c 41verlte() {
b6e62a6a
MJ
42 vercomp "$1" "$2"; local res="$?"
43 [ "$res" -eq "0" ] || [ "$res" -eq "2" ]
0cdaa21c
MJ
44}
45
46verlt() {
b6e62a6a
MJ
47 vercomp "$1" "$2"; local res="$?"
48 [ "$res" -eq "2" ]
0cdaa21c
MJ
49}
50
51vergte() {
b6e62a6a
MJ
52 vercomp "$1" "$2"; local res="$?"
53 [ "$res" -eq "0" ] || [ "$res" -eq "1" ]
0cdaa21c
MJ
54}
55
56vergt() {
b6e62a6a
MJ
57 vercomp "$1" "$2"; local res="$?"
58 [ "$res" -eq "1" ]
59}
60
61verne() {
62 vercomp "$1" "$2"; local res="$?"
63 [ "$res" -ne "0" ]
0cdaa21c
MJ
64}
65
1ad4c3d0
MJ
66print_header() {
67 set +x
68
69 local message=" $1 "
70 local message_len
71 local padding_len
72
73 message_len="${#message}"
74 padding_len=$(( (80 - (message_len)) / 2 ))
75
76
77 printf '\n'; printf -- '#%.0s' {1..80}; printf '\n'
78 printf -- '-%.0s' {1..80}; printf '\n'
79 printf -- '#%.0s' $(seq 1 $padding_len); printf '%s' "$message"; printf -- '#%.0s' $(seq 1 $padding_len); printf '\n'
80 printf -- '-%.0s' {1..80}; printf '\n'
81 printf -- '#%.0s' {1..80}; printf '\n\n'
82
83 set -x
84}
85
51c9c62d
MJ
86failed_configure() {
87 # Assume we are in the configured build directory
1ad4c3d0 88 print_header "BEGIN config.log"
51c9c62d 89 cat config.log
1ad4c3d0 90 print_header "END config.log"
51c9c62d
MJ
91
92 # End the build with failure
93 exit 1
94}
95
54c3c7ec
JR
96set_execute_traversal_bit()
97{
98 path=$1
99
100 level="$path"
101 if [ ! -d "$path" ]; then
102 fail "Path is not a directory"
103 fi
104 while level="$(dirname "$level")"
105 do
106 if [ "$level" = / ]; then
107 break
108 fi
109 chmod a+x "$level"
110 done
111 chmod a+x "$path"
112}
113
1ad4c3d0
MJ
114print_header "LTTng-tools build script starting"
115
09d45745
MJ
116# Required variables
117WORKSPACE=${WORKSPACE:-}
118
1ad4c3d0 119# Axis
5fcae288 120platform=${platform:-}
212d2afd
MJ
121conf=${conf:-}
122build=${build:-}
09d45745 123cc=${cc:-}
1ad4c3d0
MJ
124
125# Build steps that can be overriden by the environment
126LTTNG_TOOLS_MAKE_INSTALL="${LTTNG_TOOLS_MAKE_INSTALL:-yes}"
127LTTNG_TOOLS_MAKE_CLEAN="${LTTNG_TOOLS_MAKE_CLEAN:-yes}"
128LTTNG_TOOLS_GEN_COMPILE_COMMANDS="${LTTNG_TOOLS_GEN_COMPILE_COMMANDS:-no}"
129LTTNG_TOOLS_RUN_TESTS="${LTTNG_TOOLS_RUN_TESTS:-yes}"
130LTTNG_TOOLS_RUN_TESTS_LONG_REGRESSION="${LTTNG_TOOLS_RUN_TESTS_LONG_REGRESSION:-no}"
80cc6268 131LTTNG_TOOLS_RUN_UST_JAVA_TESTS="${LTTNG_TOOLS_RUN_UST_JAVA_TESTS:-yes}"
1ad4c3d0 132LTTNG_TOOLS_CLANG_TIDY="${LTTNG_TOOLS_CLANG_TIDY:-no}"
b4005bbf 133
4afa623f
MJ
134SRCDIR="$WORKSPACE/src/lttng-tools"
135TAPDIR="$WORKSPACE/tap"
136PREFIX="/build"
137LIBDIR="lib"
32dde2a3 138LIBDIR_ARCH="$LIBDIR"
4afa623f
MJ
139
140# RHEL and SLES both use lib64 but don't bother shipping a default autoconf
141# site config that matches this.
47ca4354 142if [[ ( -f /etc/redhat-release || -f /etc/products.d/SLES.prod || -f /etc/yocto-release ) ]]; then
85322e5d
MJ
143 # Detect the userspace bitness in a distro agnostic way
144 if file -L /bin/bash | grep '64-bit' >/dev/null 2>&1; then
145 LIBDIR_ARCH="${LIBDIR}64"
85322e5d 146 fi
4afa623f
MJ
147fi
148
09d45745 149DEPS_INC="$WORKSPACE/deps/build/include"
4afa623f 150DEPS_LIB="$WORKSPACE/deps/build/$LIBDIR_ARCH"
b8bdba8f 151DEPS_PKGCONFIG="$DEPS_LIB/pkgconfig"
09d45745
MJ
152DEPS_BIN="$WORKSPACE/deps/build/bin"
153DEPS_JAVA="$WORKSPACE/deps/build/share/java"
154
155export PATH="$DEPS_BIN:$PATH"
156export LD_LIBRARY_PATH="$DEPS_LIB:${LD_LIBRARY_PATH:-}"
b8bdba8f 157export PKG_CONFIG_PATH="$DEPS_PKGCONFIG"
09d45745
MJ
158export CPPFLAGS="-I$DEPS_INC"
159export LDFLAGS="-L$DEPS_LIB"
160
1ad4c3d0
MJ
161exit_status=0
162
163# Use bear to generate compile_commands.json when enabled
164BEAR=""
165if [ "$LTTNG_TOOLS_GEN_COMPILE_COMMANDS" = "yes" ]; then
166 BEAR="bear"
167fi
212d2afd 168
09d45745
MJ
169# Create tmp directory
170TMPDIR="$WORKSPACE/tmp"
171mkdir -p "$TMPDIR"
212d2afd 172
09d45745
MJ
173# Use a symlink in /tmp to point to the the tmp directory
174# inside the workspace, this is to work around the path length
175# limit of unix sockets which are created by the test suite.
176tmpdir="$(mktemp)"
177ln -sf "$TMPDIR" "$tmpdir"
178export TMPDIR="$tmpdir"
b4005bbf 179
481eadc8
JR
180# Create a symlink to "babeltrace" when the "babeltrace2" executable is found.
181# This is a temporary workaround until lttng-tools either allows the override of
182# the trace reader in its test suite or that we move to only supporting
183# babeltrace2
184if [ -x "$DEPS_BIN/babeltrace2" ]; then
65444f1c 185 ln -s "$DEPS_BIN/babeltrace2" "$DEPS_BIN/babeltrace"
481eadc8
JR
186fi
187
188# When using babeltrace2 make sure that it finds its plugins and
189# plugin-providers.
190export BABELTRACE_PLUGIN_PATH="$DEPS_LIB/babeltrace2/plugins/"
191export LIBBABELTRACE2_PLUGIN_PROVIDER_DIR="$DEPS_LIB/babeltrace2/plugin-providers/"
192
09d45745 193export CFLAGS="-g -O2"
fdb66460 194export CXXFLAGS="-g -O2"
b4005bbf 195
09d45745
MJ
196# Set compiler variables
197case "$cc" in
198gcc)
199 export CC=gcc
200 export CXX=g++
201 ;;
1ad4c3d0
MJ
202gcc-*)
203 export CC=gcc-${cc#gcc-}
204 export CXX=g++-${cc#gcc-}
09d45745
MJ
205 ;;
206clang)
207 export CC=clang
208 export CXX=clang++
209 ;;
1ad4c3d0
MJ
210clang-*)
211 export CC=clang-${cc#clang-}
212 export CXX=clang++-${cc#clang-}
09d45745
MJ
213 ;;
214*)
215 if [ "x$cc" != "x" ]; then
1ad4c3d0 216 export CC="$cc"
09d45745
MJ
217 fi
218 ;;
219esac
b4005bbf 220
0cdaa21c 221# Set platform variables
5fcae288 222case "$platform" in
f0d7e5b1 223macos*)
09d45745
MJ
224 export MAKE=make
225 export TAR=tar
226 export NPROC="getconf _NPROCESSORS_ONLN"
227 export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
228 export CPPFLAGS="-I/opt/local/include $CPPFLAGS"
229 export LDFLAGS="-L/opt/local/lib $LDFLAGS"
00f7bb3f
MJ
230 export PYTHON="python3"
231 export PYTHON_CONFIG="python3-config"
b6e62a6a
MJ
232 ;;
233
61afb3c3 234cygwin|cygwin64|msys32|msys64)
09d45745
MJ
235 export MAKE=make
236 export TAR=tar
237 export NPROC=nproc
61afb3c3
MJ
238 ;;
239
0cdaa21c 240*)
09d45745
MJ
241 export MAKE=make
242 export TAR=tar
243 export NPROC=nproc
244
0cdaa21c
MJ
245 PYTHON2=python2
246 PYTHON3=python3
247
b4c6a892
MJ
248 if command -v $PYTHON2 >/dev/null 2>&1; then
249 P2_VERSION=$($PYTHON2 -c 'import sys;v = sys.version.split()[0].split("."); print("{}.{}".format(v[0], v[1]))')
4afa623f
MJ
250 DEPS_PYTHON2="$WORKSPACE/deps/build/$LIBDIR/python$P2_VERSION/site-packages"
251 if [ "$LIBDIR" != "$LIBDIR_ARCH" ]; then
252 DEPS_PYTHON2="$DEPS_PYTHON2:$WORKSPACE/deps/build/$LIBDIR_ARCH/python$P2_VERSION/site-packages"
253 fi
b4c6a892 254 fi
0cdaa21c 255
b4c6a892 256 P3_VERSION=$($PYTHON3 -c 'import sys;v = sys.version.split()[0].split("."); print("{}.{}".format(v[0], v[1]))')
05615fb2
MJ
257
258 # Temporary fix for an issue on debian python >= 3.10, add the 'local' prefix
259 DEPS_PYTHON3="$WORKSPACE/deps/build/$LIBDIR/python$P3_VERSION/site-packages:$WORKSPACE/deps/build/local/$LIBDIR/python$P3_VERSION/dist-packages"
4afa623f
MJ
260 if [ "$LIBDIR" != "$LIBDIR_ARCH" ]; then
261 DEPS_PYTHON3="$DEPS_PYTHON3:$WORKSPACE/deps/build/$LIBDIR_ARCH/python$P3_VERSION/site-packages"
262 fi
de7e8d55
JG
263
264 # Most build configs require access to the babeltrace 2 python bindings.
265 # This also makes the lttngust python agent available for `agents` builds.
266 export PYTHONPATH="${DEPS_PYTHON2:-}${DEPS_PYTHON2:+:}$DEPS_PYTHON3"
0cdaa21c
MJ
267 ;;
268esac
269
6843e673
MJ
270# Some warning flags are very dumb in GCC 4.8 on SLES12 / EL7, disable them
271# even if they are available.
29d9c2b2 272if [[ $platform = sles12sp5* ]] || [[ $platform = el7* ]]; then
6843e673
MJ
273 CFLAGS="$CFLAGS -Wno-missing-field-initializers -Wno-shadow"
274 CXXFLAGS="$CXXFLAGS -Wno-missing-field-initializers -Wno-shadow"
fdb66460
MJ
275fi
276
7361d941
MJ
277# If we have modules, build them
278if [ -d "$WORKSPACE/src/lttng-modules" ]; then
1ad4c3d0 279 print_header "Build and install LTTng-modules"
7361d941
MJ
280 cd "$WORKSPACE/src/lttng-modules"
281 $MAKE -j"$($NPROC)" V=1
282 $MAKE modules_install V=1
283 depmod
f81a4222
KS
284
285 if [[ -f /etc/products.d/SLES.prod ]] ; then
286 echo 'allow_unsupported_modules 1' > /etc/modprobe.d/10-unsupported-modules.conf
287 fi
7361d941
MJ
288fi
289
51c9c62d 290# Print build env details
1ad4c3d0 291print_header "Build environment details"
8c956c4b 292print_hardware || true
51c9c62d
MJ
293print_os || true
294print_tooling || true
295
212d2afd
MJ
296# Enter the source directory
297cd "$SRCDIR"
298
299# Run bootstrap in the source directory prior to configure
1ad4c3d0 300print_header "Bootstrap autotools"
0cdaa21c
MJ
301./bootstrap
302
303# Get source version from configure script
212d2afd 304eval "$(grep '^PACKAGE_VERSION=' ./configure)"
09d45745 305PACKAGE_VERSION=${PACKAGE_VERSION//\-pre*/}
0cdaa21c 306
1ad4c3d0
MJ
307CONF_OPTS=("--prefix=$PREFIX" "--libdir=$PREFIX/$LIBDIR_ARCH" "--disable-maintainer-mode")
308DIST_CONF_OPTS=("--disable-maintainer-mode")
edb933dd 309
09d45745
MJ
310# Set configure options and environment variables for each build
311# configuration.
b4005bbf 312case "$conf" in
0cdaa21c 313static)
1ad4c3d0 314 print_header "Conf: Static lib only"
09d45745 315
1ad4c3d0 316 CONF_OPTS+=("--enable-static" "--disable-shared" "--enable-python-bindings")
0cdaa21c
MJ
317 ;;
318
0cdaa21c 319no-ust)
1ad4c3d0 320 print_header "Conf: Without UST support"
2c34ea14 321
1ad4c3d0
MJ
322 CONF_OPTS+=("--without-lttng-ust")
323 DIST_CONF_OPTS+=("--without-lttng-ust")
0cdaa21c
MJ
324 ;;
325
67122b96 326agents)
1ad4c3d0 327 print_header "Conf: Java and Python agents"
09d45745 328
4a9fa8ba
KS
329 if [[ -z "${JAVA_HOME:-}" ]] ; then
330 export JAVA_HOME="/usr/lib/jvm/default-java"
331 fi
61c5ba32 332 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"
dc56017a 333 if [[ -f /etc/products.d/SLES.prod ]] ; then
ada7f884
KS
334 export JAVA_HOME="/usr/${LIBDIR_ARCH}/jvm/java-1.8.0-openjdk-1.8.0"
335 export PATH="/usr/${LIBDIR_ARCH}/jvm/java-1.8.0-openjdk-1.8.0/bin:/usr/${LIBDIR_ARCH}/jvm/jre-1.8.0-openjdk/bin:${PATH}"
dc56017a 336 SLES_VERSION="$(grep -E '</version>' /etc/products.d/SLES.prod | grep -E -o '[0-9]+\.[0-9]+')"
247873aa 337 if vergte "${SLES_VERSION}" "15.4" ; then
dc56017a
KS
338 export CLASSPATH="${DEPS_JAVA}/lttng-ust-agent-all.jar:/usr/share/java/log4j/log4j-api.jar:/usr/share/java/log4j/log4j-core.jar:/usr/share/java/log4j12/log4j-12.jar"
339 fi
340 fi
341
0cdaa21c 342
1ad4c3d0 343 CONF_OPTS+=("--enable-python-bindings" "--enable-test-java-agent-all")
d51c467a
MJ
344
345 # Explicitly add '--enable-test-java-agent-log4j2', it's not part of '-all' in stable 2.12/2.13
346 if verlt "$PACKAGE_VERSION" "2.14"; then
347 CONF_OPTS+=("--enable-test-java-agent-log4j2")
348 fi
b7b61fcb
MJ
349
350 # Some distros don't ship python2 anymore
351 if command -v $PYTHON2 >/dev/null 2>&1; then
352 CONF_OPTS+=("--enable-test-python-agent-all")
353 else
354 CONF_OPTS+=("--enable-test-python3-agent")
355 fi
0cdaa21c
MJ
356 ;;
357
358relayd-only)
1ad4c3d0 359 print_header "Conf: Relayd only"
09d45745 360
1ad4c3d0 361 CONF_OPTS+=("--disable-bin-lttng" "--disable-bin-lttng-consumerd" "--disable-bin-lttng-crash" "--disable-bin-lttng-sessiond" "--disable-extras" "--disable-man-pages" "--without-lttng-ust")
a2eb91f7
MJ
362
363 # A config option for lib-lttng-ctl was added in 2.14
364 if vergte "$PACKAGE_VERSION" "2.14"; then
365 CONF_OPTS+=("--disable-lib-lttng-ctl")
366 fi
0cdaa21c
MJ
367 ;;
368
22780fe6 369debug-rcu)
1ad4c3d0
MJ
370 print_header "Conf: RCU sanity checks for debugging"
371
372 CONF_OPTS+=("--enable-python-bindings")
09d45745
MJ
373
374 export CPPFLAGS="$CPPFLAGS -DDEBUG_RCU"
22780fe6
JR
375 ;;
376
0cdaa21c 377*)
1ad4c3d0
MJ
378 print_header "Conf: Standard"
379
380 CONF_OPTS+=("--enable-python-bindings")
6871000c
MJ
381
382 # Something is broken in docbook-xml on yocto
383 if [[ "$platform" = yocto* ]]; then
384 CONF_OPTS+=("--disable-man-pages")
385 fi
0cdaa21c 386 ;;
b4005bbf
MJ
387esac
388
389# Build type
67122b96
MJ
390# oot : out-of-tree build
391# dist : build via make dist
392# oot-dist: build via make dist out-of-tree
393# * : normal tree build
b4005bbf 394#
09d45745
MJ
395# Make sure to move to the build directory and run configure
396# before continuing.
b4005bbf 397case "$build" in
09d45745 398oot)
1ad4c3d0 399 print_header "Build: Out of tree"
09d45745
MJ
400
401 # Create and enter a temporary build directory
402 builddir=$(mktemp -d)
403 cd "$builddir"
404
51c9c62d 405 "$SRCDIR/configure" "${CONF_OPTS[@]}" || failed_configure
09d45745
MJ
406 ;;
407
408dist)
1ad4c3d0 409 print_header "Build: Distribution in-tree"
09d45745
MJ
410
411 # Run configure and generate the tar file
412 # in the source directory
1ad4c3d0 413
51c9c62d 414 ./configure "${DIST_CONF_OPTS[@]}" || failed_configure
09d45745
MJ
415 $MAKE dist
416
417 # Create and enter a temporary build directory
418 builddir=$(mktemp -d)
419 cd "$builddir"
420
421 # Extract the distribution tar in the build directory,
422 # ignore the first directory level
423 $TAR xvf "$SRCDIR"/*.tar.* --strip 1
424
425 # Build in extracted source tree
51c9c62d 426 ./configure "${CONF_OPTS[@]}" || failed_configure
09d45745
MJ
427 ;;
428
429oot-dist)
1ad4c3d0 430 print_header "Build: Distribution Out of tree"
09d45745
MJ
431
432 # Create and enter a temporary build directory
433 builddir=$(mktemp -d)
434 cd "$builddir"
435
436 # Run configure out of tree and generate the tar file
51c9c62d 437 "$SRCDIR/configure" "${DIST_CONF_OPTS[@]}" || failed_configure
09d45745
MJ
438 $MAKE dist
439
440 dist_srcdir="$(mktemp -d)"
441 cd "$dist_srcdir"
442
443 # Extract the distribution tar in the new source directory,
444 # ignore the first directory level
445 $TAR xvf "$builddir"/*.tar.* --strip 1
446
447 # Create and enter a second temporary build directory
448 builddir="$(mktemp -d)"
449 cd "$builddir"
450
451 # Run configure from the extracted distribution tar,
452 # out of the source tree
51c9c62d 453 "$dist_srcdir/configure" "${CONF_OPTS[@]}" || failed_configure
09d45745
MJ
454 ;;
455
456*)
1ad4c3d0 457 print_header "Build: Standard In-tree"
51c9c62d 458 ./configure "${CONF_OPTS[@]}" || failed_configure
09d45745 459 ;;
b4005bbf
MJ
460esac
461
09d45745
MJ
462# We are now inside a configured build directory
463
0cdaa21c 464# BUILD!
1ad4c3d0
MJ
465print_header "BUILD!"
466$BEAR ${BEAR:+--} $MAKE -j "$($NPROC)" V=1
467
468# Install in the workspace if enabled
469if [ "$LTTNG_TOOLS_MAKE_INSTALL" = "yes" ]; then
470 print_header "Install"
471
472 $MAKE install V=1 DESTDIR="$WORKSPACE"
473
474 # Cleanup rpath in executables
475 find "$WORKSPACE/$PREFIX/bin" -type f -perm -0500 -exec chrpath --delete {} \;
476
477 # Some configs don't build liblttng-ctl
478 if [ -d "$WORKSPACE/$PREFIX/$LIBDIR_ARCH" ]; then
479 # Cleanup rpath in shared libraries
480 find "$WORKSPACE/$PREFIX/$LIBDIR_ARCH" -name "*.so" -exec chrpath --delete {} \;
481 # Remove libtool .la files
482 find "$WORKSPACE/$PREFIX/$LIBDIR_ARCH" -name "*.la" -delete
483 fi
484fi
485
486# Run clang-tidy on the topmost commit
487if [ "$LTTNG_TOOLS_CLANG_TIDY" = "yes" ]; then
488 print_header "Run clang-tidy"
b4005bbf 489
1ad4c3d0
MJ
490 # This would be better by linting only the lines touched by a patch but it
491 # doesn't seem to work, the lines are always filtered and no error is
492 # reported.
493 #git diff -U0 HEAD^ | clang-tidy-diff -p1 -j "$($NPROC)" -timeout 60 -fix
494
495 # Instead, run clan-tidy on all the files touched by the patch.
496 while read -r filepath; do
497 if [[ "$filepath" =~ (\.cpp|\.hhp|\.c|\.h)$ ]]; then
498 clang-tidy --fix-errors "$(realpath "$filepath")"
499 fi
500 done < <(git diff-tree --no-commit-id --diff-filter=d --name-only -r HEAD)
501
502 # If the tree has local changes, the formatting was incorrect
503 GIT_DIFF_OUTPUT=$(git diff)
504 if [ -n "$GIT_DIFF_OUTPUT" ]; then
505 echo "Saving clang-tidy proposed fixes in clang-tidy-fixes.diff"
506 git diff > "$WORKSPACE/clang-tidy-fixes.diff"
507
508 # Restore the unfixed files so they can be viewed in the warnings web
509 # interface
510 git checkout .
511 exit_status=1
512 fi
513fi
7671741c 514
d6237b1b
MJ
515# Run tests for all configs except 'no-ust' / 'relayd-only'
516if [ "$LTTNG_TOOLS_RUN_TESTS" = "yes" ] && [[ ! "$conf" =~ (no-ust|relayd-only) ]]; then
1ad4c3d0
MJ
517 print_header "Run test suite"
518
0cdaa21c
MJ
519 # Allow core dumps
520 ulimit -c unlimited
521
a4e98cc0
JR
522 # Force the lttng-sessiond path to /bin/true to prevent the spawing of a
523 # lttng-sessiond --daemonize on "lttng create"
524 export LTTNG_SESSIOND_PATH="/bin/true"
525
1ad4c3d0
MJ
526 # It is implied that tests depending on LTTNG_ENABLE_DESTRUCTIVE_TESTS
527 # only run for the root user. Note that here `destructive` means that
528 # operations are performed at the host level (add user etc.) that
529 # effectively modify the host. Running those tests are acceptable on our
530 # CI and root jobs since we always run root tests against a `snapshot`
531 # of the host.
532 if [ "$(id -u)" == "0" ]; then
533 # Allow the traversal of all directories leading to the
534 # DEPS_LIBS directory to enable test app run by temp users to
535 # access lttng-ust.
536 set_execute_traversal_bit "$DEPS_LIB"
537 # Allow `all` to interact with all deps libs.
538 chmod a+rwx -R "$DEPS_LIB"
539
540 export LTTNG_ENABLE_DESTRUCTIVE_TESTS="will-break-my-system"
541
542 # Some destructive tests play with the system clock, disable timesyncd
543 systemctl stop systemd-timesyncd.service || true
544 fi
65444f1c 545
1ad4c3d0 546 make --keep-going check || exit_status=1
4174b905 547
68d45ec8 548 # Copy tap logs for the jenkins tap parser before cleaning the build dir
1ad4c3d0 549 rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests/ "$TAPDIR"
4174b905 550
1ad4c3d0
MJ
551 # Copy the test suites top-level log which includes all tests failures
552 rsync -a --include 'test-suite.log' --include '*/' --exclude='*' tests/ "$WORKSPACE/log"
09d45745 553
aff4e3d1 554 if [ "$LTTNG_TOOLS_RUN_TESTS_LONG_REGRESSION" = "yes" ]; then
1ad4c3d0 555 print_header "Run long regression tests"
09d45745
MJ
556 cd tests
557 mkdir -p "$TAPDIR/long_regression"
1ad4c3d0 558 prove --merge -v --exec '' - < long_regression --archive "$TAPDIR/long_regression/" || exit_status=1
65444f1c 559 cd ..
0cdaa21c 560 fi
68d45ec8 561
1b7b4b35 562 if [ "$LTTNG_TOOLS_RUN_UST_JAVA_TESTS" = "yes" ] && [ "$LTTNG_TOOLS_MAKE_INSTALL" = "yes" ] && [ "$conf" = "agents" ] ; then
68d45ec8
KS
563 print_header "Run lttng-ust-java-tests"
564 # Git Source
565 LTTNG_UST_JAVA_TESTS_GIT_SOURCE="${LTTNG_UST_JAVA_TESTS_GIT_SOURCE:-https://github.com/lttng/lttng-ust-java-tests.git}"
566 LTTNG_UST_JAVA_TESTS_GIT_BRANCH="${LTTNG_UST_JAVA_TESTS_GIT_BRANCH:-master}"
567
568 OWD="$(pwd)"
569 cd ..
570 git clone -b "${LTTNG_UST_JAVA_TESTS_GIT_BRANCH}" "${LTTNG_UST_JAVA_TESTS_GIT_SOURCE}" lttng-ust-java-tests
571 cd lttng-ust-java-tests
572
573 LTTNG_UST_JAVA_TESTS_ENV=(
4a9fa8ba
KS
574 # Some ci nodes (eg. SLES12) don't have maven distributed by their
575 # package manager. As a result, the maven binary is deployed in
576 # '/opt/apache/maven/bin'.
577 PATH="${WORKSPACE}/build/bin/:$PATH:/opt/apache/maven/bin/"
578 LD_LIBRARY_PATH="${WORKSPACE}/build/${LIBDIR}/:${WORKSPACE}/build/${LIBDIR_ARCH}:$LD_LIBRARY_PATH"
68d45ec8 579 LTTNG_UST_DEBUG=1
4a9fa8ba
KS
580 LTTNG_CONSUMERD32_BIN="${WORKSPACE}/build/${LIBDIR_ARCH}/lttng/libexec/lttng-consumerd"
581 LTTNG_CONSUMERD64_BIN="${WORKSPACE}/build/${LIBDIR_ARCH}/lttng/libexec/lttng-consumerd"
68d45ec8 582 LTTNG_SESSION_CONFIG_XSD_PATH="${WORKSPACE}/build/share/xml/lttng"
4a9fa8ba
KS
583 BABELTRACE_PLUGIN_PATH="${WORKSPACE}/deps/build/${LIBDIR_ARCH}/babeltrace2/plugins"
584 LIBBABELTRACE2_PLUGIN_PROVIDER_DIR="${WORKSPACE}/deps/build/${LIBDIR_ARCH}/babeltrace2/plugin-providers"
68d45ec8
KS
585 )
586 LTTNG_UST_JAVA_TESTS_MAVEN_OPTS=(
587 "-Dmaven.test.failure.ignore=true"
588 "-Dcommon-jar-location=${WORKSPACE}/deps/build/share/java/lttng-ust-agent-common.jar"
589 "-Djul-jar-location=${WORKSPACE}/deps/build/share/java/lttng-ust-agent-jul.jar"
590 "-Dlog4j-jar-location=${WORKSPACE}/deps/build/share/java/lttng-ust-agent-log4j.jar"
591 "-Dlog4j2-jar-location=${WORKSPACE}/deps/build/share/java/lttng-ust-agent-log4j2.jar"
4a9fa8ba 592 "-DargLine=-Djava.library.path=${WORKSPACE}/deps/build/${LIBDIR_ARCH}"
68d45ec8
KS
593 '-Dgroups=!domain:log4j2'
594 )
9a269c66 595
68d45ec8 596 env "${LTTNG_UST_JAVA_TESTS_ENV[@]}" mvn -version
9a269c66
KS
597
598 if [[ -n "${LTTNG_TOOLS_UST_JAVA_TESTS_LOG4J_API_VERSION:-}" ]] ; then
599 env "${LTTNG_UST_JAVA_TESTS_ENV[@]}" mvn versions:use-dep-version -Dincludes=org.apache.logging.log4j:'*' -DdepVersion="${LTTNG_TOOLS_UST_JAVA_TESTS_LOG4J_API_VERSION}"
600 fi
601
4a9fa8ba 602 mkdir -p "${WORKSPACE}/log"
68d45ec8 603 env "${LTTNG_UST_JAVA_TESTS_ENV[@]}" lttng-sessiond -b -vvv 1>"${WORKSPACE}/log/lttng-ust-java-tests-lttng-sessiond.log" 2>&1
9a269c66 604 env "${LTTNG_UST_JAVA_TESTS_ENV[@]}" mvn "${LTTNG_UST_JAVA_TESTS_MAVEN_OPTS[@]}" clean compile dependency:build-classpath dependency:tree verify || exit_status=1
68d45ec8
KS
605 killall lttng-sessiond
606
607 cd "${OWD}"
608 fi
2c34ea14
MJ
609fi
610
d6237b1b 611if [ "$LTTNG_TOOLS_RUN_TESTS" = "yes" ] && [[ "$conf" =~ (no-ust|relayd-only) ]]; then
09d45745
MJ
612 # The TAP plugin will fail the job if no test logs are present
613 mkdir -p "$TAPDIR/no-tests"
614 echo "1..1" > "$TAPDIR/no-tests/tests.log"
615 echo "ok 1 - Test suite disabled" >> "$TAPDIR/no-tests/tests.log"
b4005bbf
MJ
616fi
617
09d45745 618# Clean the build directory
1ad4c3d0
MJ
619if [ "$LTTNG_TOOLS_MAKE_CLEAN" = "yes" ]; then
620 print_header "Clean"
621 $MAKE clean
0a059dd4 622fi
b4005bbf 623
1ad4c3d0
MJ
624print_header "LTTng-tools build script ended with: $(test $exit_status == 0 && echo SUCCESS || echo FAILURE)"
625
09d45745 626# Exit with failure if any of the tests failed
1ad4c3d0 627exit $exit_status
95654431
MJ
628
629# EOF
1ad4c3d0 630# vim: expandtab tabstop=4 shiftwidth=4
This page took 0.065662 seconds and 4 git commands to generate.