3 # Copyright (c) 2023 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:
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
16 echo "---> jjb/scripts/vpp/cov-build.sh"
20 line="*************************************************************************"
21 # Don't build anything if this is a merge job.
22 if [[ ${JOB_NAME} == *merge* ]] ; then
23 echo -e "\n$line\nSkipping build."
27 OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
28 OS_VERSION_ID=$(grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
31 IS_CSIT_VPP_JOB="${IS_CSIT_VPP_JOB:-}"
32 MAKE_PARALLEL_FLAGS="${MAKE_PARALLEL_FLAGS:-}"
33 MAKE_PARALLEL_JOBS="${MAKE_PARALLEL_JOBS:-}"
34 MAKE_TEST_OS="${MAKE_TEST_OS:-ubuntu-22.04}"
35 MAKE_TEST_MULTIWORKER_OS="${MAKE_TEST_MULTIWORKER_OS:-debian-11}"
36 VPPAPIGEN_TEST_OS="${VPPAPIGEN_TEST_OS:-${MAKE_TEST_OS}}"
37 BUILD_RESULT="SUCCESSFULLY COMPLETED"
41 if [ -n "${MAKE_PARALLEL_FLAGS}" ] ; then
42 echo "Building VPP. Number of cores for build set with" \
43 "MAKE_PARALLEL_FLAGS='${MAKE_PARALLEL_FLAGS}'."
44 elif [ -n "${MAKE_PARALLEL_JOBS}" ] ; then
45 echo "Building VPP. Number of cores for build set with" \
46 "MAKE_PARALLEL_JOBS='${MAKE_PARALLEL_JOBS}'."
48 echo "Building VPP. Number of cores not set," \
49 "using build default ($(grep -c ^processor /proc/cpuinfo))."
52 make_test_coverage_report() {
53 if ! make UNATTENDED=yes install-dep ; then
54 BUILD_ERROR="FAILED 'make install-dep'"
57 if ! make UNATTENDED=yes install-ext-deps ; then
58 BUILD_ERROR="FAILED 'make install-ext-deps'"
61 if ! make UNATTENDED=yes test-dep ; then
62 BUILD_ERROR="FAILED 'make test-dep'"
65 if ! make UNATTENDED=yes CCACHE_DISABLE=1 pkg-verify ; then
66 BUILD_ERROR="FAILED 'make pkg-verify'"
69 if [ "${IS_CSIT_VPP_JOB,,}" == "true" ] ; then
70 # CSIT jobs don't need to run make test
73 if [ -n "${MAKE_PARALLEL_JOBS}" ] ; then
74 TEST_JOBS="${MAKE_PARALLEL_JOBS}"
75 echo "Testing VPP with ${TEST_JOBS} cores."
78 echo "Testing VPP with automatically calculated number of cores. " \
79 "See test logs for the exact number."
81 if grep -q "${OS_ID}-${OS_VERSION_ID}" <<< "${VPPAPIGEN_TEST_OS}"; then
82 if ! src/tools/vppapigen/test_vppapigen.py ; then
83 BUILD_ERROR="FAILED src/tools/vppapigen/test_vppapigen.py"
87 if grep -q "${OS_ID}-${OS_VERSION_ID}" <<< "${MAKE_TEST_OS}"; then
88 if ! make COMPRESS_FAILED_TEST_LOGS=yes TEST_JOBS="$TEST_JOBS" CCACHE_DISABLE=1 test-cov ; then
89 BUILD_ERROR="FAILED 'make test-cov'"
93 echo "Skip running 'make test-cov' on ${OS_ID}-${OS_VERSION_ID}"
97 if [ "${DRYRUN,,}" != "true" ] ; then
98 make_test_coverage_report
100 if [ -n "$BUILD_ERROR" ] ; then
101 BUILD_RESULT="$BUILD_ERROR"
104 echo -e "\n$line\n* VPP ${OS_ID^^}-${OS_VERSION_ID}-${OS_ARCH^^}" \
105 "TEST COVERAGE REPORT $BUILD_RESULT\n$line\n"