2016-05-28 12:21:40 +07:00
|
|
|
#!/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)
|
|
|
|
set -eux
|
|
|
|
|
|
|
|
# brew install bash (4) to get this working on OSX!
|
2016-04-27 14:58:07 +07:00
|
|
|
shopt -s globstar
|
|
|
|
|
|
|
|
################################## ENVIRONMENT #################################
|
|
|
|
|
2016-05-09 23:06:38 +07:00
|
|
|
# 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
|
2016-04-27 14:58:07 +07:00
|
|
|
|
2016-05-28 12:21:40 +07:00
|
|
|
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)
|
2016-06-17 11:10:33 -04:00
|
|
|
if ((${num_proc_units} < ${num_jobs})); then
|
|
|
|
num_jobs=$num_proc_units
|
2016-05-28 12:21:40 +07:00
|
|
|
fi
|
2016-11-29 11:44:02 -05:00
|
|
|
if [[ "${TRAVIS}" == "true" && ${NUM_PROCESSORS:=2} > ${num_jobs} ]]; then
|
|
|
|
num_jobs=$NUM_PROCESSORS
|
|
|
|
fi
|
2016-05-28 12:21:40 +07:00
|
|
|
fi
|
|
|
|
|
2017-07-20 08:01:46 -07:00
|
|
|
echo "using toolset: $CC"
|
|
|
|
echo "using variant: $VARIANT"
|
2016-04-27 14:58:07 +07:00
|
|
|
echo "using address-model: $ADDRESS_MODEL"
|
|
|
|
echo "using PATH: $PATH"
|
2016-05-28 12:21:40 +07:00
|
|
|
echo "using MAIN_BRANCH: $MAIN_BRANCH"
|
|
|
|
echo "using BOOST_ROOT: $BOOST_ROOT"
|
2016-04-27 14:58:07 +07:00
|
|
|
|
|
|
|
#################################### HELPERS ###################################
|
|
|
|
|
2016-05-28 12:21:40 +07:00
|
|
|
function run_tests_with_debugger {
|
|
|
|
for x in bin/**/$VARIANT/**/*-tests; do
|
|
|
|
scripts/run-with-debugger.sh "$x"
|
|
|
|
done
|
2016-04-27 14:58:07 +07:00
|
|
|
}
|
|
|
|
|
2016-05-23 13:04:11 -04:00
|
|
|
function run_tests {
|
2016-05-28 12:21:40 +07:00
|
|
|
for x in bin/**/$VARIANT/**/*-tests; do
|
|
|
|
$x
|
|
|
|
done
|
2016-05-23 13:04:11 -04:00
|
|
|
}
|
|
|
|
|
2016-05-28 12:21:40 +07:00
|
|
|
function run_tests_with_valgrind {
|
|
|
|
for x in bin/**/$VARIANT/**/*-tests; do
|
|
|
|
if [[ $(basename $x) == "bench-tests" ]]; then
|
|
|
|
$x
|
|
|
|
else
|
|
|
|
# TODO --max-stackframe=8388608
|
|
|
|
# see: https://travis-ci.org/vinniefalco/Beast/jobs/132486245
|
2016-10-18 19:43:36 -04:00
|
|
|
valgrind --suppressions=./scripts/valgrind.supp --error-exitcode=1 "$x"
|
2016-05-23 13:04:11 -04:00
|
|
|
fi
|
2016-05-28 12:21:40 +07:00
|
|
|
done
|
|
|
|
}
|
2016-05-23 13:04:11 -04:00
|
|
|
|
2016-04-27 14:58:07 +07:00
|
|
|
function build_beast {
|
|
|
|
$BOOST_ROOT/bjam toolset=$CC \
|
|
|
|
variant=$VARIANT \
|
2016-05-28 12:21:40 +07:00
|
|
|
address-model=$ADDRESS_MODEL \
|
|
|
|
-j${num_jobs}
|
2016-04-27 14:58:07 +07:00
|
|
|
}
|
|
|
|
|
2016-06-17 11:10:33 -04:00
|
|
|
function build_beast_cmake {
|
|
|
|
mkdir -p build
|
|
|
|
pushd build > /dev/null
|
2016-06-22 11:24:05 -07:00
|
|
|
cmake -DVARIANT=${VARIANT} ..
|
2016-06-17 11:10:33 -04:00
|
|
|
make -j${num_jobs}
|
|
|
|
mkdir -p ../bin/$VARIANT
|
|
|
|
find . -executable -type f -exec cp {} ../bin/$VARIANT/. \;
|
|
|
|
popd > /dev/null
|
|
|
|
}
|
|
|
|
|
2016-05-28 12:21:40 +07:00
|
|
|
function run_autobahn_test_suite {
|
2016-04-27 14:58:07 +07:00
|
|
|
# Run autobahn tests
|
2016-05-28 12:21:40 +07:00
|
|
|
wsecho=$(find bin -name "websocket-echo" | grep /$VARIANT/)
|
|
|
|
nohup $wsecho&
|
2016-04-27 14:58:07 +07:00
|
|
|
|
|
|
|
# We need to wait a while so wstest can connect!
|
|
|
|
sleep 5
|
2016-11-29 11:44:02 -05:00
|
|
|
# Show the output (if any) as it is generated
|
|
|
|
tail -f nohup.out &
|
2016-05-09 23:06:38 +07:00
|
|
|
cd scripts && wstest -m fuzzingclient
|
|
|
|
cd ..
|
2016-04-27 14:58:07 +07:00
|
|
|
rm nohup.out
|
2016-05-28 12:21:40 +07:00
|
|
|
# Show what jobs are running
|
2016-04-27 14:58:07 +07:00
|
|
|
jobs
|
2016-05-28 12:21:40 +07:00
|
|
|
# Wait a while for things to wind down before issuing a kill
|
2016-05-23 13:04:11 -04:00
|
|
|
sleep 5
|
2016-04-27 14:58:07 +07:00
|
|
|
# Kill it gracefully
|
|
|
|
kill -INT %1
|
2016-11-29 11:44:02 -05:00
|
|
|
kill -INT %2
|
2016-05-28 12:21:40 +07:00
|
|
|
# Wait for all the jobs to finish
|
2016-05-23 13:04:11 -04:00
|
|
|
wait
|
2016-05-28 12:21:40 +07:00
|
|
|
# Parse the test results, with python>=2.5<3 script
|
|
|
|
python scripts/parseautobahn.py scripts/autoresults/index.json
|
|
|
|
}
|
|
|
|
|
|
|
|
##################################### BUILD ####################################
|
|
|
|
|
2016-06-17 11:10:33 -04:00
|
|
|
if [[ ${BUILD_SYSTEM:-} == cmake ]]; then
|
|
|
|
build_beast_cmake
|
|
|
|
else
|
|
|
|
build_beast
|
|
|
|
fi
|
2016-05-28 12:21:40 +07:00
|
|
|
|
|
|
|
##################################### TESTS ####################################
|
|
|
|
|
|
|
|
if [[ $VARIANT == "coverage" ]]; then
|
|
|
|
find . -name "*.gcda" | xargs rm -f
|
|
|
|
rm *.info -f
|
|
|
|
# Create baseline coverage data file
|
|
|
|
lcov --no-external -c -i -d . -o baseline.info > /dev/null
|
|
|
|
|
|
|
|
# Perform test
|
|
|
|
if [[ $MAIN_BRANCH == "1" ]]; then
|
|
|
|
run_tests_with_valgrind
|
2016-11-29 11:44:02 -05:00
|
|
|
# skip slow autobahn tests
|
|
|
|
#run_autobahn_test_suite
|
2016-05-28 12:21:40 +07:00
|
|
|
else
|
2016-11-29 11:44:02 -05:00
|
|
|
echo "skipping autobahn/valgrind tests for feature branch build"
|
2016-05-28 12:21:40 +07:00
|
|
|
run_tests
|
|
|
|
fi
|
2016-04-27 14:58:07 +07:00
|
|
|
|
|
|
|
# Create test coverage data file
|
|
|
|
lcov --no-external -c -d . -o testrun.info > /dev/null
|
|
|
|
|
|
|
|
# Combine baseline and test coverage data
|
|
|
|
lcov -a baseline.info -a testrun.info -o lcov-all.info > /dev/null
|
|
|
|
|
|
|
|
# Extract only include/beast, and don\'t report on examples/test
|
2016-05-28 12:21:40 +07:00
|
|
|
lcov -e "lcov-all.info" "$PWD/include/beast/*" -o lcov.info > /dev/null
|
2016-04-27 14:58:07 +07:00
|
|
|
|
|
|
|
~/.local/bin/codecov -X gcov
|
2016-05-28 12:21:40 +07:00
|
|
|
cat lcov.info | node_modules/.bin/coveralls
|
2017-07-20 08:01:46 -07:00
|
|
|
|
2016-05-28 12:21:40 +07:00
|
|
|
# Clean up these stragglers so BOOST_ROOT cache is clean
|
|
|
|
find $BOOST_ROOT/bin.v2 -name "*.gcda" | xargs rm -f
|
|
|
|
else
|
|
|
|
run_tests_with_debugger
|
2016-04-27 14:58:07 +07:00
|
|
|
fi
|