ea742fb24fdee21e66b0e12f244baa849681ea43
[ci-management.git] / jjb / scripts / vpp / debug-build.sh
1 #!/bin/bash
2
3 # Copyright (c) 2021 Cisco and/or its affiliates.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 echo "---> jjb/scripts/vpp/debug-build.sh"
17
18 set -euxo pipefail
19
20 line="*************************************************************************"
21 OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
22 OS_VERSION_ID=$(grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
23 OS_ARCH=$(uname -m)
24 DRYRUN="${DRYRUN:-}"
25 MAKE_PARALLEL_JOBS="${MAKE_PARALLEL_JOBS:-}"
26 BUILD_RESULT="SUCCESSFULLY COMPLETED"
27 BUILD_ERROR=""
28 RETVAL="0"
29
30 echo "sha1sum of this script: ${0}"
31 sha1sum $0
32
33 # run with ASAN on
34 # disable ASAN for now in the debug build - it's broken with PAPI
35 # in make test transitioning to unix sockets
36 # export VPP_EXTRA_CMAKE_ARGS='-DVPP_ENABLE_SANITIZE_ADDR=ON'
37
38 make_build_test_debug() {
39     if ! make UNATTENDED=yes install-dep ; then
40         BUILD_ERROR="FAILED 'make install-dep'"
41         return
42     fi
43     if ! make UNATTENDED=yes install-ext-deps ; then
44         BUILD_ERROR="FAILED 'make install-ext-deps'"
45         return
46     fi
47     if ! make UNATTENDED=yes build ; then
48         BUILD_ERROR="FAILED 'make build'"
49         return
50     fi
51     if [ "${OS_ID}-${OS_VERSION_ID}" == "${MAKE_TEST_OS}" ] ; then
52         if [ -n "${MAKE_PARALLEL_JOBS}" ] ; then
53             TEST_JOBS="${MAKE_PARALLEL_JOBS}"
54             echo "Testing VPP with ${TEST_JOBS} cores."
55         else
56             TEST_JOBS="auto"
57             echo "Testing VPP with automatically calculated number of cores. " \
58                 "See test logs for the exact number."
59         fi
60         if ! make UNATTENDED=yes TEST_JOBS="$TEST_JOBS" test-debug ; then
61             BUILD_ERROR="FAILED 'make UNATTENDED=yes TEST_JOBS=$TEST_JOBS test-debug'"
62             return
63         fi
64     else
65         echo "Skip running 'make test-debug' on ${OS_ID}-${OS_VERSION_ID}"
66     fi
67 }
68
69 # clang is not working with ASAN right now - see change 27268
70 # also, it does not work with gcc-7, we need gcc-8 at least
71 # on ubuntu 20.04 executor the gcc is gcc9
72 if [ "${DRYRUN,,}" != "true" ] ; then
73     make_build_test_debug
74 fi
75 if [ -n "$BUILD_ERROR" ] ; then
76     BUILD_RESULT="$BUILD_ERROR"
77     RETVAL="1"
78 fi
79 echo -e "\n$line\n* VPP ${OS_ID^^}-${OS_VERSION_ID}-${OS_ARCH^^} DEBUG BUILD $BUILD_RESULT\n$line\n"
80 exit $RETVAL