This repository has been archived by the owner on Aug 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker.sh
executable file
·88 lines (73 loc) · 2.45 KB
/
docker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/sh -e
# Autogenerated by 'mkbuild'; DO NOT EDIT!
USAGE="Usage: $0 asan|clang|coverage|tsan|ubsan|vanilla"
if [ $# -eq 1 ]; then
INTERNAL=0
BUILD_TYPE="$1"
elif [ $# -eq 2 -a "$1" = "-internal" ]; then
INTERNAL=1
BUILD_TYPE="$2"
else
echo "$USAGE" 1>&2
exit 1
fi
if [ "$CODECOV_TOKEN" = "" ]; then
echo "WARNING: CODECOV_TOKEN is not set" 1>&2
fi
if [ "$TRAVIS_BRANCH" = "" ]; then
echo "WARNING: TRAVIS_BRANCH is not set" 1>&2
fi
set -x
if [ $INTERNAL -eq 0 ]; then
exec docker run --cap-add=NET_ADMIN \
-e CODECOV_TOKEN=$CODECOV_TOKEN \
-e TRAVIS_BRANCH=$TRAVIS_BRANCH \
-v "$(pwd):/mk" \
--workdir /mk \
-t bassosimone/mk-debian \
./docker.sh -internal "$1"
fi
env | grep -v TOKEN | sort
# Make sure we don't consume too much resources by bumping latency
tc qdisc add dev eth0 root netem delay 200ms 10ms
# Select the proper build flags depending on the build type
if [ "$BUILD_TYPE" = "asan" ]; then
export CFLAGS="-fsanitize=address -O1 -fno-omit-frame-pointer"
export CXXFLAGS="-fsanitize=address -O1 -fno-omit-frame-pointer"
export LDFLAGS="-fsanitize=address -fno-omit-frame-pointer"
export CMAKE_BUILD_TYPE="Debug"
elif [ "$BUILD_TYPE" = "clang" ]; then
export CMAKE_BUILD_TYPE="Release"
export CXXFLAGS="-stdlib=libc++"
export CC=clang
export CXX=clang++
elif [ "$BUILD_TYPE" = "coverage" ]; then
export CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage"
export CMAKE_BUILD_TYPE="Debug"
export CXXFLAGS="-O0 -g -fprofile-arcs -ftest-coverage"
export LDFLAGS="-lgcov"
elif [ "$BUILD_TYPE" = "ubsan" ]; then
export CFLAGS="-fsanitize=undefined -fno-sanitize-recover"
export CXXFLAGS="-fsanitize=undefined -fno-sanitize-recover"
export LDFLAGS="-fsanitize=undefined"
export CMAKE_BUILD_TYPE="Debug"
elif [ "$BUILD_TYPE" = "vanilla" ]; then
export CMAKE_BUILD_TYPE="Release"
else
echo "$0: BUILD_TYPE not in: asan, clang, coverage, tsan, ubsan, vanilla" 1>&2
exit 1
fi
# Configure, make, and make check equivalent
mkdir build
cd build
cmake -GNinja -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE ..
cmake --build . -- -v
ctest --output-on-failure -a -j8
# Measure and possibly report the test coverage
if [ "$BUILD_TYPE" = "coverage" ]; then
lcov --directory . --capture -o lcov.info
if [ "$CODECOV_TOKEN" != "" ]; then
curl -fsSL -o codecov.sh https://codecov.io/bash
bash codecov.sh -X gcov -Z -f lcov.info
fi
fi