X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=scripts%2Fcommon%2Fcoverity.sh;h=a224f388fc16980521756b440ac1cce56a270027;hb=51c9c62db1805a4cdd96be18df4082f1ac5d81c5;hp=928575c7af3d9c26ac842281d0954dc3c9128fad;hpb=187bdd07d7b7b7431742e7bcaec07e5ba628023e;p=lttng-ci.git diff --git a/scripts/common/coverity.sh b/scripts/common/coverity.sh index 928575c..a224f38 100755 --- a/scripts/common/coverity.sh +++ b/scripts/common/coverity.sh @@ -1,7 +1,7 @@ -#!/bin/bash -exu +#!/bin/bash # -# Copyright (C) 2015 - Michael Jeanson -# Jonathan Rajotte-Julien +# Copyright (C) 2020 Michael Jeanson +# Copyright (C) 2015 Jonathan Rajotte-Julien # # 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,6 +16,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +set -exu + +# Required variables +WORKSPACE=${WORKSPACE:-} + # Coverity settings # The project name and token have to be provided trough env variables #COVERITY_SCAN_PROJECT_NAME="" @@ -25,6 +30,17 @@ 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" +DEPS_INC="$WORKSPACE/deps/build/include" +DEPS_LIB="$WORKSPACE/deps/build/lib" +DEPS_PKGCONFIG="$DEPS_LIB/pkgconfig" +DEPS_BIN="$WORKSPACE/deps/build/bin" + +export PATH="$DEPS_BIN:$PATH" +export LD_LIBRARY_PATH="$DEPS_LIB:${LD_LIBRARY_PATH:-}" +export PKG_CONFIG_PATH="$DEPS_PKGCONFIG" +export CPPFLAGS="-I$DEPS_INC" +export LDFLAGS="-L$DEPS_LIB" + SRCDIR="$WORKSPACE/src/${COVERITY_SCAN_PROJECT_NAME}" TMPDIR="$WORKSPACE/tmp" @@ -51,7 +67,7 @@ export TMPDIR case "$COVERITY_SCAN_PROJECT_NAME" in babeltrace) - CONF_OPTS="--enable-python-bindings --enable-python-bindings-doc" + CONF_OPTS="--enable-python-bindings --enable-python-bindings-doc --enable-python-plugins" BUILD_TYPE="autotools" ;; liburcu) @@ -87,57 +103,17 @@ linux-rseq) ;; 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:-}" -fi - - -# lttng-ust dependency -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:-}" -fi - if [ -d "$WORKSPACE/src/linux" ]; then export KERNELDIR="$WORKSPACE/src/linux" fi -# Hack to get coverity with gcc >= 7 -# -# We have to define the _Float* types as those are not defined by coverity and as result -# the codes linking agains those (pretty much anything linking against stdlib.h and math.h) -# won't be covered. -echo " -#ifdef __cplusplus -extern \"C\" { -#endif - -#define _Float128 long double -#define _Float64x long double -#define _Float64 double -#define _Float32x double -#define _Float32 float - -#ifdef __cplusplus -} -#endif" >> /tmp/coverity.h - -export CPPFLAGS="-include /tmp/coverity.h ${CPPFLAGS:-}" - +# Enter the source directory +cd "$SRCDIR" # Verify upload is permitted +# Added "--insecure" because Coverity can't be bothered to properly install SSL certificate chains set +x -AUTH_RES=$(curl -s --form project="$COVERITY_SCAN_PROJECT_NAME" --form token="$COVERITY_SCAN_TOKEN" $SCAN_URL/api/upload_permitted) +AUTH_RES=$(curl -s --insecure --form project="$COVERITY_SCAN_PROJECT_NAME" --form token="$COVERITY_SCAN_TOKEN" $SCAN_URL/api/upload_permitted) set -x if [ "$AUTH_RES" = "Access denied" ]; then echo -e "\033[33;1mCoverity Scan API access denied. Check COVERITY_SCAN_PROJECT_NAME and COVERITY_SCAN_TOKEN.\033[0m" @@ -159,7 +135,7 @@ if [ ! -d "$TOOL_BASE" ]; then if [ ! -e "$TOOL_ARCHIVE" ]; then echo -e "\033[33;1mDownloading Coverity Scan Analysis Tool...\033[0m" set +x - wget -nv -O "$TOOL_ARCHIVE" "$TOOL_URL" --post-data "project=$COVERITY_SCAN_PROJECT_NAME&token=$COVERITY_SCAN_TOKEN" + curl -s --insecure --form project="$COVERITY_SCAN_PROJECT_NAME" --form token="$COVERITY_SCAN_TOKEN" -o "$TOOL_ARCHIVE" "$TOOL_URL" set -x fi @@ -174,8 +150,6 @@ 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') # Build @@ -203,7 +177,8 @@ autotools) ;; linux-rseq) make defconfig - cov-build --dir "$RESULTS_DIR" $COVERITY_SCAN_BUILD_OPTIONS make -j"$NPROC" kernel/rseq.o kernel/cpu_opv.o V=1 + make -j"$NPROC" prepare + cov-build --dir "$RESULTS_DIR" $COVERITY_SCAN_BUILD_OPTIONS make -j"$NPROC" kernel/rseq.o kernel/do_on_cpu/core.o kernel/do_on_cpu/interpreter.o kernel/do_on_cpu/validate.o V=1 ;; *) echo "Unsupported build type: $BUILD_TYPE" @@ -224,7 +199,7 @@ tar czf $RESULTS_ARCHIVE $RESULTS_DIR_NAME # Upload results echo -e "\033[33;1mUploading Coverity Scan Analysis results...\033[0m" set +x -response=$(curl \ +response=$(curl --insecure \ --silent --write-out "\n%{http_code}\n" \ --form project="$COVERITY_SCAN_PROJECT_NAME" \ --form token="$COVERITY_SCAN_TOKEN" \