jjb: lttng-ivc: urcu is now handled by lttng-ivc
[lttng-ci.git] / scripts / lttng-tools / build.sh
index b44dd2c82098f470440890973a9ce5fed8b77288..84f12a2201fd371c49212863430c56283a921bf8 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash -exu
+#!/bin/bash
 # shellcheck disable=SC2103
 #
 # Copyright (C) 2016 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
@@ -17,6 +17,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+set -exu
+
 # Version compare functions
 vercomp () {
     set +u
@@ -70,6 +72,34 @@ verne() {
     [ "$res" -ne "0" ]
 }
 
+failed_configure() {
+    # Assume we are in the configured build directory
+    echo "#################### BEGIN config.log ####################"
+    cat config.log
+    echo "#################### END config.log ####################"
+
+    # End the build with failure
+    exit 1
+}
+
+set_execute_traversal_bit()
+{
+    path=$1
+
+    level="$path"
+    if [ ! -d "$path" ]; then
+        fail "Path is not a directory"
+    fi
+    while level="$(dirname "$level")"
+    do
+        if [ "$level" = / ]; then
+            break
+        fi
+        chmod a+x "$level"
+    done
+    chmod a+x "$path"
+}
+
 # Required variables
 WORKSPACE=${WORKSPACE:-}
 
@@ -213,7 +243,7 @@ sol11-i386)
     RUN_TESTS="no"
     ;;
 
-macosx)
+macos*)
     export MAKE=make
     export TAR=tar
     export NPROC="getconf _NPROCESSORS_ONLN"
@@ -269,6 +299,10 @@ if [ -d "$WORKSPACE/src/lttng-modules" ]; then
     depmod
 fi
 
+# Print build env details
+print_os || true
+print_tooling || true
+
 # Enter the source directory
 cd "$SRCDIR"
 
@@ -350,7 +384,7 @@ oot)
     builddir=$(mktemp -d)
     cd "$builddir"
 
-    "$SRCDIR/configure" "${CONF_OPTS[@]}"
+    "$SRCDIR/configure" "${CONF_OPTS[@]}" || failed_configure
     ;;
 
 dist)
@@ -358,7 +392,7 @@ dist)
 
     # Run configure and generate the tar file
     # in the source directory
-    ./configure "${DIST_CONF_OPTS[@]}"
+    ./configure "${DIST_CONF_OPTS[@]}" || failed_configure
     $MAKE dist
 
     # Create and enter a temporary build directory
@@ -370,7 +404,7 @@ dist)
     $TAR xvf "$SRCDIR"/*.tar.* --strip 1
 
     # Build in extracted source tree
-    ./configure "${CONF_OPTS[@]}"
+    ./configure "${CONF_OPTS[@]}" || failed_configure
     ;;
 
 oot-dist)
@@ -381,7 +415,7 @@ oot-dist)
     cd "$builddir"
 
     # Run configure out of tree and generate the tar file
-    "$SRCDIR/configure" "${DIST_CONF_OPTS[@]}"
+    "$SRCDIR/configure" "${DIST_CONF_OPTS[@]}" || failed_configure
     $MAKE dist
 
     dist_srcdir="$(mktemp -d)"
@@ -397,12 +431,12 @@ oot-dist)
 
     # Run configure from the extracted distribution tar,
     # out of the source tree
-    "$dist_srcdir/configure" "${CONF_OPTS[@]}"
+    "$dist_srcdir/configure" "${CONF_OPTS[@]}" || failed_configure
     ;;
 
 *)
     echo "Standard in-tree build"
-    ./configure "${CONF_OPTS[@]}"
+    ./configure "${CONF_OPTS[@]}" || failed_configure
     ;;
 esac
 
@@ -426,6 +460,21 @@ if [ "$RUN_TESTS" = "yes" ] && [ "$conf" != "no-ust" ]; then
 
     # Run 'unit_tests', 2.8 and up has a new test suite
     if vergte "$PACKAGE_VERSION" "2.8"; then
+       # It is implied that tests depending on LTTNG_ENABLE_DESTRUCTIVE_TESTS
+       # only run for the root user. Note that here `destructive` means that
+       # operations are performed at the host level (add user etc.) that
+       # effectively modify the host. Running those tests are acceptable on our
+       # CI and root jobs since we always run root tests against a `snapshot`
+       # of the host.
+       if [ "$(id -u)" == "0" ]; then
+               # Allow the traversal of all directories leading to the
+               # DEPS_LIBS directory to enable test app run by temp users to
+               # access lttng-ust.
+               set_execute_traversal_bit "$DEPS_LIB"
+               # Allow `all` to interact with all deps libs.
+               chmod a+rwx -R "$DEPS_LIB"
+               export LTTNG_ENABLE_DESTRUCTIVE_TESTS="will-break-my-system"
+       fi
         make --keep-going check || failed_tests=1
         rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests/ "$TAPDIR"
     else
This page took 0.024489 seconds and 4 git commands to generate.