]>
Commit | Line | Data |
---|---|---|
b32b8144 FG |
1 | #!/usr/bin/env bash |
2 | ||
3 | # add 'x' for command tracing | |
4 | set -eu | |
5 | ||
6 | #------------------------------------------------------------------------------- | |
7 | # | |
8 | # Utilities | |
9 | # | |
10 | ||
11 | # For builds not triggered by a pull request TRAVIS_BRANCH is the name of the | |
12 | # branch currently being built; whereas for builds triggered by a pull request | |
13 | # it is the name of the branch targeted by the pull request (in many cases this | |
14 | # will be master). | |
15 | MAIN_BRANCH="0" | |
16 | if [[ $TRAVIS_BRANCH == "master" || $TRAVIS_BRANCH == "develop" ]]; then | |
17 | MAIN_BRANCH="1" | |
18 | fi | |
19 | ||
20 | if [[ "${TRAVIS}" == "true" ]]; then | |
21 | JOBS="2" | |
22 | elif [[ $(uname -s) == "Linux" ]]; then | |
23 | # Physical cores | |
24 | JOBS=$(lscpu -p | grep -v '^#' | sort -u -t, -k 2,4 | wc -l) | |
25 | elif [[ $(uname) == "Darwin" ]]; then | |
26 | # Physical cores | |
27 | JOBS=$(sysctl -n hw.physicalcpu) | |
28 | else | |
29 | JOBS=1 | |
30 | fi | |
31 | ||
32 | # run with a debugger | |
33 | function debug_run () | |
34 | { | |
35 | if [[ $TRAVIS_OS_NAME == "osx" ]]; then | |
36 | # -o runs after loading the binary | |
37 | # -k runs after any crash | |
38 | # We use a ghetto appromixation of --return-child-result, exiting with | |
39 | # 1 on a crash | |
40 | lldb \ | |
41 | --batch \ | |
42 | -o 'run' \ | |
43 | -k 'thread backtrace all' \ | |
44 | -k 'script import os; os._exit(1)' \ | |
45 | $@ | |
46 | else | |
47 | gdb \ | |
48 | --silent \ | |
49 | --batch \ | |
50 | --return-child-result \ | |
51 | -ex="set print thread-events off" \ | |
52 | -ex=run \ | |
53 | -ex="thread apply all bt full" \ | |
54 | --args $@ | |
55 | fi | |
56 | } | |
57 | ||
58 | function valgrind_run () | |
59 | { | |
60 | valgrind \ | |
61 | --track-origins=yes \ | |
62 | --max-stackframe=16000000 \ | |
63 | --suppressions=$BOOST_ROOT/libs/beast/tools/valgrind.supp \ | |
64 | --error-exitcode=1 \ | |
65 | $@ | |
66 | } | |
67 | ||
68 | function run_tests_with_debugger () | |
69 | { | |
70 | find "$1" -name "$2" -print0 | while read -d $'\0' f | |
71 | do | |
72 | debug_run "$f" | |
73 | done | |
74 | } | |
75 | ||
76 | function run_tests_with_valgrind () | |
77 | { | |
78 | find "$1" -name "$2" -print0 | while read -d $'\0' f | |
79 | do | |
80 | valgrind_run "$f" | |
81 | done | |
82 | } | |
83 | ||
84 | function run_tests () | |
85 | { | |
86 | find "$1" -name "$2" -print0 | while read -d $'\0' f | |
87 | do | |
88 | "$f" | |
89 | done | |
90 | } | |
91 | ||
92 | #------------------------------------------------------------------------------- | |
93 | ||
94 | BIN_DIR="$BOOST_ROOT/bin.v2/libs/beast/test" | |
95 | LIB_DIR="$BOOST_ROOT/libs/beast" | |
96 | INC_DIR="$BOOST_ROOT/boost/beast" | |
97 | ||
98 | function build_bjam () | |
99 | { | |
100 | if [[ $VARIANT == "coverage" ]] || \ | |
101 | [[ $VARIANT == "valgrind" ]] || \ | |
102 | [[ $VARIANT == "ubasan" ]]; then | |
103 | b2 \ | |
104 | cxxflags=-std=c++11 \ | |
105 | libs/beast/test/beast/core//fat-tests \ | |
106 | libs/beast/test/beast/http//fat-tests \ | |
107 | libs/beast/test/beast/websocket//fat-tests \ | |
108 | libs/beast/test/beast/zlib//fat-tests \ | |
109 | toolset=$TOOLSET \ | |
110 | variant=$VARIANT \ | |
111 | -j${JOBS} | |
112 | else | |
113 | b2 \ | |
114 | cxxflags=-std=c++11 \ | |
115 | libs/beast/test//fat-tests \ | |
116 | libs/beast/example \ | |
117 | toolset=$TOOLSET \ | |
118 | variant=$VARIANT \ | |
119 | -j${JOBS} | |
120 | fi | |
121 | } | |
122 | ||
123 | build_bjam | |
124 | ||
125 | if [[ $VARIANT == "coverage" ]]; then | |
126 | # for lcov to work effectively, the paths and includes | |
127 | # passed to the compiler should not contain "." or "..". | |
128 | # (this runs in $BOOST_ROOT) | |
129 | lcov --version | |
130 | find "$BOOST_ROOT" -name "*.gcda" | xargs rm -f | |
131 | rm -f "$BOOST_ROOT/*.info" | |
132 | lcov --no-external -c -i -d "$BOOST_ROOT" -o baseline.info > /dev/null | |
133 | run_tests "$BIN_DIR" fat-tests | |
134 | # https://bugs.launchpad.net/ubuntu/+source/lcov/+bug/1163758 | |
135 | lcov --no-external -c -d "$BOOST_ROOT" -o testrun.info > /dev/null 2>&1 | |
136 | lcov -a baseline.info -a testrun.info -o lcov-all.info > /dev/null | |
137 | lcov -e "lcov-all.info" "$INC_DIR/*" -o lcov.info > /dev/null | |
138 | ~/.local/bin/codecov -X gcov -f lcov.info | |
139 | find "$BOOST_ROOT" -name "*.gcda" | xargs rm -f | |
140 | ||
141 | elif [[ $VARIANT == "valgrind" ]]; then | |
142 | run_tests_with_valgrind "$BIN_DIR" fat-tests | |
143 | ||
144 | else | |
11fdf7f2 TL |
145 | #run_tests_with_debugger "$BIN_DIR" fat-tests |
146 | run_tests "$BIN_DIR" fat-tests | |
b32b8144 FG |
147 | |
148 | fi |