From 009d4f38ab7c857b5fa389e81bbfb722de71b8c1 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Sat, 29 Jul 2017 12:52:39 -0700 Subject: [PATCH] Tidy up Travis build scripts --- .travis.yml | 112 ++++++++-------- CHANGELOG.md | 7 + CMakeLists.txt | 2 +- Jamfile | 2 +- {scripts => build}/blacklist.supp | 0 build/build-and-test.sh | 146 +++++++++++++++++++++ {scripts => build}/field.txt | 0 {scripts => build}/install-dependencies.sh | 20 +-- {scripts => build}/local-travis.sh | 0 {scripts => build}/make_field.sh | 0 {scripts => build}/valgrind.supp | 0 scripts/build-and-test.sh | 128 ------------------ scripts/fuzzingclient.json | 14 -- scripts/parseautobahn.py | 43 ------ scripts/run-with-debugger.sh | 22 ---- scripts/run-with-gdb.sh | 9 -- 16 files changed, 217 insertions(+), 288 deletions(-) rename {scripts => build}/blacklist.supp (100%) create mode 100755 build/build-and-test.sh rename {scripts => build}/field.txt (100%) rename {scripts => build}/install-dependencies.sh (71%) rename {scripts => build}/local-travis.sh (100%) rename {scripts => build}/make_field.sh (100%) mode change 100644 => 100755 rename {scripts => build}/valgrind.supp (100%) delete mode 100755 scripts/build-and-test.sh delete mode 100644 scripts/fuzzingclient.json delete mode 100644 scripts/parseautobahn.py delete mode 100755 scripts/run-with-debugger.sh delete mode 100755 scripts/run-with-gdb.sh diff --git a/.travis.yml b/.travis.yml index bb52ac0e..222d53be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,15 @@ -sudo: false -language: cpp +# +# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# -env: - global: - - LLVM_VERSION=3.8.0 - - LCOV_ROOT=$HOME/lcov - - VALGRIND_ROOT=$HOME/valgrind-install +sudo: false + +language: cpp addons: apt: @@ -21,20 +25,17 @@ addons: matrix: include: - # gcc coverage - - compiler: gcc + # GCC 6.0, Debug + Coverage + - os: linux + compiler: g++-6 env: + - VARIANT=coverage - TOOLSET=gcc - COMPILER=g++-6 - CXXSTD=c++11 - - GCC_VER=6 - - VARIANT=coverage - - ADDRESS_MODEL=64 - - DO_VALGRIND=false addons: apt: packages: - - gcc-6 - g++-6 - lcov - libssl-dev @@ -42,39 +43,18 @@ matrix: sources: - *base_sources - # older GCC, release - - compiler: gcc + # GCC 5.0, Release + Valgrind + - os: linux + compiler: g++-5 env: - - TOOLSET=gcc - - COMPILER=g++-4.8 - - CXXSTD=c++11 - - GCC_VER=4.8 + - DO_VALGRIND=true - VARIANT=release - - DO_VALGRIND=false - - ADDRESS_MODEL=64 - addons: - apt: - packages: - - gcc-4.8 - - g++-4.8 - - *base_packages - sources: - - *base_sources - - # later GCC - - compiler: gcc - env: - TOOLSET=gcc - COMPILER=g++-5 - CXXSTD=c++11 - - GCC_VER=5 - - VARIANT=release - - DO_VALGRIND=true - - ADDRESS_MODEL=64 addons: apt: packages: - - gcc-5 - g++-5 - libssl-dev - valgrind @@ -82,31 +62,56 @@ matrix: sources: - *base_sources - # clang ubsan+asan - - compiler: clang + # Clang 3.8, UBasan + - os: linux + compiler: clang++-3.8 env: - - TOOLSET=clang - - COMPILER=clang++ - - CXXSTD=c++11 - - GCC_VER=5 - VARIANT=ubasan - - CLANG_VER=3.8 - - DO_VALGRIND=false - - ADDRESS_MODEL=64 + - TOOLSET=clang + - COMPILER=clang++-3.8 + - CXXSTD=c++11 - UBSAN_OPTIONS='print_stacktrace=1' - PATH=$PWD/llvm-$LLVM_VERSION/bin:$PATH addons: apt: packages: - - gcc-5 - - g++-5 + - clang-3.8 - libssl-dev - *base_packages + sources: + - llvm-toolchain-precise-3.8 + - *base_sources + + # GCC 4.8, Release + - os: linux + compiler: g++-4.8 + env: + - VARIANT=release + - TOOLSET=gcc + - COMPILER=g++-4.8 + - CXXSTD=c++11 + addons: + apt: + packages: + - g++-4.8 + - *base_packages sources: - *base_sources + # OSX Clang, C++14, Debug + - os: osx + compiler: clang++ + env: + - VARIANT=debug + - TOOLSET=clang + - COMPILER=clang++ + - CXXSTD=c++14 + + # OSX + before_install: &base_before_install - - scripts/install-dependencies.sh + #- build/install-dependencies.sh + - pip install --user https://github.com/codecov/codecov-python/archive/master.zip install: - export BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true @@ -181,7 +186,10 @@ install: - ./bootstrap.sh script: - - travis_retry libs/beast/scripts/build-and-test.sh + - |- + echo "using $TOOLSET : : $COMPILER : -std=$CXXSTD ;" > ~/user-config.jam + - cd ../boost-root + - travis_retry libs/beast/build/build-and-test.sh after_script: - cat nohup.out || echo "nohup.out already deleted" diff --git a/CHANGELOG.md b/CHANGELOG.md index af2b8895..b4dcde2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +Version 95: + +* Tidy up Travis build scripts +* Move scripts to build/ + +-------------------------------------------------------------------------------- + Version 94: * Use off-site Quick Start link temporarily diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ce8fc27..fb13ae50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,7 +147,7 @@ elseif ("${VARIANT}" STREQUAL "ubasan") else() set (CMAKE_BUILD_TYPE RELWITHDEBINFO) set (CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -DBOOST_BEAST_NO_SLOW_TESTS=1 -msse4.2 -funsigned-char -fno-omit-frame-pointer -fsanitize=address,undefined -fsanitize-blacklist=${PROJECT_SOURCE_DIR}/scripts/blacklist.supp") + "${CMAKE_CXX_FLAGS} -DBOOST_BEAST_NO_SLOW_TESTS=1 -msse4.2 -funsigned-char -fno-omit-frame-pointer -fsanitize=address,undefined -fsanitize-blacklist=${PROJECT_SOURCE_DIR}/build/blacklist.supp") set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address,undefined") endif() diff --git a/Jamfile b/Jamfile index 7849f9c7..70f217bd 100644 --- a/Jamfile +++ b/Jamfile @@ -62,7 +62,7 @@ variant ubasan : release : - "-msse4.2 -funsigned-char -fno-omit-frame-pointer -fsanitize=address,undefined -fsanitize-blacklist=libs/beast/scripts/blacklist.supp" + "-msse4.2 -funsigned-char -fno-omit-frame-pointer -fsanitize=address,undefined -fsanitize-blacklist=libs/beast/build/blacklist.supp" "-fsanitize=address,undefined" ; diff --git a/scripts/blacklist.supp b/build/blacklist.supp similarity index 100% rename from scripts/blacklist.supp rename to build/blacklist.supp diff --git a/build/build-and-test.sh b/build/build-and-test.sh new file mode 100755 index 00000000..c06b50d3 --- /dev/null +++ b/build/build-and-test.sh @@ -0,0 +1,146 @@ +#!/usr/bin/env bash + +# add 'x' for command tracing +set -eu + +#------------------------------------------------------------------------------- +# +# Utilities +# + +# For builds not triggered by a pull request TRAVIS_BRANCH is the name of the +# branch currently being built; whereas for builds triggered by a pull request +# it is the name of the branch targeted by the pull request (in many cases this +# will be master). +MAIN_BRANCH="0" +if [[ $TRAVIS_BRANCH == "master" || $TRAVIS_BRANCH == "develop" ]]; then + MAIN_BRANCH="1" +fi + +if [[ "${TRAVIS}" == "true" ]]; then + JOBS="2" +elif [[ $(uname -s) == "Linux" ]]; then + # Physical cores + JOBS=$(lscpu -p | grep -v '^#' | sort -u -t, -k 2,4 | wc -l) +elif [[ $(uname) == "Darwin" ]]; then + # Physical cores + JOBS=$(sysctl -n hw.physicalcpu) +else + JOBS=1 +fi + +# run with a debugger +function debug_run () +{ + if [[ $TRAVIS_OS_NAME == "osx" ]]; then + # -o runs after loading the binary + # -k runs after any crash + # We use a ghetto appromixation of --return-child-result, exiting with + # 1 on a crash + lldb \ + --batch \ + -o 'run' \ + -k 'thread backtrace all' \ + -k 'script import os; os._exit(1)' \ + $@ + else + gdb \ + --silent \ + --batch \ + --return-child-result \ + -ex="set print thread-events off" \ + -ex=run \ + -ex="thread apply all bt full" \ + --args $@ + fi +} + +function valgrind_run () +{ + valgrind \ + --track-origins=yes \ + --max-stackframe=16000000 \ + --suppressions=$BOOST_ROOT/libs/beast/build/valgrind.supp \ + --error-exitcode=1 \ + $@ +} + +function run_tests_with_debugger () +{ + find "$1" -name "$2" -print0 | while read -d $'\0' f + do + debug_run "$f" + done +} + +function run_tests_with_valgrind () +{ + find "$1" -name "$2" -print0 | while read -d $'\0' f + do + valgrind_run "$f" + done +} + +function run_tests () +{ + find "$1" -name "$2" -print0 | while read -d $'\0' f + do + "$f" + done +} + +#------------------------------------------------------------------------------- + +BIN_DIR="$BOOST_ROOT/bin.v2/libs/beast/test" +LIB_DIR="$BOOST_ROOT/libs/beast" +INC_DIR="$BOOST_ROOT/boost/beast" + +function build_bjam () +{ + if [[ $VARIANT == "coverage" ]]; then + bjam \ + libs/beast/test/beast/core//fat-tests \ + libs/beast/test/beast/http//fat-tests \ + libs/beast/test/beast/websocket//fat-tests \ + libs/beast/test/beast/zlib//fat-tests \ + toolset=$TOOLSET \ + variant=$VARIANT \ + -j${JOBS} + else + bjam \ + libs/beast/test//fat-tests \ + libs/beast/bench \ + libs/beast/example \ + toolset=$TOOLSET \ + variant=$VARIANT \ + -j${JOBS} + fi +} + +build_bjam + +DO_VALGRIND=${DO_VALGRIND:-false} + +if [[ $VARIANT == "coverage" ]]; then + # for lcov to work effectively, the paths and includes + # passed to the compiler should not contain "." or "..". + # (this runs in $BOOST_ROOT) + lcov --version + find "$BOOST_ROOT" -name "*.gcda" | xargs rm -f + rm -f "$BOOST_ROOT/*.info" + lcov --no-external -c -i -d "$BOOST_ROOT" -o baseline.info > /dev/null + run_tests "$BIN_DIR" fat-tests + # https://bugs.launchpad.net/ubuntu/+source/lcov/+bug/1163758 + lcov --no-external -c -d "$BOOST_ROOT" -o testrun.info > /dev/null 2>&1 + lcov -a baseline.info -a testrun.info -o lcov-all.info > /dev/null + lcov -e "lcov-all.info" "$INC_DIR/*" -o lcov.info > /dev/null + ~/.local/bin/codecov -X gcov -f lcov.info + find "$BOOST_ROOT" -name "*.gcda" | xargs rm -f + +elif [[ "$DO_VALGRIND" = true ]]; then + run_tests_with_valgrind "$BIN_DIR" fat-tests + +else + run_tests_with_debugger "$BIN_DIR" fat-tests + +fi diff --git a/scripts/field.txt b/build/field.txt similarity index 100% rename from scripts/field.txt rename to build/field.txt diff --git a/scripts/install-dependencies.sh b/build/install-dependencies.sh similarity index 71% rename from scripts/install-dependencies.sh rename to build/install-dependencies.sh index 76bdc673..e865187b 100755 --- a/scripts/install-dependencies.sh +++ b/build/install-dependencies.sh @@ -38,26 +38,10 @@ fi if [ -x $HOME/bin/clang ]; then $HOME/bin/clang -v fi + # Avoid `spurious errors` caused by ~/.npm permission issues # Does it already exist? Who owns? What permissions? ls -lah ~/.npm || mkdir ~/.npm + # Make sure we own it chown -Rc $USER ~/.npm -# We use this so we can filter the subtrees from our coverage report -pip install --user requests==2.13.0 -pip install --user https://github.com/codecov/codecov-python/archive/master.zip -pip install --user autobahntestsuite - -# Install lcov -# Download the archive -#wget http://downloads.sourceforge.net/ltp/lcov-1.12.tar.gz -# Extract to ~/lcov-1.12 -#tar xfvz lcov-1.12.tar.gz -C $HOME -# Set install path -#mkdir -p $LCOV_ROOT -#cd $HOME/lcov-1.12 && make install PREFIX=$LCOV_ROOT - -# Install coveralls reporter -#cd $HERE -#mkdir -p node_modules -#npm install coveralls diff --git a/scripts/local-travis.sh b/build/local-travis.sh similarity index 100% rename from scripts/local-travis.sh rename to build/local-travis.sh diff --git a/scripts/make_field.sh b/build/make_field.sh old mode 100644 new mode 100755 similarity index 100% rename from scripts/make_field.sh rename to build/make_field.sh diff --git a/scripts/valgrind.supp b/build/valgrind.supp similarity index 100% rename from scripts/valgrind.supp rename to build/valgrind.supp diff --git a/scripts/build-and-test.sh b/scripts/build-and-test.sh deleted file mode 100755 index de2a1df6..00000000 --- a/scripts/build-and-test.sh +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/env bash -# We use set -e to bail on first non zero exit code of any processes launched -# and -x to exit upon any unbound variable. -x will output command lines used -# (with variable expansion) - -BIN_DIR="$BOOST_ROOT/bin.v2/libs/beast/test" -LIB_DIR="$BOOST_ROOT/libs/beast" -INC_DIR="$BOOST_ROOT/boost/beast" - -set -eux - -# brew install bash (4) to get this working on OSX! -shopt -s globstar - -################################## ENVIRONMENT ################################# - -DO_VALGRIND=${DO_VALGRIND:-false} - -# If not CI, then set some defaults -if [[ "${CI:-}" == "" ]]; then - TRAVIS_BRANCH=${TRAVIS_BRANCH:-feature} - CC=${CC:-gcc} - ADDRESS_MODEL=${ADDRESS_MODEL:-64} - VARIANT=${VARIANT:-debug} - # If running locally we assume we have lcov/valgrind on PATH -else - export PATH=$VALGRIND_ROOT/bin:$LCOV_ROOT/usr/bin:$PATH -fi - -MAIN_BRANCH="0" -# For builds not triggered by a pull request TRAVIS_BRANCH is the name of the -# branch currently being built; whereas for builds triggered by a pull request -# it is the name of the branch targeted by the pull request (in many cases this -# will be master). -if [[ $TRAVIS_BRANCH == "master" || $TRAVIS_BRANCH == "develop" ]]; then - MAIN_BRANCH="1" -fi - -num_jobs="1" -if [[ $(uname) == "Darwin" ]]; then - num_jobs=$(sysctl -n hw.physicalcpu) -elif [[ $(uname -s) == "Linux" ]]; then - # CircleCI returns 32 phys procs, but 2 virt proc - num_proc_units=$(nproc) - # Physical cores - num_jobs=$(lscpu -p | grep -v '^#' | sort -u -t, -k 2,4 | wc -l) - if ((${num_proc_units} < ${num_jobs})); then - num_jobs=$num_proc_units - fi - if [[ "${TRAVIS}" == "true" && ${NUM_PROCESSORS:=2} > ${num_jobs} ]]; then - num_jobs=$NUM_PROCESSORS - fi - #if [[ "$TRAVIS" == "true" ]] && (( "$num_jobs" > 1)); then - # num_jobs=$((num_jobs - 1)) - #fi -fi - -echo "using toolset: $TOOLSET" -echo "using variant: $VARIANT" -echo "using address-model: $ADDRESS_MODEL" -echo "using PATH: $PATH" -echo "using MAIN_BRANCH: $MAIN_BRANCH" -echo "using BOOST_ROOT: $BOOST_ROOT" - -#################################### HELPERS ################################### - -function run_tests_with_debugger { - for x in $BOOST_ROOT/bin.v2/libs/beast/test/**/$VARIANT/**/fat-tests; do - "$LIB_DIR/scripts/run-with-debugger.sh" "$x" - done -} - -function run_tests { - for x in $BOOST_ROOT/bin.v2/libs/beast/test/**/$VARIANT/**/fat-tests; do - $x - done -} - -function run_tests_with_valgrind { - for x in $BOOST_ROOT/bin.v2/libs/beast/test/**/$VARIANT/**/fat-tests; do - # TODO --max-stackframe=8388608 - # see: https://travis-ci.org/vinniefalco/Beast/jobs/132486245 - valgrind --suppressions=$BOOST_ROOT/libs/beast/scripts/valgrind.supp --error-exitcode=1 "$x" - done -} - -function build_bjam { - if [[ $VARIANT == "coverage" ]]; then - bjam \ - libs/beast/test/beast/core//fat-tests \ - libs/beast/test/beast/http//fat-tests \ - libs/beast/test/beast/websocket//fat-tests \ - libs/beast/test/beast/zlib//fat-tests \ - toolset=$TOOLSET variant=$VARIANT address-model=$ADDRESS_MODEL -j${num_jobs} - else - bjam \ - libs/beast/test//fat-tests \ - libs/beast/bench \ - libs/beast/example \ - toolset=$TOOLSET variant=$VARIANT address-model=$ADDRESS_MODEL -j${num_jobs} - fi -} - -build_bjam - -if [[ $VARIANT == "coverage" ]]; then - # for lcov to work effectively, the paths and includes - # passed to the compiler should not contain "." or "..". - # (this runs in $BOOST_ROOT) - lcov --version - find "$BOOST_ROOT" -name "*.gcda" | xargs rm -f - rm -f "$BOOST_ROOT/*.info" - lcov --no-external -c -i -d "$BOOST_ROOT" -o baseline.info > /dev/null - run_tests - # https://bugs.launchpad.net/ubuntu/+source/lcov/+bug/1163758 - lcov --no-external -c -d "$BOOST_ROOT" -o testrun.info > /dev/null 2>&1 - lcov -a baseline.info -a testrun.info -o lcov-all.info > /dev/null - lcov -e "lcov-all.info" "$INC_DIR/*" -o lcov.info > /dev/null - ~/.local/bin/codecov -X gcov -f lcov.info - find "$BOOST_ROOT" -name "*.gcda" | xargs rm -f - -elif [[ "$DO_VALGRIND" = true ]]; then - run_tests_with_valgrind - -else - run_tests_with_debugger - -fi diff --git a/scripts/fuzzingclient.json b/scripts/fuzzingclient.json deleted file mode 100644 index 6bece294..00000000 --- a/scripts/fuzzingclient.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "outdir": "./autoresults", - "servers": [ - { - "url": "ws://127.0.0.1:6000" - }, - { - "url": "ws://127.0.0.1:6001" - } - ], - "cases": ["*"], - "exclude-cases": [], - "exclude-agent-cases": {} -} \ No newline at end of file diff --git a/scripts/parseautobahn.py b/scripts/parseautobahn.py deleted file mode 100644 index 6b91e8c6..00000000 --- a/scripts/parseautobahn.py +++ /dev/null @@ -1,43 +0,0 @@ -import os -import json -import sys - -VARIANT = os.environ.get('VARIANT', 'release') -EXPECTED_BEHAVIOR = ('OK', 'UNIMPLEMENTED', 'INFORMATIONAL') -EXPECTED_BEHAVIOR_CLOSE = ('OK', 'INFORMATIONAL') -WARNINGS = ("peer did not respond (in time) in closing handshake", ) - -args = sys.argv[1:] -fn = os.path.abspath(args[0]) -indexPath = os.path.dirname(fn) -relativeToIndex = lambda f: os.path.join(indexPath, f) -print "index", fn - - -failures = [] -warnings = [] - -with open(fn, 'r') as fh: - index = json.load(fh) - for servername, serverResults in index.items(): - for test in serverResults: - result = serverResults[test] - if ((result['behavior'] not in EXPECTED_BEHAVIOR) or - result['behaviorClose'] not in EXPECTED_BEHAVIOR_CLOSE): - with open(relativeToIndex(result['reportfile'])) as rh: - report = json.load(rh) - if (report.get('wasNotCleanReason', '') in WARNINGS and - VARIANT != 'release'): - warnings.append(report) - else: - failures.append(report) - - -if warnings: - print >> sys.stderr, json.dumps(warnings, indent=2) - print >> sys.stderr, 'there was %s warnings' % len(warnings) - -if failures: - print >> sys.stderr, json.dumps(failures, indent=2) - print >> sys.stderr, 'there was %s failures' % len(failures) - sys.exit(1) diff --git a/scripts/run-with-debugger.sh b/scripts/run-with-debugger.sh deleted file mode 100755 index 6a8b55d8..00000000 --- a/scripts/run-with-debugger.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash -set -eu - -if [[ $(uname) == "Darwin" ]]; then - # -o runs after loading the binary - # -k runs after any crash - # We use a ghetto appromixation of --return-child-result, exiting with - # 1 on a crash - lldb --batch \ - -o 'run' \ - -k 'thread backtrace all' \ - -k 'script import os; os._exit(1)' \ - $@ -else - gdb --silent \ - --batch \ - --return-child-result \ - -ex="set print thread-events off" \ - -ex=run \ - -ex="thread apply all bt full" \ - --args $@ -fi diff --git a/scripts/run-with-gdb.sh b/scripts/run-with-gdb.sh deleted file mode 100755 index f7ff0bc7..00000000 --- a/scripts/run-with-gdb.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -u -set -e -gdb --silent \ - --batch \ - --return-child-result \ - -ex="set print thread-events off" \ - -ex=run \ - -ex="thread apply all bt full" \ - --args $@