summaryrefslogtreecommitdiffstats
path: root/src/CMakeLists.txt
blob: de0c24135d7f27d3a27779565acefa4e2d25f75c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# Copyright (c) 2018 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required(VERSION 3.13)

set(CMAKE_C_COMPILER_NAMES clang gcc cc)

project(vpp C)

if(NOT DEFINED CMAKE_INSTALL_LIBDIR AND EXISTS "/etc/debian_version")
  set(CMAKE_INSTALL_LIBDIR "lib/${CMAKE_LIBRARY_ARCHITECTURE}")
endif()

include(CheckCCompilerFlag)
include(CheckIPOSupported)
include(GNUInstallDirs)
include(cmake/misc.cmake)
include(cmake/cpu.cmake)
include(cmake/ccache.cmake)

##############################################################################
# VPP Version
##############################################################################
execute_process(
  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  COMMAND scripts/version
  OUTPUT_VARIABLE VPP_VERSION
  OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(REPLACE "-" ";" VPP_LIB_VERSION ${VPP_VERSION})
list(GET VPP_LIB_VERSION 0 VPP_LIB_VERSION)

##############################################################################
# compiler specifics
##############################################################################

set(MIN_SUPPORTED_CLANG_C_COMPILER_VERSION 9.0.0)
set(MIN_SUPPORTED_GNU_C_COMPILER_VERSION 9.0.0)

if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
  if (CMAKE_C_COMPILER_VERSION VERSION_LESS MIN_SUPPORTED_CLANG_C_COMPILER_VERSION)
    set(COMPILER_TOO_OLD TRUE)
  endif()
elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU")
  if (CMAKE_C_COMPILER_VERSION VERSION_LESS MIN_SUPPORTED_GNU_C_COMPILER_VERSION)
    set(COMPILER_TOO_OLD TRUE)
  endif()
else()
  message(WARNING "WARNING: Unsupported C compiler `${CMAKE_C_COMPILER_ID}` is used")
  set (PRINT_MIN_C_COMPILER_VER TRUE)
endif()
if (COMPILER_TOO_OLD)
  message(WARNING "WARNING: C compiler version is too old and it's usage may result")
  message(WARNING "         in sub-optimal binaries or lack of support for specific CPU types.")
  set (PRINT_MIN_C_COMPILER_VER TRUE)
endif()

if (PRINT_MIN_C_COMPILER_VER)
  string (APPEND _t "Supported C compilers are ")
  string (APPEND _t "Clang ${MIN_SUPPORTED_CLANG_C_COMPILER_VERSION} or higher ")
  string (APPEND _t "and GNU ${MIN_SUPPORTED_GNU_C_COMPILER_VERSION} or higher.")
  message(WARNING "         ${_t}")
  unset (_t)
endif()

##############################################################################
# cross compiling
##############################################################################
if(CMAKE_CROSSCOMPILING)
  set(CMAKE_IGNORE_PATH
    /usr/lib/${CMAKE_HOST_SYSTEM_PROCESSOR}-linux-gnu/
    /usr/lib/${CMAKE_HOST_SYSTEM_PROCESSOR}-linux-gnu/lib/
  )
endif()
set(CMAKE_C_COMPILER_TARGET ${CMAKE_SYSTEM_PROCESSOR}-linux-gnu)

##############################################################################
# build config
##############################################################################
check_c_compiler_flag("-Wno-address-of-packed-member"
		      compiler_flag_no_address_of_packed_member)
set(VPP_RUNTIME_DIR ${CMAKE_INSTALL_BINDIR} CACHE STRING "Relative runtime directory path")
set(VPP_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR} CACHE STRING "Relative library directory path")

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${VPP_RUNTIME_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${VPP_LIBRARY_DIR})
set(VPP_BINARY_DIR ${CMAKE_BINARY_DIR}/CMakeFiles)
set(PYENV PYTHONPYCACHEPREFIX=${CMAKE_BINARY_DIR}/CMakeFiles/__pycache__)

if (CMAKE_BUILD_TYPE)
  add_compile_options(-g -Werror -Wall)
endif()

