Run VPP 'make test' on Ubuntu 22.04 for master.
[ci-management.git] / jjb / scripts / vpp / gcc-build.sh
1 #!/bin/bash
2
3 # Copyright (c) 2022 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/gcc-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 BUILD_RESULT="SUCCESSFULLY COMPLETED"
26 BUILD_ERROR=""
27 RETVAL="0"
28
29 echo "sha1sum of this script: ${0}"
30 sha1sum $0
31 export CC=gcc
32
33 make_build_release_build_test_gcov_sanity() {
34     if ! make UNATTENDED=yes install-dep ; then
35         BUILD_ERROR="FAILED 'make install-dep'"
36         return
37     fi
38     if ! make UNATTENDED=yes install-ext-deps ; then
39         BUILD_ERROR="FAILED 'make install-ext-deps'"
40         return
41     fi
42     if ! make UNATTENDED=yes build-release ; then
43         BUILD_ERROR="FAILED 'make build'"
44         return
45     fi
46     if ! make UNATTENDED=yes build ; then
47         BUILD_ERROR="FAILED 'make build'"
48         return
49     fi
50     if [ -n "${MAKE_PARALLEL_JOBS}" ] ; then
51         TEST_JOBS="${MAKE_PARALLEL_JOBS}"
52         echo "Testing VPP with ${TEST_JOBS} cores."
53     else
54         TEST_JOBS="auto"
55         echo "Testing VPP with automatically calculated number of cores. " \
56              "See test logs for the exact number."
57     fi
58     # TODO: Add 'smoke test' env var to select smoke test cases
59     #       then update this accordingly.  For now pick a few basic suites...
60     MAKE_TEST_SUITES="vlib vppinfra vpe_api vapi cli bihash"
61     for suite in $MAKE_TEST_SUITES ; do
62         if ! make UNATTENDED=yes TESTS_GCOV=1 TEST_JOBS="$TEST_JOBS" TEST=$suite test ; then
63             BUILD_ERROR="FAILED 'make TESTS_GCOV=1 TEST_JOBS=$TEST_JOBS TEST=$suite test'!"
64             return
65         fi
66         if ! make UNATTENDED=yes TESTS_GCOV=1 TEST_JOBS="$TEST_JOBS" TEST=$suite test-debug ; then
67             BUILD_ERROR="FAILED 'make TESTS_GCOV=1 TEST_JOBS=$TEST_JOBS TEST=$suite test-debug'!"
68             return
69         fi
70     done
71 }
72
73 if [ "${DRYRUN,,}" != "true" ] ; then
74     make_build_release_build_test_gcov_sanity
75 fi
76 if [ -n "$BUILD_ERROR" ] ; then
77     BUILD_RESULT="$BUILD_ERROR"
78     RETVAL="1"
79 fi
80 echo -e "\n$line\n* VPP ${OS_ID^^}-${OS_VERSION_ID}-${OS_ARCH^^} GCC BUILD $BUILD_RESULT\n$line\n"
81 exit $RETVAL