From 1f4fba8c3ff773bb4dfc8ba3d911a2ffe70c323c Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Wed, 18 May 2016 17:16:42 -0400 Subject: [PATCH] lttng-ust: checkout sources in a subdirectory Signed-off-by: Michael Jeanson --- jobs/lttng-ust.yaml | 6 +++- scripts/common/coverity.sh | 55 +++++++++++++++++++++++++++------ scripts/lttng-ust/build.sh | 53 +++++++++++++++---------------- scripts/lttng-ust/scan-build.sh | 47 +++++++++++++++++----------- 4 files changed, 104 insertions(+), 57 deletions(-) diff --git a/jobs/lttng-ust.yaml b/jobs/lttng-ust.yaml index f25d957..e24d182 100644 --- a/jobs/lttng-ust.yaml +++ b/jobs/lttng-ust.yaml @@ -25,6 +25,7 @@ browser-url: https://github.com/{github_user}/{github_name} branches: - origin/{version} + basedir: src/lttng-ust triggers: - pollscm: @@ -78,7 +79,7 @@ # TODO: Scan for open tasks publishers: - tap: - results: 'tap/**/*.tap' + results: 'tap/**/*.log' failed-tests-mark-build-as-failure: true todo-is-failure: false - warnings: @@ -319,6 +320,9 @@ publishers: - workspace-cleanup + - archive: + artifacts: 'analysis-results.tgz,cov-int/**' + allow-empty: false # TODO - job-template: diff --git a/scripts/common/coverity.sh b/scripts/common/coverity.sh index 4c519c3..37b23fc 100755 --- a/scripts/common/coverity.sh +++ b/scripts/common/coverity.sh @@ -20,31 +20,63 @@ # The project name and token have to be provided trough env variables #COVERITY_SCAN_PROJECT_NAME="" #COVERITY_SCAN_TOKEN="" -COVERITY_SCAN_VERSION=`git describe --always | sed 's|-|.|g'` COVERITY_SCAN_DESCRIPTION="Automated CI build" COVERITY_SCAN_NOTIFICATION_EMAIL="ci-notification@lists.lttng.org" COVERITY_SCAN_BUILD_OPTIONS="" #COVERITY_SCAN_BUILD_OPTIONS="--return-emit-failures 8 --parse-error-threshold 85" +SRCDIR="$WORKSPACE/src/${COVERITY_SCAN_PROJECT_NAME}" +TMPDIR="$WORKSPACE/tmp" + NPROC=$(nproc) PLATFORM=$(uname) export CFLAGS="-O0 -g -DDEBUG" -TOOL_ARCHIVE=/tmp/cov-analysis-${PLATFORM}.tgz +TOOL_ARCHIVE="$TMPDIR/cov-analysis-${PLATFORM}.tgz" TOOL_URL=https://scan.coverity.com/download/${PLATFORM} -TOOL_BASE=/tmp/coverity-scan-analysis +TOOL_BASE="$TMPDIR/coverity-scan-analysis" UPLOAD_URL="https://scan.coverity.com/builds" SCAN_URL="https://scan.coverity.com" -RESULTS_DIR="cov-int" +RESULTS_DIR_NAME="cov-int" +RESULTS_DIR="$WORKSPACE/$RESULTS_DIR_NAME" +RESULTS_ARCHIVE=analysis-results.tgz +# Create tmp directory +rm -rf "$TMPDIR" +mkdir -p "$TMPDIR" + +export TMPDIR + +case "$COVERITY_SCAN_PROJECT_NAME" in +babeltrace) + CONF_OPTS="--enable-python-bindings --enable-python-bindings-doc" + ;; +liburcu) + CONF_OPTS="" + ;; +lttng-modules) + CONF_OPTS="" + ;; +lttng-tools) + CONF_OPTS="" + ;; +lttng-ust) + CONF_OPTS="--enable-java-agent-all --enable-python-agent" + export CLASSPATH="/usr/share/java/log4j-1.2.jar" + ;; +*) + echo "Generic project, no configure options." + CONF_OPTS="" + ;; +esac # liburcu dependency if [ -d "$WORKSPACE/deps/liburcu" ]; then URCU_INCS="$WORKSPACE/deps/liburcu/build/include/" URCU_LIBS="$WORKSPACE/deps/liburcu/build/lib/" - + export CPPFLAGS="-I$URCU_INCS ${CPPFLAGS:-}" export LDFLAGS="-L$URCU_LIBS ${LDFLAGS:-}" export LD_LIBRARY_PATH="$URCU_LIBS:${LD_LIBRARY_PATH:-}" @@ -55,7 +87,7 @@ fi if [ -d "$WORKSPACE/deps/lttng-ust" ]; then UST_INCS="$WORKSPACE/deps/lttng-ust/build/include/" UST_LIBS="$WORKSPACE/deps/lttng-ust/build/lib/" - + export CPPFLAGS="-I$UST_INCS ${CPPFLAGS:-}" export LDFLAGS="-L$UST_LIBS ${LDFLAGS:-}" export LD_LIBRARY_PATH="$UST_LIBS:${LD_LIBRARY_PATH:-}" @@ -105,11 +137,14 @@ fi TOOL_DIR=`find $TOOL_BASE -type d -name 'cov-analysis*'` export PATH=$TOOL_DIR/bin:$PATH +cd "$SRCDIR" + +COVERITY_SCAN_VERSION=`git describe --always | sed 's|-|.|g'` # Prepare build dir if [ -f "./bootstrap" ]; then ./bootstrap - ./configure + ./configure $CONF_OPTS fi # Build @@ -117,11 +152,11 @@ echo -e "\033[33;1mRunning Coverity Scan Analysis Tool...\033[0m" cov-build --dir $RESULTS_DIR $COVERITY_SCAN_BUILD_OPTIONS make -j$NPROC V=1 cov-import-scm --dir $RESULTS_DIR --scm git --log $RESULTS_DIR/scm_log.txt +cd "${WORKSPACE}" + # Tar results echo -e "\033[33;1mTarring Coverity Scan Analysis results...\033[0m" -RESULTS_ARCHIVE=analysis-results.tgz -tar czf $RESULTS_ARCHIVE $RESULTS_DIR - +tar czf $RESULTS_ARCHIVE $RESULTS_DIR_NAME # Upload results echo -e "\033[33;1mUploading Coverity Scan Analysis results...\033[0m" diff --git a/scripts/lttng-ust/build.sh b/scripts/lttng-ust/build.sh index 3b890c2..21094f5 100755 --- a/scripts/lttng-ust/build.sh +++ b/scripts/lttng-ust/build.sh @@ -1,6 +1,7 @@ #!/bin/bash -exu # -# Copyright (C) 2015 - Jonathan Rajotte-Julien +# Copyright (C) 2015, Jonathan Rajotte-Julien +# 2016, Michael Jeanson # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,17 +17,20 @@ # along with this program. If not, see . -# Create build directory -rm -rf $WORKSPACE/build -mkdir -p $WORKSPACE/build - # liburcu URCU_INCS="$WORKSPACE/deps/liburcu/build/include/" URCU_LIBS="$WORKSPACE/deps/liburcu/build/lib/" - +SRCDIR="$WORKSPACE/src/lttng-ust" +TMPDIR="$WORKSPACE/tmp" PREFIX="$WORKSPACE/build" +# Create build and tmp directories +rm -rf "$PREFIX" "$TMPDIR" +mkdir -p "$PREFIX" "$TMPDIR" + +export TMPDIR + # Set platform variables case "$arch" in *) @@ -71,8 +75,10 @@ python-agent) ;; esac +# Enter the source directory +cd "$SRCDIR" -# Run bootstrap prior to configure +# Run bootstrap in the source directory prior to configure ./bootstrap @@ -83,14 +89,14 @@ esac # # Make sure to move to the build_path and configure # before continuing -BUILD_PATH=$WORKSPACE +BUILD_PATH=$SRCDIR case "$build" in oot) echo "Out of tree build" BUILD_PATH=$WORKSPACE/oot mkdir -p $BUILD_PATH cd $BUILD_PATH - $WORKSPACE/configure --prefix=$PREFIX $CONF_OPTS + $SRCDIR/configure --prefix=$PREFIX $CONF_OPTS ;; dist) @@ -98,7 +104,7 @@ dist) BUILD_PATH=`mktemp -d` # Initial configure and generate tarball - ./configure + $SRCDIR/configure $MAKE dist mkdir -p $BUILD_PATH @@ -112,9 +118,8 @@ dist) ;; *) - BUILD_PATH=$WORKSPACE - echo "Standard tree build" - $WORKSPACE/configure --prefix=$PREFIX $CONF_OPTS + echo "Standard in-tree build" + $BUILD_PATH/configure --prefix=$PREFIX $CONF_OPTS ;; esac @@ -123,31 +128,23 @@ $MAKE -j `$NPROC` V=1 $MAKE install # Run tests -rm -rf $WORKSPACE/tap -mkdir -p $WORKSPACE/tap/unit - -cd $BUILD_PATH/tests - -prove --merge --exec '' - < $BUILD_PATH/tests/unit_tests --archive $WORKSPACE/tap/unit/ || true - -# TAP plugin is having a hard time with .yml files. -rm -f $WORKSPACE/tap/unit/meta.yml +$MAKE check -# And also with files without extension, so rename all result to *.tap -find $WORKSPACE/tap/unit/ -type f -exec mv {} {}.tap \; +# Copy tap logs for the jenkins tap parser +rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests/ "$WORKSPACE/tap" -# Cleanup +# Clean the build directory $MAKE clean # Cleanup rpath in executables and shared libraries -find $WORKSPACE/build/lib -name "*.so" -exec chrpath --delete {} \; +find $PREFIX/lib -name "*.so" -exec chrpath --delete {} \; # Remove libtool .la files -find $WORKSPACE/build/lib -name "*.la" -exec rm -f {} \; +find $PREFIX/lib -name "*.la" -exec rm -f {} \; # Clean temp dir for dist build if [ "$build" = "dist" ]; then - cd $WORKSPACE + cd $SRCDIR rm -rf $BUILD_PATH fi diff --git a/scripts/lttng-ust/scan-build.sh b/scripts/lttng-ust/scan-build.sh index da98d40..39933e3 100755 --- a/scripts/lttng-ust/scan-build.sh +++ b/scripts/lttng-ust/scan-build.sh @@ -1,6 +1,7 @@ #!/bin/sh -exu # # Copyright (C) 2015 - Jonathan Rajotte-Julien +# 2016 - Michael Jeanson # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,16 +19,22 @@ # do not exit immediately if any command fails set +e - -# temp directory to store the scan-build report -SCAN_BUILD_TMPDIR=$( mktemp -d /tmp/scan-build.XXXXXX ) - -# directory to use for archiving the scan-build report + +SRCDIR="$WORKSPACE/src/lttng-ust" +TMPDIR="$WORKSPACE/tmp" +PREFIX="$WORKSPACE/build" + +# Directory to archive the scan-build report SCAN_BUILD_ARCHIVE="${WORKSPACE}/scan-build-archive" -# Create build directory -rm -rf $WORKSPACE/build -mkdir -p $WORKSPACE/build +# Create build and tmp directories +rm -rf "$PREFIX" "$TMPDIR" +mkdir -p "$PREFIX" "$TMPDIR" + +export TMPDIR + +# temp directory to store the scan-build report +SCAN_BUILD_TMPDIR=$( mktemp -d ) # liburcu URCU_INCS="$WORKSPACE/deps/liburcu/build/include/" @@ -38,37 +45,41 @@ export CPPFLAGS="-I$URCU_INCS" export LDFLAGS="-L$URCU_LIBS" export LD_LIBRARY_PATH="$URCU_LIBS:${LD_LIBRARY_PATH:-}" -PREFIX="$WORKSPACE/build" +# Enter the source directory +cd "$SRCDIR" +# Run bootstrap in the source directory prior to configure ./bootstrap + + ./configure --prefix=$PREFIX -make clean + # generate the scan-build report scan-build -k -o ${SCAN_BUILD_TMPDIR} make - + # get the directory name of the report created by scan-build SCAN_BUILD_REPORT=$( find ${SCAN_BUILD_TMPDIR} -maxdepth 1 -not -empty -not -name `basename ${SCAN_BUILD_TMPDIR}` ) rc=$? - + if [ -z "${SCAN_BUILD_REPORT}" ]; then echo ">>> No new bugs identified." echo ">>> No scan-build report has been generated" else echo ">>> New scan-build report generated in ${SCAN_BUILD_REPORT}" - + if [ ! -d "${SCAN_BUILD_ARCHIVE}" ]; then echo ">>> Creating scan-build archive directory" - install -d -o jenkins -g jenkins -m 0755 "${SCAN_BUILD_ARCHIVE}" + mkdir "${SCAN_BUILD_ARCHIVE}" else echo ">>> Removing any previous scan-build reports from ${SCAN_BUILD_ARCHIVE}" - rm -f ${SCAN_BUILD_ARCHIVE}/* + rm -f "${SCAN_BUILD_ARCHIVE}/*" fi - + echo ">>> Archiving scan-build report to ${SCAN_BUILD_ARCHIVE}" mv ${SCAN_BUILD_REPORT}/* ${SCAN_BUILD_ARCHIVE}/ - + echo ">>> Removing any temporary files and directories" rm -rf "${SCAN_BUILD_TMPDIR}" fi - + exit ${rc} -- 2.34.1