if (compiler_flag_no_address_of_packed_member)
  add_compile_options(-Wno-address-of-packed-member)
endif()

string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LC)
string(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_UC)

set(CMAKE_C_FLAGS_RELEASE "")
set(CMAKE_C_FLAGS_DEBUG "")

if (${CMAKE_BUILD_TYPE_LC} MATCHES "release")
  add_compile_options(-O3 -fstack-protector -fno-common)
  add_compile_definitions(_FORTIFY_SOURCE=2)
elseif (${CMAKE_BUILD_TYPE_LC} MATCHES "debug")
  add_compile_options(-O0 -fstack-protector -fno-common)
  add_compile_definitions(CLIB_DEBUG)
elseif (${CMAKE_BUILD_TYPE_LC} MATCHES "coverity")
  add_compile_options(-O0)
  add_compile_definitions(__COVERITY__)
elseif (${CMAKE_BUILD_TYPE_LC} MATCHES "gcov")
  add_compile_options(-O0 -fprofile-arcs -ftest-coverage)
  add_compile_definitions(CLIB_DEBUG CLIB_GCOV)
endif()

set(BUILD_TYPES release debug coverity gcov)
string(REPLACE ";" " " BUILD_TYPES_STR "${BUILD_TYPES}")
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
	     HELPSTRING "Build type - valid options are: ${BUILD_TYPES_STR}")

##############################################################################
# link time optimizations
##############################################################################
if (CMAKE_BUILD_TYPE_UC STREQUAL "RELEASE")
  check_ipo_supported(RESULT _result)
  if (_result)
    option(VPP_USE_LTO "Link time optimization of release binaries" ON)
  endif()
endif()

if(VPP_USE_LTO)
  check_c_compiler_flag("-Wno-stringop-overflow"
		        compiler_flag_no_stringop_overflow)
endif()
##############################################################################
# sanitizers
##############################################################################

option(VPP_ENABLE_SANITIZE_ADDR "Enable Address Sanitizer" OFF)
set(VPP_SANITIZE_ADDR_OPTIONS
  "unmap_shadow_on_exit=1:disable_coredump=0:abort_on_error=1:detect_leaks=0"
  CACHE
  STRING "Address sanitizer arguments"
)

if (VPP_ENABLE_SANITIZE_ADDR)
  add_compile_options(-fsanitize=address)
  add_link_options(-fsanitize=address)
endif (VPP_ENABLE_SANITIZE_ADDR)

##############################################################################
# trajectory trace
##############################################################################

option(VPP_ENABLE_TRAJECTORY_TRACE "Build vpp with trajectory tracing enabled" OFF)
if(VPP_ENABLE_TRAJECTORY_TRACE)
  add_compile_definitions(VLIB_BUFFER_TRACE_TRAJECTORY=1)
endif()

##############################################################################
# unittest with clang ode coverage
##############################################################################

if("${CMAKE_VERSION}" VERSION_GREATER_EQUAL "3.13" AND "${CMAKE_C_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang")
  option(VPP_BUILD_TESTS_WITH_COVERAGE "Build unit tests with code coverage" OFF)
endif()

##############################################################################
# install config
##############################################################################
option(VPP_SET_RPATH "Set rpath for resulting binaries and libraries." ON)
if(VPP_SET_RPATH)
  set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${VPP_LIBRARY_DIR}")
endif()
set(CMAKE_INSTALL_MESSAGE NEVER)

include_directories (
	${CMAKE_SOURCE_DIR}
	${VPP_BINARY_DIR}
)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "vpp")

set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

include(cmake/syscall.cmake)
include(cmake/api.cmake)
include(cmake/library.cmake)
include(cmake/exec.cmake)
include(cmake/plugin.cmake)

##############################################################################
# subdirs - order matters
##############################################################################
option(VPP_HOST_TOOLS_ONLY "Build only host tools" OFF)
if(VPP_HOST_TOOLS_ONLY)
  set(SUBDIRS tools/vppapigen cmake)
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
  find_package(OpenSSL)
  set(SUBDIRS
    vppinfra svm vlib vlibmemory vlibapi vnet vpp vat vat2 vcl vpp-api
    plugins tools/vppapigen tools/g2 tools/perftool cmake pkg
    tools/appimage
  )
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
  set(SUBDIRS vppinfra)
