From 069752b72613b772a9536a3e7f15fa75097f2946 Mon Sep 17 00:00:00 2001 From: practicalswift Date: Tue, 27 Nov 2018 10:21:29 +0100 Subject: [PATCH 1/3] build: Enable functional tests in the ThreadSanitizer (TSan) build job --- .travis.yml | 4 ++-- .travis/test_04_install.sh | 3 ++- .travis/test_06_script.sh | 16 +++++++++++++--- test/sanitizer_suppressions/tsan | 11 +++-------- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index d051f37d9..a7c6e03f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -99,9 +99,9 @@ jobs: DOCKER_NAME_TAG=ubuntu:16.04 PACKAGES="clang llvm python3-zmq qtbase5-dev qttools5-dev-tools libssl-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libprotobuf-dev protobuf-compiler libqrencode-dev" NO_DEPENDS=1 - RUN_FUNCTIONAL_TESTS=false # Disabled for now. TODO identify suppressions or exclude specific tests + FUNCTIONAL_TESTS_CONFIG="--exclude feature_block.py,p2p_invalid_messages.py" GOAL="install" - BITCOIN_CONFIG="--enable-zmq --with-incompatible-bdb --with-gui=qt5 CPPFLAGS=-DDEBUG_LOCKORDER --with-sanitizers=thread --disable-hardening --disable-asm CC=clang CXX=clang++" + BITCOIN_CONFIG="--enable-zmq --disable-wallet --with-gui=qt5 CPPFLAGS=-DDEBUG_LOCKORDER --with-sanitizers=thread --disable-hardening --disable-asm CC=clang CXX=clang++" # x86_64 Linux (no depends, only system libs, sanitizers: address/leak (ASan + LSan) + undefined (UBSan) + integer) - stage: test env: >- diff --git a/.travis/test_04_install.sh b/.travis/test_04_install.sh index 03a61ea9f..3f7415811 100755 --- a/.travis/test_04_install.sh +++ b/.travis/test_04_install.sh @@ -7,9 +7,10 @@ export LC_ALL=C.UTF-8 travis_retry docker pull "$DOCKER_NAME_TAG" +mkdir -p "${TRAVIS_BUILD_DIR}/sanitizer-output/" export ASAN_OPTIONS="" export LSAN_OPTIONS="suppressions=${TRAVIS_BUILD_DIR}/test/sanitizer_suppressions/lsan" -export TSAN_OPTIONS="suppressions=${TRAVIS_BUILD_DIR}/test/sanitizer_suppressions/tsan" +export TSAN_OPTIONS="suppressions=${TRAVIS_BUILD_DIR}/test/sanitizer_suppressions/tsan:log_path=${TRAVIS_BUILD_DIR}/sanitizer-output/tsan" export UBSAN_OPTIONS="suppressions=${TRAVIS_BUILD_DIR}/test/sanitizer_suppressions/ubsan:print_stacktrace=1:halt_on_error=1" env | grep -E '^(BITCOIN_CONFIG|CCACHE_|WINEDEBUG|LC_ALL|BOOST_TEST_RANDOM|CONFIG_SHELL|(ASAN|LSAN|TSAN|UBSAN)_OPTIONS)' | tee /tmp/env if [[ $HOST = *-mingw32 ]]; then diff --git a/.travis/test_06_script.sh b/.travis/test_06_script.sh index 506d2b518..688387241 100755 --- a/.travis/test_06_script.sh +++ b/.travis/test_06_script.sh @@ -41,12 +41,19 @@ DOCKER_EXEC ./configure --cache-file=../config.cache $BITCOIN_CONFIG_ALL $BITCOI END_FOLD BEGIN_FOLD build -DOCKER_EXEC make $MAKEJOBS $GOAL || ( echo "Build failure. Verbose build follows." && DOCKER_EXEC make $GOAL V=1 ; false ) +DOCKER_EXEC make $MAKEJOBS $GOAL || ( + echo "Build failure. Verbose build follows." && DOCKER_EXEC make $GOAL V=1 + DOCKER_EXEC "cat ${TRAVIS_BUILD_DIR}/sanitizer-output/* 2> /dev/null" + false +) END_FOLD if [ "$RUN_UNIT_TESTS" = "true" ]; then BEGIN_FOLD unit-tests - DOCKER_EXEC LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/depends/$HOST/lib make $MAKEJOBS check VERBOSE=1 + DOCKER_EXEC LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/depends/$HOST/lib make $MAKEJOBS check VERBOSE=1 || ( + DOCKER_EXEC "cat ${TRAVIS_BUILD_DIR}/sanitizer-output/* 2> /dev/null" + false + ) END_FOLD fi @@ -56,6 +63,9 @@ fi if [ "$RUN_FUNCTIONAL_TESTS" = "true" ]; then BEGIN_FOLD functional-tests - DOCKER_EXEC test/functional/test_runner.py --ci --combinedlogslen=4000 --coverage --quiet --failfast ${extended} ${FUNCTIONAL_TESTS_CONFIG} + DOCKER_EXEC test/functional/test_runner.py --ci --combinedlogslen=4000 --coverage --quiet --failfast ${extended} ${FUNCTIONAL_TESTS_CONFIG} || ( + DOCKER_EXEC "cat ${TRAVIS_BUILD_DIR}/sanitizer-output/* 2> /dev/null" + false + ) END_FOLD fi diff --git a/test/sanitizer_suppressions/tsan b/test/sanitizer_suppressions/tsan index 996f342eb..70eea3436 100644 --- a/test/sanitizer_suppressions/tsan +++ b/test/sanitizer_suppressions/tsan @@ -11,11 +11,6 @@ deadlock:TestPotentialDeadLockDetected race:src/qt/test/* deadlock:src/qt/test/* -# WIP: Unidentified suppressions to run the functional tests -#race:zmqpublishnotifier.cpp -# -#deadlock:CreateWalletFromFile -#deadlock:importprivkey -#deadlock:walletdb.h -#deadlock:walletdb.cpp -#deadlock:wallet/db.cpp +# External libraries +deadlock:libdb +race:libzmq From 5e5138a721738f47053d915e4c65f925838ad5b4 Mon Sep 17 00:00:00 2001 From: Chun Kuan Lee Date: Sat, 15 Dec 2018 00:14:50 +0800 Subject: [PATCH 2/3] travis: Use trap and set -e errtrace --- .travis/test_06_script.sh | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/.travis/test_06_script.sh b/.travis/test_06_script.sh index 688387241..618aa2c3b 100755 --- a/.travis/test_06_script.sh +++ b/.travis/test_06_script.sh @@ -40,20 +40,16 @@ BEGIN_FOLD configure DOCKER_EXEC ./configure --cache-file=../config.cache $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG || ( cat config.log && false) END_FOLD +set -o errtrace +trap 'DOCKER_EXEC "cat ${TRAVIS_BUILD_DIR}/sanitizer-output/* 2> /dev/null"' ERR + BEGIN_FOLD build -DOCKER_EXEC make $MAKEJOBS $GOAL || ( - echo "Build failure. Verbose build follows." && DOCKER_EXEC make $GOAL V=1 - DOCKER_EXEC "cat ${TRAVIS_BUILD_DIR}/sanitizer-output/* 2> /dev/null" - false -) +DOCKER_EXEC make $MAKEJOBS $GOAL || ( echo "Build failure. Verbose build follows." && DOCKER_EXEC make $GOAL V=1 ; false ) END_FOLD if [ "$RUN_UNIT_TESTS" = "true" ]; then BEGIN_FOLD unit-tests - DOCKER_EXEC LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/depends/$HOST/lib make $MAKEJOBS check VERBOSE=1 || ( - DOCKER_EXEC "cat ${TRAVIS_BUILD_DIR}/sanitizer-output/* 2> /dev/null" - false - ) + DOCKER_EXEC LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/depends/$HOST/lib make $MAKEJOBS check VERBOSE=1 END_FOLD fi @@ -63,9 +59,6 @@ fi if [ "$RUN_FUNCTIONAL_TESTS" = "true" ]; then BEGIN_FOLD functional-tests - DOCKER_EXEC test/functional/test_runner.py --ci --combinedlogslen=4000 --coverage --quiet --failfast ${extended} ${FUNCTIONAL_TESTS_CONFIG} || ( - DOCKER_EXEC "cat ${TRAVIS_BUILD_DIR}/sanitizer-output/* 2> /dev/null" - false - ) + DOCKER_EXEC test/functional/test_runner.py --ci --combinedlogslen=4000 --coverage --quiet --failfast ${extended} ${FUNCTIONAL_TESTS_CONFIG} END_FOLD fi From eaf4070e3a48ac6b9f7ae402c5de2c7117d9ef84 Mon Sep 17 00:00:00 2001 From: practicalswift Date: Tue, 18 Dec 2018 09:33:02 +0100 Subject: [PATCH 3/3] Add suppression for InterruptRPC (fRPCRunning) data race --- test/sanitizer_suppressions/tsan | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/sanitizer_suppressions/tsan b/test/sanitizer_suppressions/tsan index 70eea3436..593e1f54f 100644 --- a/test/sanitizer_suppressions/tsan +++ b/test/sanitizer_suppressions/tsan @@ -7,6 +7,9 @@ deadlock:WalletBatch # Intentional deadlock in tests deadlock:TestPotentialDeadLockDetected +# fRPCRunning race +race:InterruptRPC + # Wildcard for all gui tests, should be replaced with non-wildcard suppressions race:src/qt/test/* deadlock:src/qt/test/*