3 # Copyright (C) 2015 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
4 # Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com>
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # Version compare functions
24 if [[ "$1" == "$2" ]]; then
28 local i ver1
=($1) ver2
=($2)
29 # fill empty fields in ver1 with zeros
30 for ((i
=${#ver1[@]}; i
<${#ver2[@]}; i
++)); do
33 for ((i
=0; i
<${#ver1[@]}; i
++)); do
34 if [[ -z ${ver2[i]} ]]; then
35 # fill empty fields in ver2 with zeros
38 if ((10#${ver1[i]} > 10#${ver2[i]})); then
41 if ((10#${ver1[i]} < 10#${ver2[i]})); then
50 vercomp
"$1" "$2"; local res
="$?"
51 [ "$res" -eq "0" ] ||
[ "$res" -eq "2" ]
55 vercomp
"$1" "$2"; local res
="$?"
60 vercomp
"$1" "$2"; local res
="$?"
61 [ "$res" -eq "0" ] ||
[ "$res" -eq "1" ]
65 vercomp
"$1" "$2"; local res
="$?"
70 vercomp
"$1" "$2"; local res
="$?"
74 export TERM
="xterm-256color"
77 WORKSPACE
=${WORKSPACE:-}
79 DEPS_INC
="$WORKSPACE/deps/build/include"
80 DEPS_LIB
="$WORKSPACE/deps/build/lib"
81 DEPS_PKGCONFIG
="$DEPS_LIB/pkgconfig"
82 DEPS_BIN
="$WORKSPACE/deps/build/bin"
83 DEPS_JAVA
="$WORKSPACE/deps/build/share/java"
85 export PATH
="$DEPS_BIN:$PATH"
86 export LD_LIBRARY_PATH
="$DEPS_LIB:${LD_LIBRARY_PATH:-}"
87 export PKG_CONFIG_PATH
="$DEPS_PKGCONFIG"
88 export CPPFLAGS
="-I$DEPS_INC"
89 export LDFLAGS
="-L$DEPS_LIB"
91 export JAVA_HOME
="/usr/lib/jvm/default-java"
92 export CLASSPATH
="$DEPS_JAVA/*:/usr/share/java/log4j-core.jar:/usr/share/java/log4j-1.2.jar"
94 SRCDIR
="$WORKSPACE/src/lttng-tools"
95 OUTDIR
="$WORKSPACE/out"
96 TAPDIR
="$WORKSPACE/tap"
100 # Create tmp directory
101 TMPDIR
="$WORKSPACE/tmp"
104 # Use a symlink in /tmp to point to the the tmp directory
105 # inside the workspace, this is to work around the path length
106 # limit of unix sockets which are created by the test suite.
108 ln -sf "$TMPDIR" "$tmpdir"
109 export TMPDIR
="$tmpdir"
111 # Create a symlink to "babeltrace" when the "babeltrace2" executable is found.
112 # This is a temporary workaround until lttng-tools either allows the override of
113 # the trace reader in its test suite or that we move to only supporting
115 if [ -x "$DEPS_BIN/babeltrace2" ]; then
116 ln -s "$DEPS_BIN/babeltrace2" "$DEPS_BIN/babeltrace"
119 # When using babeltrace2 make sure that it finds its plugins and
121 export BABELTRACE_PLUGIN_PATH
="$DEPS_LIB/babeltrace2/plugins/"
122 export LIBBABELTRACE2_PLUGIN_PROVIDER_DIR
="$DEPS_LIB/babeltrace2/plugin-providers/"
126 # Set default python to python3 for the bindings
127 export PYTHON
="$PYTHON3"
128 export PYTHON_CONFIG
="/usr/bin/$PYTHON3-config"
130 P3_VERSION
=$
($PYTHON3 -c 'import sys;v = sys.version.split()[0].split("."); print("{}.{}".format(v[0], v[1]))')
132 UST_PYTHON3
="$WORKSPACE/deps/build/lib/python$P3_VERSION/site-packages"
134 export PYTHONPATH
="$UST_PYTHON3"
138 # Create build and tmp directories
139 rm -rf "$OUTDIR" "$TAPDIR"
140 mkdir
-p "$OUTDIR" "$TAPDIR"
145 # Enter the source directory
148 # Run bootstrap in the source directory prior to configure
151 # Get source version from configure script
152 eval "$(grep '^PACKAGE_VERSION=' ./configure)"
153 PACKAGE_VERSION
=${PACKAGE_VERSION//\-pre*/}
155 CONF_OPTS
=("--enable-python-bindings" "--enable-test-java-agent-all" "--enable-test-python3-agent")
157 TARBALL_FILE
="lttng-tools-$PACKAGE_VERSION.tar.bz2"
159 # Make sure the reported version matches the current git tag
160 GIT_TAG
="$(git describe --exact-match --tags "$
(git log
-n1 --pretty='%h')" || echo 'undefined')"
162 if [ "v$PACKAGE_VERSION" != "$GIT_TAG" ]; then
163 echo "Git checkout is not tagged or doesn't match the reported version."
167 # Generate release tarball
170 cp "./$TARBALL_FILE" "$OUTDIR/"
176 # Force the lttng-sessiond path to /bin/true to prevent the spawing of a
177 # lttng-sessiond --daemonize on "lttng create"
178 export LTTNG_SESSIOND_PATH
="/bin/true"
181 ## Do an in-tree test build
182 mkdir
"$WORKSPACE/intree"
183 cd "$WORKSPACE/intree" ||
exit 1
185 tar xvf
"$OUTDIR/$TARBALL_FILE" --strip 1
186 .
/configure
--prefix="$(mktemp -d)" "${CONF_OPTS[@]}"
189 make -j "$(nproc)" V
=1
193 # Run tests, don't fail now, we want to run the archiving steps
194 make --keep-going check || failed_tests
=1
196 # Copy tap logs for the jenkins tap parser before cleaning the build dir
197 rsync
-a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests
/ "$TAPDIR/intree"
199 # Clean the build directory
203 ## Do an out-of-tree test build
204 mkdir
"$WORKSPACE/oot"
205 mkdir
"$WORKSPACE/oot/src"
206 mkdir
"$WORKSPACE/oot/build"
207 cd "$WORKSPACE/oot/src" ||
exit 1
209 tar xvf
"$OUTDIR/$TARBALL_FILE" --strip 1
210 cd "$WORKSPACE/oot/build" ||
exit 1
211 "$WORKSPACE/oot/src/configure" --prefix="$(mktemp -d)" "${CONF_OPTS[@]}"
214 make -j "$(nproc)" V
=1
218 # Run tests, don't fail now, we want to run the archiving steps
219 make --keep-going check || failed_tests
=1
221 # Copy tap logs for the jenkins tap parser before cleaning the build dir
222 rsync
-a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests
/ "$TAPDIR/oot"
224 # Clean the build directory
228 # Exit with failure if any of the tests failed