else()
  message(FATAL_ERROR "Unsupported system: ${CMAKE_SYSTEM_NAME}")
endif()

foreach(DIR ${SUBDIRS})
  add_subdirectory(${DIR} ${VPP_BINARY_DIR}/${DIR})
endforeach()

##############################################################################
# detect if we are inside git repo and add configure dependency
##############################################################################
execute_process(
  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  COMMAND git rev-parse --show-toplevel
  OUTPUT_VARIABLE VPP_GIT_TOPLEVEL_DIR
  OUTPUT_STRIP_TRAILING_WHITESPACE
  ERROR_QUIET
)

if (VPP_GIT_TOPLEVEL_DIR)
  set_property(
    DIRECTORY APPEND PROPERTY
    CMAKE_CONFIGURE_DEPENDS ${VPP_GIT_TOPLEVEL_DIR}/.git/index
  )
endif()

##############################################################################
# custom targets
##############################################################################

add_custom_target(run
  COMMAND ./${VPP_RUNTIME_DIR}/vpp -c startup.conf
  COMMENT "Starting VPP..."
  USES_TERMINAL
)

add_custom_target(debug
  COMMAND gdb --args ./${VPP_RUNTIME_DIR}/vpp -c startup.conf
  COMMENT "Starting VPP in the debugger..."
  USES_TERMINAL
)

add_custom_target(config
  COMMAND ccmake ${CMAKE_BINARY_DIR}
  COMMENT "Starting Configuration TUI..."
  USES_TERMINAL
)

foreach(bt ${BUILD_TYPES})
  add_custom_target(set-build-type-${bt}
    COMMAND cmake -DCMAKE_BUILD_TYPE:STRING=${bt} .
    COMMENT "Changing build type to ${bt}"
    USES_TERMINAL
  )
endforeach()

mark_as_advanced(CLEAR
  CMAKE_C_FLAGS
  CMAKE_C_COMPILER
  CMAKE_EXPORT_COMPILE_COMMANDS
  CMAKE_INSTALL_PREFIX
  CMAKE_LINKER
  CMAKE_SHARED_LINKER_FLAGS
  CMAKE_VERBOSE_MAKEFILE
)

