]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/beast/tools/build-and-test.sh
bump version to 18.2.4-pve3
[ceph.git] / ceph / src / boost / libs / beast / tools / build-and-test.sh
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 [[ "${BEAST_RETRY}" == "true" ]]; then
21 JOBS=1
22 elif [[ "${TRAVIS}" == "true" ]]; then
23 JOBS="2"
24 elif [[ $(uname -s) == "Linux" ]]; then
25 # Physical cores
26 JOBS=$(lscpu -p | grep -v '^#' | sort -u -t, -k 2,4 | wc -l)
27 elif [[ $(uname) == "Darwin" ]]; then
28 # Physical cores
29 JOBS=$(sysctl -n hw.physicalcpu)
30 else
31 JOBS=1
32 fi
33
34 # run with a debugger
35 function debug_run ()
36 {
37 if [[ $TRAVIS_OS_NAME == "osx" ]]; then
38 # -o runs after loading the binary
39 # -k runs after any crash
40 # We use a ghetto appromixation of --return-child-result, exiting with
41 # 1 on a crash
42 lldb \
43 --batch \
44 -o 'run' \
45 -k 'thread backtrace all' \
46 -k 'script import os; os._exit(1)' \
47 $@
48 else
49 gdb \
50 --silent \
51 --batch \
52 --return-child-result \
53 -ex="set print thread-events off" \
54 -ex=run \
55 -ex="thread apply all bt full" \
56 --args $@
57 fi
58 }
59
60 function valgrind_run ()
61 {
62 valgrind \
63 --track-origins=yes \
64 --max-stackframe=16000000 \
65 --suppressions=$BOOST_ROOT/libs/beast/tools/valgrind.supp \
66 --error-exitcode=1 \
67 $@
68 }
69
70 function run_tests_with_debugger ()
71 {
72 find "$1" -name "$2" -print0 | while read -d $'\0' f
73 do
74 debug_run "$f"
75 done
76 }
77
78 function run_tests_with_valgrind ()
79 {
80 find "$1" -name "$2" -print0 | while read -d $'\0' f
81 do
82 valgrind_run "$f"
83 done
84 }
85
86 function run_tests ()
87 {
88 find "$1" -name "$2" -print0 | while read -d $'\0' f
89 do
90 "$f"
91 done
92 }
93
94 #-------------------------------------------------------------------------------
95
96 BIN_DIR="$BOOST_ROOT/bin.v2/libs/beast/test"
97 LIB_DIR="$BOOST_ROOT/libs/beast"
98 INC_DIR="$BOOST_ROOT/boost/beast"
99
100 function build_bjam ()
101 {
102 if [[ $VARIANT == "beast_coverage" ]] || \
103 [[ $VARIANT == "beast_valgrind" ]] || \
104 [[ $VARIANT == "beast_ubasan" ]]; then
105 b2 \
106 define=BOOST_COROUTINES_NO_DEPRECATION_WARNING=1 \
107 cxxstd=$CXXSTD \
108 libs/beast/test/beast/core//fat-tests \
109 libs/beast/test/beast/http//fat-tests \
110 libs/beast/test/beast/websocket//fat-tests \
111 libs/beast/test/beast/zlib//fat-tests \
112 toolset=$TOOLSET \
113 variant=$VARIANT \
114 link=static \
115 -j${JOBS}
116 elif [[ $VARIANT == "debug" ]]; then
117 b2 \
118 define=BOOST_COROUTINES_NO_DEPRECATION_WARNING=1 \
119 cxxstd=$CXXSTD \
120 libs/beast/test//fat-tests \
121 libs/beast/example \
122 toolset=$TOOLSET \
123 variant=$VARIANT \
124 -j${JOBS}
125 else
126 b2 \
127 define=BOOST_COROUTINES_NO_DEPRECATION_WARNING=1 \
128 cxxstd=$CXXSTD \
129 libs/beast/test//fat-tests \
130 toolset=$TOOLSET \
131 variant=$VARIANT \
132 -j${JOBS}
133 fi
134 }
135
136 build_bjam
137
138 if [[ $VARIANT == "beast_coverage" ]]; then
139 GCOV=${GCOV:-gcov}
140 # for lcov to work effectively, the paths and includes
141 # passed to the compiler should not contain "." or "..".
142 # (this runs in $BOOST_ROOT)
143 lcov --version
144 find "$BOOST_ROOT" -name "*.gcda" | xargs rm -f
145 rm -f "$BOOST_ROOT/*.info"
146 lcov --gcov-tool $GCOV --no-external -c -i -d "$BOOST_ROOT" -o baseline.info > /dev/null
147 run_tests "$BIN_DIR" fat-tests
148 # https://bugs.launchpad.net/ubuntu/+source/lcov/+bug/1163758
149 lcov --gcov-tool $GCOV --no-external -c -d "$BOOST_ROOT" -o testrun-all.info > /dev/null 2>&1
150 lcov --gcov-tool $GCOV -a baseline.info -a testrun-all.info -o lcov-diff.info > /dev/null
151 lcov --gcov-tool $GCOV -e "lcov-diff.info" "$INC_DIR/*" -o lcov.info > /dev/null
152 lcov --gcov-tool $GCOV --remove "lcov.info" "$INC_DIR/_experimental/*" -o lcov.info > /dev/null
153 echo "Change working directory for codecov:"
154 pwd
155 pushd .
156 cd libs/beast
157 ~/.local/bin/codecov -X gcov -f ../../lcov.info
158 popd
159 find "$BOOST_ROOT" -name "*.gcda" | xargs rm -f
160
161 elif [[ $VARIANT == "beast_valgrind" ]]; then
162 run_tests_with_valgrind "$BIN_DIR" fat-tests
163
164 else
165 #run_tests_with_debugger "$BIN_DIR" fat-tests
166 run_tests "$BIN_DIR" fat-tests
167
168 fi