From ed73ea036cff9db9dfe6dddb011e9d8d58ff0feb Mon Sep 17 00:00:00 2001 From: Riccardo Schirone Date: Fri, 6 Jul 2018 23:35:55 +0200 Subject: [PATCH] travis.yml: try to run ASAN on travis (#10645) * fixing travis with docker. Env vars weren't passed to docker, so it was compiling always in the same way and not with clang/gcc * replacing damo22/r2-travis with radareorg/r2-travis * introduce an ASAN build on travis --- .travis.yml | 11 ++++++++--- Dockerfile.travis | 1 + travis-extract-var.sh | 24 ++++++++++++++++++++++++ travis-script | 8 +++++--- 4 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 travis-extract-var.sh diff --git a/.travis.yml b/.travis.yml index ec361b482b..77cd604fce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,14 +14,18 @@ matrix: env: COMPILER_NAME=gcc CXX=g++ CC=gcc - os: linux env: COMPILER_NAME=clang CXX=clang++ CC=clang + - os: linux + env: COMPILER_NAME=clang CXX=clang++ CC=clang CFLAGS="-O0 -ggdb -fsanitize=address -fno-omit-frame-pointer" LDFLAGS="-O0 -ggdb -fsanitize=address -fno-omit-frame-pointer" ASAN_OPTIONS=detect_odr_violation=0 - os: osx env: COMPILER_NAME=clang CXX=clang++ CC=clang - + allow_failures: + - os: linux + env: COMPILER_NAME=clang CXX=clang++ CC=clang CFLAGS="-O0 -ggdb -fsanitize=address -fno-omit-frame-pointer" LDFLAGS="-O0 -ggdb -fsanitize=address -fno-omit-frame-pointer" ASAN_OPTIONS=detect_odr_violation=0 cache: - ccache before_install: - - if [ "$TRAVIS_OS_NAME" != "osx" ]; then docker pull damo22/r2-travis || docker build -t damo22/r2-travis:latest -f Dockerfile.travis . ; else rm -rf .nvm && git clone https://github.com/creationix/nvm.git .nvm && (cd .nvm && git checkout `git describe --abbrev=0 --tags`) && . .nvm/nvm.sh && nvm install 8.11.3; fi + - if [ "$TRAVIS_OS_NAME" != "osx" ]; then docker pull radareorg/r2-travis || docker build -t radareorg/r2-travis:latest -f Dockerfile.travis . ; else rm -rf .nvm && git clone https://github.com/creationix/nvm.git .nvm && (cd .nvm && git checkout `git describe --abbrev=0 --tags`) && . .nvm/nvm.sh && nvm install 8.11.3; fi script: - export PR_NAME=$(echo $TRAVIS_PULL_REQUEST_SLUG | cut -d'/' -f1) @@ -32,7 +36,8 @@ script: - export R2R_BRANCH=$([ -n "${TRAVIS_PULL_REQUEST_BRANCH}" ] && echo "${TRAVIS_PULL_REQUEST_BRANCH}" || echo "${R2R_DEFAULT_BRANCH}") - if [ "${R2R_BRANCH}" = master ]; then USER_NAME=radare; fi - export R2R_REPO=$(doc/repo PR_REGRESSIONS | sed "s/__USER__/${USER_NAME}/g") - - if [ "$TRAVIS_OS_NAME" != "osx" ]; then docker run -v /home/travis/.ccache:/root/.ccache -v ${TRAVIS_BUILD_DIR}:${TRAVIS_BUILD_DIR} --entrypoint "/bin/bash" damo22/r2-travis:latest -c ". /src/.nvm/nvm.sh; cd ${TRAVIS_BUILD_DIR}; R2R_BRANCH=${R2R_BRANCH} R2R_REPO=${R2R_REPO} R2R_DEFAULT_BRANCH=${R2R_DEFAULT_BRANCH} R2R_DEFAULT_REPO=${R2R_DEFAULT_REPO} TRAVIS_BUILD_DIR=${TRAVIS_BUILD_DIR} bash travis-script"; else bash travis-script; fi + - if [ "$TRAVIS_OS_NAME" != "osx" ]; then bash ./travis-extract-var.sh > docker-env.txt ; cat docker-env.txt ; fi + - if [ "$TRAVIS_OS_NAME" != "osx" ]; then docker run -v /home/travis/.ccache:/root/.ccache -v ${TRAVIS_BUILD_DIR}:${TRAVIS_BUILD_DIR} --env-file=docker-env.txt --entrypoint "/bin/bash" radareorg/r2-travis:latest -c ". /src/.nvm/nvm.sh; cd ${TRAVIS_BUILD_DIR}; bash travis-script"; else bash travis-script; fi notifications: irc: "chat.freenode.net#radare" diff --git a/Dockerfile.travis b/Dockerfile.travis index c97a430f8c..1dc6c609a5 100644 --- a/Dockerfile.travis +++ b/Dockerfile.travis @@ -18,6 +18,7 @@ RUN dnf install -y \ git \ binutils \ cabextract \ + libasan \ libcurl-devel \ elfutils-libelf-devel \ elfutils-libelf-devel-static \ diff --git a/travis-extract-var.sh b/travis-extract-var.sh new file mode 100644 index 0000000000..5d6e2cda12 --- /dev/null +++ b/travis-extract-var.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +print_var() +{ + VAR_NAME=$1 + VAR_VALUE=$2 + if [ "${VAR_VALUE}" != "" ] ; then + echo "${VAR_NAME}=${VAR_VALUE}" + fi +} + +env -0 | while IFS='=' read -r -d '' n v; do + if [[ "${n}" =~ ^TRAVIS_* || "${n}" =~ ^R2* || "${n}" =~ ^ASAN* ]]; then + print_var "${n}" "${v}" + fi +done + +# print extra variables +print_var CC "${CC}" +print_var CXX "${CXX}" +print_var CFLAGS "${CFLAGS}" +print_var LDFLAGS "${LDFLAGS}" +print_var CXXFLAGS "${CXXFLAGS}" + diff --git a/travis-script b/travis-script index 71d674e676..8d9ada0a80 100644 --- a/travis-script +++ b/travis-script @@ -1,12 +1,14 @@ #!/bin/bash +set -x + export PKG_CONFIG_PATH=${TRAVIS_BUILD_DIR}/pkgcfg:${PKG_CONFIG_PATH} export PATH=${TRAVIS_BUILD_DIR}/install/bin:${PATH} export LD_LIBRARY_PATH=${TRAVIS_BUILD_DIR}/install/lib:${LD_LIBRARY_PATH} git clone --depth 1 --branch "${R2R_BRANCH}" "${R2R_REPO}" || true # If cloning fails that's not an error: we simply fallback to master. ls radare2-regressions >/dev/null 2>&1 || git clone --depth 1 --branch "${R2R_DEFAULT_BRANCH}" "${R2R_DEFAULT_REPO}" -./configure --prefix=${TRAVIS_BUILD_DIR}/install > /dev/null -make -s -j2 > /dev/null -make install > /dev/null +./configure --prefix=${TRAVIS_BUILD_DIR}/install > /dev/null || exit 1 +make -s -j2 > /dev/null || exit 1 +make install > /dev/null || exit 1 #[ "$TRAVIS_OS_NAME" != "osx" ] && mkdir -p /tmp/kcov && pushd /tmp/kcov #[ "$TRAVIS_OS_NAME" != "osx" ] && mkdir ${TRAVIS_BUILD_DIR}/kcov #[ "$TRAVIS_OS_NAME" != "osx" ] && wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz && tar xzf master.tar.gz && mkdir kcov-master/build && cd kcov-master/build && cmake .. && make && make install DESTDIR=../tmp && popd