##############################################################################
# print configuration
##############################################################################
message(STATUS "Configuration:")
pr("VPP version" ${VPP_VERSION})
pr("VPP library version" ${VPP_LIB_VERSION})
pr("GIT toplevel dir" ${VPP_GIT_TOPLEVEL_DIR})
pr("Build type" ${CMAKE_BUILD_TYPE})
pr("C compiler" "${CMAKE_C_COMPILER} (${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION})")
pr("C flags" ${CMAKE_C_FLAGS}${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UC}})
pr("Linker flags (apps)" ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE_UC}})
pr("Linker flags (libs)" ${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS_${CMAKE_BUILD_TYPE_UC}})
pr("Host processor" ${CMAKE_HOST_SYSTEM_PROCESSOR})
pr("Target processor" ${CMAKE_SYSTEM_PROCESSOR})
pr("Prefix path" ${CMAKE_PREFIX_PATH})
pr("Install prefix" ${CMAKE_INSTALL_PREFIX})
pr("Library dir" ${VPP_LIBRARY_DIR})
>if [ "$OS_ID" == "centos" ]; then DISTRO="CENTOS" PACKAGE="rpm" sudo yum install -y python-devel python-virtualenv elif [ "$OS_ID" == "ubuntu" ]; then DISTRO="UBUNTU" PACKAGE="deb" export DEBIAN_FRONTEND=noninteractive sudo apt-get -y update sudo apt-get -y install libpython2.7-dev python-virtualenv else echo "$OS_ID is not yet supported." exit 1 fi # 1st step: Download and prepare VPP packages # Temporarily download VPP packages from nexus.fd.io if [ "${#}" -ne "0" ]; then arr=(${@}) echo ${arr[0]} else # Download the latest VPP build install packages CSIT_DIR=${SCRIPT_DIR} source "${SCRIPT_DIR}/resources/libraries/bash/function/artifacts.sh" download_artifacts # Need to revert -euo as the rest of script is not optimized for this. set +euo pipefail fi VIRL_DIR_LOC="/tmp/" VPP_PKGS=(vpp*.$PACKAGE) VPP_PKGS_FULL=("${VPP_PKGS[@]/#/${VIRL_DIR_LOC}}") echo ${VPP_PKGS[@]} VIRL_TOPOLOGY=$(cat ${SCRIPT_DIR}/VIRL_TOPOLOGY_${DISTRO}) VIRL_RELEASE=$(cat ${SCRIPT_DIR}/VIRL_RELEASE_${DISTRO}) VPP_VER="$( expr match $(ls vpp*.${PACKAGE} | head -n 1) 'vpp[-|_]\(.*\)'.${PACKAGE} )" set +x echo "****************************************************************************************************************************************" echo "1st step: Download VPP packages FINISHED" echo "VPP version to be tested: ${VPP_VER}" echo "****************************************************************************************************************************************" set -x # 2nd step: Start virtual env and install requirements echo Starting virtual env... virtualenv --system-site-packages env . env/bin/activate echo Installing requirements... pip install -r ${SCRIPT_DIR}/requirements.txt set +x echo "****************************************************************************************************************************************" echo "2nd step: Start virtual env and install requirements FINISHED" echo "****************************************************************************************************************************************" set -x # 3rd step: Prepare VIRL system echo Preparing VIRL system... VIRL_SERVERS=("10.30.51.28" "10.30.51.29" "10.30.51.30") VIRL_SERVER="" VIRL_USERNAME=jenkins-in VIRL_PKEY=priv_key VIRL_SERVER_STATUS_FILE="status" VIRL_SERVER_EXPECTED_STATUS="PRODUCTION" VIRL_SESSION_EXPIRY="620" SSH_OPTIONS="-i ${VIRL_PKEY} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o BatchMode=yes -o LogLevel=error" function ssh_do() { echo echo "### " ssh $@ ssh ${SSH_OPTIONS} $@ } rm -f ${VIRL_PKEY} cat > ${VIRL_PKEY} <<EOF -----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEA+IHXq87GcqMR1C47rzx6Cbip5Ghq8pKrbqKrP5Nf41HcYrT6 GOXl9nFWKsMOzIlIn+8y7Il27eZh7csQGApbg8QLiHMtcYEmWNzKZpkqg4nuAPxX VXwlKgnKX902SrET9Gp9TDayiHtCRWVfrlPPPSA0UEXW6BjLN/uHJ+W/Xzrrab+9 asBVa05vT2W6n0KJ66zfCaeDM912mQ6SttscAwFoWDmdHlegiVqrlIG2ABxOvxxz L3dM3iSmlmQlzv9bThjo+nI4KFYh6m5wrZmAo5r/4q9CIJc21HVnTqkGOWJIZz6J 73lePJVSq5gYqaoGw3swFEA/MDkOx7baWKSoLQIDAQABAoIBAQCNBeolNp+JWJ76 gQ4fwLsknyXSV6sxYyhkDW4PEwwcTU06uqce0AAzXVffxne0fMe48x47+zqBgPbb 4huM+Pu8B9nfojUMr5TaYtl9Zbgpk3F8H7dT7LKOa6XrxvZTZrADSRc30+Z26zPN e9zTaf42Gvt0/l0Zs1BHwbaOXqO+XuwJ3/F9Sf3PQYWXD3EOWjpHDP/X/1vAs6lV SLkm6J/9KKE1m6I6LTYjIXuYt4SXybW6N2TSy54hhQtYcDUnIU2hR/PHVWKrGA0J kELgrtTNTdbML27O5gFWU4PLUEYTZ9fN11D6qUZKxLcPOiPPHXkiILMRCCnG5DYI ksBAU/YlAoGBAPxZO9VO18TYc8THV1nLKcvT2+1oSs1UcA2wNQMU55t910ZYinRa MRwUhMOf8Mv5wOeiZaRICQB1PnVWtDVmGECgPpK6jUxqAwn8rgJcnoafLGL5YKMY RVafTe6N5LXgCaOcJrk21wxs6v7ninEbUxxc575urOvZMBkymDw91dwbAoGBAPwa YRhKhrzFKZzdK0RadVjnxKvolUllpoqqg3XuvmeAJHAOAnaOgVWq68NAcp5FZJv0 2D2Up7TX8pjf9MofP1SJbcraKBpK4NzfNkA0dSdEi+FhVofAJ9umB2o5LW1n7sab UIrjsdzSJK/9Zb9yTTHPyibYzNEgaJV1HsbxfEFXAoGAYO2RmvRm0phll18OQVJV IpKk9kLKAKZ/R/K32hAsikBC8SVPQTPniyaifFWx81diblalff2hX4ipTf7Yx24I wMIMZuW7Im/R7QMef4+94G3Bad7p7JuE/qnAEHJ2OBnu+eYfxaK35XDsrq6XMazS NqHE7hOq3giVfgg+C12hCKMCgYEAtu9dbYcG5owbehxzfRI2/OCRsjz/t1bv1seM xVMND4XI6xb/apBWAZgZpIFrqrWoIBM3ptfsKipZe91ngBPUnL9s0Dolx452RVAj yctHB8uRxWYgqDkjsxtzXf1HnZBBkBS8CUzYj+hdfuddoeKLaY3invXLCiV+PpXS U4KAK9kCgYEAtSv0m5+Fg74BbAiFB6kCh11FYkW94YI6B/E2D/uVTD5dJhyEUFgZ cWsudXjMki8734WSpMBqBp/J8wG3C9ZS6IpQD+U7UXA+roB7Qr+j4TqtWfM+87Rh maOpG56uAyR0w5Z9BhwzA3VakibVk9KwDgZ29WtKFzuATLFnOtCS46E= -----END RSA PRIVATE KEY----- EOF chmod 600 ${VIRL_PKEY} # # Pick a random host from the array of VIRL servers, and attempt # to reach it and verify it's status. # # The server must be reachable, and have a "status" file with # the content "PRODUCTION", to be selected. # # If the server is not reachable, or does not have the correct # status, remove it from the array and start again. # # Abort if there are no more servers left in the array. # while [[ ! "$VIRL_SERVER" ]] do num_hosts=${#VIRL_SERVERS[@]} if [ $num_hosts == 0 ] then echo "No more VIRL candidate hosts available, failing." exit 127 fi element=$[ $RANDOM % $num_hosts ] virl_server_candidate=${VIRL_SERVERS[$element]} virl_server_status=$(ssh ${SSH_OPTIONS} ${VIRL_USERNAME}@${virl_server_candidate} cat $VIRL_SERVER_STATUS_FILE 2>&1) echo VIRL HOST $virl_server_candidate status is \"$virl_server_status\" if [ "$virl_server_status" == "$VIRL_SERVER_EXPECTED_STATUS" ] then # Candidate is in good status. Select this server. VIRL_SERVER="$virl_server_candidate" else # Candidate is in bad status. Remove from array. VIRL_SERVERS=("${VIRL_SERVERS[@]:0:$element}" "${VIRL_SERVERS[@]:$[$element+1]}") fi done # Copy the files to VIRL host scp ${SSH_OPTIONS} ${VPP_PKGS[@]} \ ${VIRL_USERNAME}@${VIRL_SERVER}:${VIRL_DIR_LOC}/ result=$? if [ "${result}" -ne "0" ]; then echo "Failed to copy vpp deb files to virl host" echo ${result} exit ${result} fi # Start a simulation on VIRL server echo "Starting simulation on VIRL server" function stop_virl_simulation { ssh ${SSH_OPTIONS} ${VIRL_USERNAME}@${VIRL_SERVER}\ "stop-testcase ${VIRL_SID}" } VIRL_SID=$(ssh ${SSH_OPTIONS} \ ${VIRL_USERNAME}@${VIRL_SERVER} \ "start-testcase -vv --copy ${VIRL_TOPOLOGY} \ --expiry ${VIRL_SESSION_EXPIRY} \ --release ${VIRL_RELEASE} ${VPP_PKGS_FULL[@]}") retval=$? if [ ${retval} -ne "0" ]; then echo "VIRL simulation start failed" exit ${retval} fi if [[ ! "${VIRL_SID}" =~ session-[a-zA-Z0-9_]{6} ]]; then echo "No VIRL session ID reported." exit 127 fi # Upon script exit, cleanup the VIRL simulation execution trap stop_virl_simulation EXIT echo ${VIRL_SID} ssh_do ${VIRL_USERNAME}@${VIRL_SERVER} cat /scratch/${VIRL_SID}/topology.yaml # Download the topology file from VIRL session scp ${SSH_OPTIONS} \ ${VIRL_USERNAME}@${VIRL_SERVER}:/scratch/${VIRL_SID}/topology.yaml \ topologies/enabled/topology_VIRL.yaml retval=$? if [ ${retval} -ne "0" ]; then echo "Failed to copy topology file from VIRL simulation" exit ${retval} fi set +x echo "****************************************************************************************************************************************" echo "3rd step: Start the simulation on the VIRL server FINISHED" echo "****************************************************************************************************************************************" set -x # 4th step: Run functional test suites RC=0 MORE_FAILS=0 echo Running functional tests on the VIRL system... # There are used three iterations of functional tests there # to check the stability and reliability of the results. partial_logs="" for test_set in 1 2 3 do echo echo Functional test loop: ${test_set} echo pybot -L TRACE -W 136\ -v TOPOLOGY_PATH:${SCRIPT_DIR}/topologies/enabled/topology_VIRL.yaml \ --suite "tests.vpp.func" \ --include vm_envAND3_node_single_link_topo \ --include vm_envAND3_node_double_link_topo \ --exclude PERFTEST \ --noncritical EXPECTED_FAILING \ --output ${LOG_PATH}/output_func_test_set${test_set} \ tests/ PARTIAL_RC=$(echo $?) partial_logs="${partial_logs} ${LOG_PATH}/output_func_test_set${test_set}.xml" if [ ${PARTIAL_RC} -eq 250 ]; then MORE_FAILS=1 fi RC=$((RC+PARTIAL_RC)) done set +x echo "****************************************************************************************************************************************" echo "4th step: Run functional tests FINISHED" echo "****************************************************************************************************************************************" set -x # Set RETURN_STATUS=1 if some critical test failed if [ ! ${RC} -eq 0 ]; then RETURN_STATUS=1 fi # Log the final result if [ ${RC} -eq 0 ]; then set +x echo echo "========================================================================================================================================" echo "Final result of all test loops: | PASS |" echo "All critical tests have passed." echo "========================================================================================================================================" echo set -x elif [ ${MORE_FAILS} -eq 0 ]; then if [ ${RC} -eq 1 ]; then HLP_STR="test has" else HLP_STR="tests have" fi set +x echo echo "========================================================================================================================================" echo "Final result of all test loops: | FAIL |" echo "${RC} critical ${HLP_STR} failed." echo "========================================================================================================================================" echo set -x else set +x echo echo "========================================================================================================================================" echo "Final result of all test loops: | FAIL |" echo "More then 250 critical tests have failed in one test loop." echo "========================================================================================================================================" echo set -x fi # 7th step: Post-processing test data echo Post-processing test data... # Rebot output post-processing rebot --noncritical EXPECTED_FAILING \ --output output.xml ${partial_logs} # Remove unnecessary files rm -f ${partial_logs} # Archive JOB artifacts in jenkins for i in ${JOB_ARCHIVE_ARTIFACTS[@]}; do cp $( readlink -f ${i} | tr '\n' ' ' ) ${JOB_ARCHIVE_DIR}/ done # Archive JOB artifacts to logs.fd.io for i in ${LOG_ARCHIVE_ARTIFACTS[@]}; do cp $( readlink -f ${i} | tr '\n' ' ' ) ${LOG_ARCHIVE_DIR}/ done echo Post-processing finished. exit ${RETURN_STATUS}