Commit | Line | Data |
---|---|---|
51c9c62d | 1 | #!/bin/bash |
c95cf818 MJ |
2 | # |
3 | # Copyright (C) 2015 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com> | |
4 | # Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com> | |
5 | # | |
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. | |
10 | # | |
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. | |
15 | # | |
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/>. | |
18 | ||
51c9c62d MJ |
19 | set -exu |
20 | ||
c95cf818 MJ |
21 | # Version compare functions |
22 | vercomp () { | |
23 | set +u | |
24 | if [[ "$1" == "$2" ]]; then | |
25 | return 0 | |
26 | fi | |
27 | local IFS=. | |
28 | local i ver1=($1) ver2=($2) | |
29 | # fill empty fields in ver1 with zeros | |
30 | for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); do | |
31 | ver1[i]=0 | |
32 | done | |
33 | for ((i=0; i<${#ver1[@]}; i++)); do | |
34 | if [[ -z ${ver2[i]} ]]; then | |
35 | # fill empty fields in ver2 with zeros | |
36 | ver2[i]=0 | |
37 | fi | |
38 | if ((10#${ver1[i]} > 10#${ver2[i]})); then | |
39 | return 1 | |
40 | fi | |
41 | if ((10#${ver1[i]} < 10#${ver2[i]})); then | |
42 | return 2 | |
43 | fi | |
44 | done | |
45 | set -u | |
46 | return 0 | |
47 | } | |
48 | ||
49 | verlte() { | |
50 | vercomp "$1" "$2"; local res="$?" | |
51 | [ "$res" -eq "0" ] || [ "$res" -eq "2" ] | |
52 | } | |
53 | ||
54 | verlt() { | |
55 | vercomp "$1" "$2"; local res="$?" | |
56 | [ "$res" -eq "2" ] | |
57 | } | |
58 | ||
59 | vergte() { | |
60 | vercomp "$1" "$2"; local res="$?" | |
61 | [ "$res" -eq "0" ] || [ "$res" -eq "1" ] | |
62 | } | |
63 | ||
64 | vergt() { | |
65 | vercomp "$1" "$2"; local res="$?" | |
66 | [ "$res" -eq "1" ] | |
67 | } | |
68 | ||
69 | verne() { | |
70 | vercomp "$1" "$2"; local res="$?" | |
71 | [ "$res" -ne "0" ] | |
72 | } | |
73 | ||
74 | export TERM="xterm-256color" | |
75 | ||
a7f915c4 MJ |
76 | # Required variables |
77 | WORKSPACE=${WORKSPACE:-} | |
78 | ||
c95cf818 MJ |
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" | |
84 | ||
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" | |
90 | ||
91 | export JAVA_HOME="/usr/lib/jvm/default-java" | |
00b991d2 | 92 | export CLASSPATH="$DEPS_JAVA/*:/usr/share/java/log4j-core.jar:/usr/share/java/log4j-1.2.jar" |
c95cf818 MJ |
93 | |
94 | SRCDIR="$WORKSPACE/src/lttng-tools" | |
a7f915c4 | 95 | OUTDIR="$WORKSPACE/out" |
c95cf818 | 96 | TAPDIR="$WORKSPACE/tap" |
a7f915c4 MJ |
97 | |
98 | failed_tests=0 | |
c95cf818 MJ |
99 | |
100 | # Create tmp directory | |
101 | TMPDIR="$WORKSPACE/tmp" | |
102 | mkdir -p "$TMPDIR" | |
103 | ||
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. | |
107 | tmpdir="$(mktemp)" | |
108 | ln -sf "$TMPDIR" "$tmpdir" | |
109 | export TMPDIR="$tmpdir" | |
110 | ||
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 | |
114 | # babeltrace2 | |
115 | if [ -x "$DEPS_BIN/babeltrace2" ]; then | |
116 | ln -s "$DEPS_BIN/babeltrace2" "$DEPS_BIN/babeltrace" | |
117 | fi | |
118 | ||
119 | # When using babeltrace2 make sure that it finds its plugins and | |
120 | # plugin-providers. | |
121 | export BABELTRACE_PLUGIN_PATH="$DEPS_LIB/babeltrace2/plugins/" | |
122 | export LIBBABELTRACE2_PLUGIN_PROVIDER_DIR="$DEPS_LIB/babeltrace2/plugin-providers/" | |
123 | ||
124 | PYTHON2=python2 | |
125 | PYTHON3=python3 | |
126 | ||
127 | # Set default python to python3 for the bindings | |
128 | export PYTHON="$PYTHON3" | |
129 | export PYTHON_CONFIG="/usr/bin/$PYTHON3-config" | |
130 | ||
131 | P2_VERSION=$($PYTHON2 -c "import sys;print(sys.version[:3])") | |
132 | P3_VERSION=$($PYTHON3 -c "import sys;print(sys.version[:3])") | |
133 | ||
134 | UST_PYTHON2="$WORKSPACE/deps/build/lib/python$P2_VERSION/site-packages" | |
135 | UST_PYTHON3="$WORKSPACE/deps/build/lib/python$P3_VERSION/site-packages" | |
136 | ||
137 | export PYTHONPATH="$UST_PYTHON2:$UST_PYTHON3" | |
138 | ||
139 | ||
140 | ||
141 | # Create build and tmp directories | |
a7f915c4 MJ |
142 | rm -rf "$OUTDIR" "$TAPDIR" |
143 | mkdir -p "$OUTDIR" "$TAPDIR" | |
c95cf818 MJ |
144 | |
145 | ||
146 | ||
147 | ||
148 | # Enter the source directory | |
149 | cd "$SRCDIR" | |
150 | ||
151 | # Run bootstrap in the source directory prior to configure | |
152 | ./bootstrap | |
153 | ||
154 | # Get source version from configure script | |
155 | eval "$(grep '^PACKAGE_VERSION=' ./configure)" | |
a7f915c4 MJ |
156 | PACKAGE_VERSION=${PACKAGE_VERSION//\-pre*/} |
157 | ||
158 | CONF_OPTS=("--enable-python-bindings" "--enable-test-java-agent-all" "--enable-test-python-agent-all") | |
c95cf818 MJ |
159 | |
160 | TARBALL_FILE="lttng-tools-$PACKAGE_VERSION.tar.bz2" | |
161 | ||
162 | # Make sure the reported version matches the current git tag | |
a7f915c4 | 163 | GIT_TAG="$(git describe --exact-match --tags "$(git log -n1 --pretty='%h')" || echo 'undefined')" |
c95cf818 MJ |
164 | |
165 | if [ "v$PACKAGE_VERSION" != "$GIT_TAG" ]; then | |
166 | echo "Git checkout is not tagged or doesn't match the reported version." | |
167 | exit 1 | |
168 | fi | |
169 | ||
170 | # Generate release tarball | |
171 | ./configure | |
172 | make dist | |
a7f915c4 | 173 | cp "./$TARBALL_FILE" "$OUTDIR/" |
c95cf818 MJ |
174 | |
175 | ||
176 | # Allow core dumps | |
177 | ulimit -c unlimited | |
178 | ||
179 | # Force the lttng-sessiond path to /bin/true to prevent the spawing of a | |
180 | # lttng-sessiond --daemonize on "lttng create" | |
181 | export LTTNG_SESSIOND_PATH="/bin/true" | |
182 | ||
183 | ||
a7f915c4 | 184 | ## Do an in-tree test build |
c95cf818 MJ |
185 | mkdir "$WORKSPACE/intree" |
186 | cd "$WORKSPACE/intree" || exit 1 | |
a7f915c4 MJ |
187 | |
188 | tar xvf "$OUTDIR/$TARBALL_FILE" --strip 1 | |
189 | ./configure --prefix="$(mktemp -d)" "${CONF_OPTS[@]}" | |
190 | ||
191 | # BUILD! | |
c95cf818 | 192 | make -j "$(nproc)" V=1 |
a7f915c4 | 193 | |
c95cf818 | 194 | make install |
a7f915c4 MJ |
195 | |
196 | # Run tests, don't fail now, we want to run the archiving steps | |
197 | make --keep-going check || failed_tests=1 | |
198 | ||
199 | # Copy tap logs for the jenkins tap parser before cleaning the build dir | |
200 | rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests/ "$TAPDIR/intree" | |
201 | ||
202 | # Clean the build directory | |
c95cf818 MJ |
203 | make clean |
204 | ||
a7f915c4 MJ |
205 | |
206 | ## Do an out-of-tree test build | |
c95cf818 MJ |
207 | mkdir "$WORKSPACE/oot" |
208 | mkdir "$WORKSPACE/oot/src" | |
209 | mkdir "$WORKSPACE/oot/build" | |
210 | cd "$WORKSPACE/oot/src" || exit 1 | |
a7f915c4 MJ |
211 | |
212 | tar xvf "$OUTDIR/$TARBALL_FILE" --strip 1 | |
c95cf818 | 213 | cd "$WORKSPACE/oot/build" || exit 1 |
a7f915c4 MJ |
214 | "$WORKSPACE/oot/src/configure" --prefix="$(mktemp -d)" "${CONF_OPTS[@]}" |
215 | ||
216 | # BUILD! | |
c95cf818 | 217 | make -j "$(nproc)" V=1 |
a7f915c4 | 218 | |
c95cf818 | 219 | make install |
a7f915c4 MJ |
220 | |
221 | # Run tests, don't fail now, we want to run the archiving steps | |
222 | make --keep-going check || failed_tests=1 | |
223 | ||
224 | # Copy tap logs for the jenkins tap parser before cleaning the build dir | |
225 | rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests/ "$TAPDIR/oot" | |
226 | ||
227 | # Clean the build directory | |
c95cf818 MJ |
228 | make clean |
229 | ||
a7f915c4 MJ |
230 | |
231 | # Exit with failure if any of the tests failed | |
232 | exit $failed_tests | |
233 | ||
c95cf818 | 234 | # EOF |