tests: refactor asf framework code
[vpp.git] / Makefile
1 # Copyright (c) 2021 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 export WS_ROOT=$(CURDIR)
15 export BR=$(WS_ROOT)/build-root
16 CCACHE_DIR?=$(BR)/.ccache
17 SHELL:=/bin/bash
18 GDB?=gdb
19 PLATFORM?=vpp
20 SAMPLE_PLUGIN?=no
21 STARTUP_DIR?=$(PWD)
22 MACHINE=$(shell uname -m)
23 SUDO?=sudo -E
24 DPDK_CONFIG?=no-pci
25
26 ,:=,
27 define disable_plugins
28 $(if $(1), \
29   "plugins {" \
30   $(patsubst %,"plugin %_plugin.so { disable }",$(subst $(,), ,$(1))) \
31   " }" \
32   ,)
33 endef
34
35 MINIMAL_STARTUP_CONF="                                                  \
36 unix {                                                                  \
37         interactive                                                     \
38         cli-listen /run/vpp/cli.sock                                    \
39         gid $(shell id -g)                                              \
40         $(if $(wildcard startup.vpp),"exec startup.vpp",)               \
41 }                                                                       \
42 $(if $(DPDK_CONFIG), "dpdk { $(DPDK_CONFIG) }",)                        \
43 $(if $(EXTRA_VPP_CONFIG), "$(EXTRA_VPP_CONFIG)",)                       \
44 $(call disable_plugins,$(DISABLED_PLUGINS))                             \
45 "
46
47 GDB_ARGS= -ex "handle SIGUSR1 noprint nostop"
48
49 #
50 # OS Detection
51 #
52 # We allow Darwin (MacOS) for docs generation; VPP build will still fail.
53 ifneq ($(shell uname),Darwin)
54 OS_ID        = $(shell grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
55 OS_VERSION_ID= $(shell grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
56 endif
57
58 ifeq ($(filter ubuntu debian linuxmint,$(OS_ID)),$(OS_ID))
59 PKG=deb
60 else ifeq ($(filter rhel centos fedora opensuse-leap rocky,$(OS_ID)),$(OS_ID))
61 PKG=rpm
62 endif
63
64 # +libganglia1-dev if building the gmond plugin
65
66 DEB_DEPENDS  = curl build-essential autoconf automake ccache
67 DEB_DEPENDS += debhelper dkms git libtool libapr1-dev dh-python
68 DEB_DEPENDS += libconfuse-dev git-review exuberant-ctags cscope pkg-config
69 DEB_DEPENDS += gcovr lcov chrpath autoconf libnuma-dev
70 DEB_DEPENDS += python3-all python3-setuptools check
71 DEB_DEPENDS += libffi-dev python3-ply
72 DEB_DEPENDS += cmake ninja-build python3-jsonschema python3-yaml
73 DEB_DEPENDS += python3-venv  # ensurepip
74 DEB_DEPENDS += python3-dev python3-pip
75 DEB_DEPENDS += libnl-3-dev libnl-route-3-dev libmnl-dev
76 # DEB_DEPENDS += enchant  # for docs
77 DEB_DEPENDS += python3-virtualenv
78 DEB_DEPENDS += libssl-dev
79 DEB_DEPENDS += libelf-dev libpcap-dev # for libxdp (af_xdp)
80 DEB_DEPENDS += iperf3 # for 'make test TEST=vcl'
81 DEB_DEPENDS += nasm
82 DEB_DEPENDS += iperf ethtool  # for 'make test TEST=vm_vpp_interfaces'
83 DEB_DEPENDS += libpcap-dev
84 DEB_DEPENDS += tshark
85
86 LIBFFI=libffi6 # works on all but 20.04 and debian-testing
87
88 ifeq ($(OS_VERSION_ID),22.04)
89         DEB_DEPENDS += python3-virtualenv
90         DEB_DEPENDS += libssl-dev
91         DEB_DEPENDS += clang clang-format-11
92         LIBFFI=libffi7
93         DEB_DEPENDS += enchant-2  # for docs
94 else ifeq ($(OS_VERSION_ID),20.04)
95         DEB_DEPENDS += python3-virtualenv
96         DEB_DEPENDS += libssl-dev
97         DEB_DEPENDS += clang clang-format-11
98         LIBFFI=libffi7
99         DEB_DEPENDS += enchant-2  # for docs
100 else ifeq ($(OS_VERSION_ID),20.10)
101         DEB_DEPENDS += clang clang-format-11
102         LIBFFI=libffi8ubuntu1
103 else ifeq ($(OS_ID)-$(OS_VERSION_ID),debian-10)
104         DEB_DEPENDS += virtualenv
105 else ifeq ($(OS_ID)-$(OS_VERSION_ID),debian-11)
106         DEB_DEPENDS += virtualenv
107         DEB_DEPENDS += clang clang-format-11
108         LIBFFI=libffi7
109 else
110         DEB_DEPENDS += clang-11 clang-format-11
111         LIBFFI=libffi7
112         DEB_DEPENDS += enchant-2  # for docs
113 endif
114
115 DEB_DEPENDS += $(LIBFFI)
116
117 RPM_DEPENDS  = glibc-static
118 RPM_DEPENDS += apr-devel
119 RPM_DEPENDS += numactl-devel
120 RPM_DEPENDS += check check-devel
121 RPM_DEPENDS += selinux-policy selinux-policy-devel
122 RPM_DEPENDS += ninja-build
123 RPM_DEPENDS += ccache
124 RPM_DEPENDS += xmlto
125 RPM_DEPENDS += elfutils-libelf-devel libpcap-devel
126 RPM_DEPENDS += libnl3-devel libmnl-devel
127 RPM_DEPENDS += nasm
128
129 ifeq ($(OS_ID),fedora)
130         RPM_DEPENDS += dnf-utils
131         RPM_DEPENDS += subunit subunit-devel
132         RPM_DEPENDS += compat-openssl10-devel
133         RPM_DEPENDS += python3-devel  # needed for python3 -m pip install psutil
134         RPM_DEPENDS += python3-ply  # for vppapigen
135         RPM_DEPENDS += python3-virtualenv python3-jsonschema
136         RPM_DEPENDS += cmake
137         RPM_DEPENDS_GROUPS = 'C Development Tools and Libraries'
138 else ifeq ($(OS_ID),rocky)
139         RPM_DEPENDS += yum-utils
140         RPM_DEPENDS += subunit subunit-devel
141         RPM_DEPENDS += openssl-devel
142         RPM_DEPENDS += python3-devel  # needed for python3 -m pip install psutil
143         RPM_DEPENDS += python3-ply  # for vppapigen
144         RPM_DEPENDS += python3-virtualenv python3-jsonschema
145         RPM_DEPENDS += infiniband-diags llvm clang cmake
146         RPM_DEPENDS_GROUPS = 'Development Tools'
147 else ifeq ($(OS_ID)-$(OS_VERSION_ID),centos-8)
148         RPM_DEPENDS += yum-utils
149         RPM_DEPENDS += compat-openssl10 openssl-devel
150         RPM_DEPENDS += python2-devel python36-devel python3-ply
151         RPM_DEPENDS += python3-virtualenv python3-jsonschema
152         RPM_DEPENDS += libarchive cmake
153         RPM_DEPENDS += infiniband-diags libibumad
154         RPM_DEPENDS += libpcap-devel llvm-toolset
155         RPM_DEPENDS_GROUPS = 'Development Tools'
156 else
157         RPM_DEPENDS += yum-utils
158         RPM_DEPENDS += openssl-devel
159         RPM_DEPENDS += python36-ply  # for vppapigen
160         RPM_DEPENDS += python3-devel python3-pip
161         RPM_DEPENDS += python-virtualenv python36-jsonschema
162         RPM_DEPENDS += devtoolset-9 devtoolset-9-libasan-devel
163         RPM_DEPENDS += cmake3
164         RPM_DEPENDS_GROUPS = 'Development Tools'
165 endif
166
167 # +ganglia-devel if building the ganglia plugin
168
169 RPM_DEPENDS += chrpath libffi-devel rpm-build
170
171 RPM_DEPENDS_DEBUG  = glibc-debuginfo e2fsprogs-debuginfo
172 RPM_DEPENDS_DEBUG += krb5-debuginfo openssl-debuginfo
173 RPM_DEPENDS_DEBUG += zlib-debuginfo nss-softokn-debuginfo
174 RPM_DEPENDS_DEBUG += yum-plugin-auto-update-debug-info
175
176 RPM_SUSE_BUILDTOOLS_DEPS = autoconf automake ccache check-devel chrpath
177 RPM_SUSE_BUILDTOOLS_DEPS += clang cmake indent libtool make ninja python3-ply
178
179 RPM_SUSE_DEVEL_DEPS = glibc-devel-static libnuma-devel libelf-devel
180 RPM_SUSE_DEVEL_DEPS += libopenssl-devel lsb-release
181 RPM_SUSE_DEVEL_DEPS += libpcap-devel llvm-devel
182 RPM_SUSE_DEVEL_DEPS += curl libstdc++-devel bison gcc-c++ zlib-devel
183
184 RPM_SUSE_PYTHON_DEPS = python3-devel python3-pip python3-rpm-macros
185
186 RPM_SUSE_PLATFORM_DEPS = shadow rpm-build
187
188 ifeq ($(OS_ID),opensuse-leap)
189         RPM_SUSE_DEVEL_DEPS += xmlto openssl-devel asciidoc git nasm
190         RPM_SUSE_PYTHON_DEPS += python3 python3-ply python3-virtualenv
191         RPM_SUSE_PLATFORM_DEPS += distribution-release
192 endif
193
194 RPM_SUSE_DEPENDS += $(RPM_SUSE_BUILDTOOLS_DEPS) $(RPM_SUSE_DEVEL_DEPS) $(RPM_SUSE_PYTHON_DEPS) $(RPM_SUSE_PLATFORM_DEPS)
195
196 ifneq ($(wildcard $(STARTUP_DIR)/startup.conf),)
197         STARTUP_CONF ?= $(STARTUP_DIR)/startup.conf
198 endif
199
200 ifeq ($(findstring y,$(UNATTENDED)),y)
201 DEBIAN_FRONTEND=noninteractive
202 CONFIRM=-y
203 FORCE=--allow-downgrades --allow-remove-essential --allow-change-held-packages
204 endif
205
206 TARGETS = vpp
207
208 ifneq ($(SAMPLE_PLUGIN),no)
209 TARGETS += sample-plugin
210 endif
211
212 define banner
213         @echo "========================================================================"
214         @echo " $(1)"
215         @echo "========================================================================"
216         @echo " "
217 endef
218
219 .PHONY: help
220 help:
221         @echo "Make Targets:"
222         @echo " install-dep[s]       - install software dependencies"
223         @echo " wipe                 - wipe all products of debug build "
224         @echo " wipe-release         - wipe all products of release build "
225         @echo " build                - build debug binaries"
226         @echo " build-release        - build release binaries"
227         @echo " build-coverity       - build coverity artifacts"
228         @echo " rebuild              - wipe and build debug binaries"
229         @echo " rebuild-release      - wipe and build release binaries"
230         @echo " run                  - run debug binary"
231         @echo " run-release          - run release binary"
232         @echo " debug                - run debug binary with debugger"
233         @echo " debug-release        - run release binary with debugger"
234         @echo " test                 - build and run tests"
235         @echo " test-help            - show help on test framework"
236         @echo " run-vat              - run vpp-api-test tool"
237         @echo " pkg-deb              - build DEB packages"
238         @echo " pkg-deb-debug        - build DEB debug packages"
239         @echo " pkg-snap             - build SNAP package"
240         @echo " snap-clean           - clean up snap build environment"
241         @echo " pkg-rpm              - build RPM packages"
242         @echo " install-ext-dep[s]   - install external development dependencies"
243         @echo " ctags                - (re)generate ctags database"
244         @echo " gtags                - (re)generate gtags database"
245         @echo " cscope               - (re)generate cscope database"
246         @echo " compdb               - (re)generate compile_commands.json"
247         @echo " checkstyle           - check coding style"
248         @echo " checkstyle-commit    - check commit message format"
249         @echo " checkstyle-python    - check python coding style using 'black' formatter"
250         @echo " checkstyle-api       - check api for incompatible changes"
251         @echo " fixstyle             - fix coding style"
252         @echo " fixstyle-python      - fix python coding style using 'black' formatter"
253         @echo " doxygen              - DEPRECATED - use 'make docs'"
254         @echo " bootstrap-doxygen    - DEPRECATED"
255         @echo " wipe-doxygen         - DEPRECATED"
256         @echo " checkfeaturelist     - check FEATURE.yaml according to schema"
257         @echo " featurelist          - dump feature list in markdown"
258         @echo " json-api-files       - (re)-generate json api files"
259         @echo " json-api-files-debug - (re)-generate json api files for debug target"
260         @echo " go-api-files         - (re)-generate golang api files"
261         @echo " docs                 - Build the Sphinx documentation"
262         @echo " docs-venv            - Build the virtual environment for the Sphinx docs"
263         @echo " docs-clean           - Remove the generated files from the Sphinx docs"
264         @echo " docs-rebuild         - Rebuild all of the Sphinx documentation"
265         @echo ""
266         @echo "Make Arguments:"
267         @echo " V=[0|1]                  - set build verbosity level"
268         @echo " STARTUP_CONF=<path>      - startup configuration file"
269         @echo "                            (e.g. /etc/vpp/startup.conf)"
270         @echo " STARTUP_DIR=<path>       - startup directory (e.g. /etc/vpp)"
271         @echo "                            It also sets STARTUP_CONF if"
272         @echo "                            startup.conf file is present"
273         @echo " GDB=<path>               - gdb binary to use for debugging"
274         @echo " PLATFORM=<name>          - target platform. default is vpp"
275         @echo " DPDK_CONFIG=<conf>       - add specified dpdk config commands to"
276         @echo "                            autogenerated startup.conf"
277         @echo "                            (e.g. \"no-pci\" )"
278         @echo " SAMPLE_PLUGIN=yes        - in addition build/run/debug sample plugin"
279         @echo " DISABLED_PLUGINS=<list>  - comma separated list of plugins which"
280         @echo "                            should not be loaded"
281         @echo ""
282         @echo "Current Argument Values:"
283         @echo " V                 = $(V)"
284         @echo " STARTUP_CONF      = $(STARTUP_CONF)"
285         @echo " STARTUP_DIR       = $(STARTUP_DIR)"
286         @echo " GDB               = $(GDB)"
287         @echo " PLATFORM          = $(PLATFORM)"
288         @echo " DPDK_VERSION      = $(DPDK_VERSION)"
289         @echo " DPDK_CONFIG       = $(DPDK_CONFIG)"
290         @echo " SAMPLE_PLUGIN     = $(SAMPLE_PLUGIN)"
291         @echo " DISABLED_PLUGINS  = $(DISABLED_PLUGINS)"
292
293 $(BR)/.deps.ok:
294 ifeq ($(findstring y,$(UNATTENDED)),y)
295         make install-dep
296 endif
297 ifeq ($(filter ubuntu debian linuxmint,$(OS_ID)),$(OS_ID))
298         @MISSING=$$(apt-get install -y -qq -s $(DEB_DEPENDS) | grep "^Inst ") ; \
299         if [ -n "$$MISSING" ] ; then \
300           echo "\nPlease install missing packages: \n$$MISSING\n" ; \
301           echo "by executing \"make install-dep\"\n" ; \
302           exit 1 ; \
303         fi ; \
304         exit 0
305 else ifneq ("$(wildcard /etc/redhat-release)","")
306         @for i in $(RPM_DEPENDS) ; do \
307             RPM=$$(basename -s .rpm "$${i##*/}" | cut -d- -f1,2,3,4)  ; \
308             MISSING+=$$(rpm -q $$RPM | grep "^package")    ;    \
309         done                                                       ;    \
310         if [ -n "$$MISSING" ] ; then \
311           echo "Please install missing RPMs: \n$$MISSING\n" ; \
312           echo "by executing \"make install-dep\"\n" ; \
313           exit 1 ; \
314         fi ; \
315         exit 0
316 endif
317         @touch $@
318
319 .PHONY: bootstrap
320 bootstrap:
321         @echo "'make bootstrap' is not needed anymore"
322
323 .PHONY: install-dep
324 install-dep:
325 ifeq ($(filter ubuntu debian linuxmint,$(OS_ID)),$(OS_ID))
326         @sudo -E apt-get update
327         @sudo -E apt-get $(APT_ARGS) $(CONFIRM) $(FORCE) install $(DEB_DEPENDS)
328 else ifneq ("$(wildcard /etc/redhat-release)","")
329 ifeq ($(OS_ID),rhel)
330         @sudo -E yum-config-manager --enable rhel-server-rhscl-7-rpms
331         @sudo -E yum groupinstall $(CONFIRM) $(RPM_DEPENDS_GROUPS)
332         @sudo -E yum install $(CONFIRM) $(RPM_DEPENDS)
333         @sudo -E debuginfo-install $(CONFIRM) glibc openssl-libs zlib
334 else ifeq ($(OS_ID),rocky)
335         @sudo -E dnf install $(CONFIRM) dnf-plugins-core epel-release
336         @sudo -E dnf config-manager --set-enabled \
337           $(shell dnf repolist all 2>/dev/null|grep -i crb|cut -d' ' -f1|grep -v source)
338         @sudo -E dnf groupinstall $(CONFIRM) $(RPM_DEPENDS_GROUPS)
339         @sudo -E dnf install $(CONFIRM) $(RPM_DEPENDS)
340 else ifeq ($(OS_ID)-$(OS_VERSION_ID),centos-8)
341         @sudo -E dnf install $(CONFIRM) dnf-plugins-core epel-release
342         @sudo -E dnf config-manager --set-enabled \
343           $(shell dnf repolist all 2>/dev/null|grep -i powertools|cut -d' ' -f1|grep -v source)
344         @sudo -E dnf groupinstall $(CONFIRM) $(RPM_DEPENDS_GROUPS)
345         @sudo -E dnf install --skip-broken $(CONFIRM) $(RPM_DEPENDS)
346 else ifeq ($(OS_ID),centos)
347         @sudo -E yum install $(CONFIRM) centos-release-scl-rh epel-release
348         @sudo -E yum groupinstall $(CONFIRM) $(RPM_DEPENDS_GROUPS)
349         @sudo -E yum install $(CONFIRM) $(RPM_DEPENDS)
350         @sudo -E yum install $(CONFIRM) --enablerepo=base-debuginfo $(RPM_DEPENDS_DEBUG)
351 else ifeq ($(OS_ID),fedora)
352         @sudo -E dnf groupinstall $(CONFIRM) $(RPM_DEPENDS_GROUPS)
353         @sudo -E dnf install $(CONFIRM) $(RPM_DEPENDS)
354         @sudo -E debuginfo-install $(CONFIRM) glibc openssl-libs zlib
355 endif
356 else ifeq ($(filter opensuse-leap-15.3 opensuse-leap-15.4 ,$(OS_ID)-$(OS_VERSION_ID)),$(OS_ID)-$(OS_VERSION_ID))
357         @sudo -E zypper refresh
358         @sudo -E zypper install  -y $(RPM_SUSE_DEPENDS)
359 else
360         $(error "This option currently works only on Ubuntu, Debian, RHEL, CentOS or openSUSE-leap systems")
361 endif
362         git config commit.template .git_commit_template.txt
363
364 .PHONY: install-deps
365 install-deps: install-dep
366
367 define make
368         @make -C $(BR) PLATFORM=$(PLATFORM) TAG=$(1) $(2)
369 endef
370
371 $(BR)/scripts/.version:
372 ifneq ("$(wildcard /etc/redhat-release)","")
373         $(shell $(BR)/scripts/version rpm-string > $(BR)/scripts/.version)
374 else
375         $(shell $(BR)/scripts/version > $(BR)/scripts/.version)
376 endif
377
378 DIST_FILE = $(BR)/vpp-$(shell src/scripts/version).tar
379 DIST_SUBDIR = vpp-$(shell src/scripts/version|cut -f1 -d-)
380
381 .PHONY: dist
382 dist:
383         @if git rev-parse 2> /dev/null ; then \
384             git archive \
385               --prefix=$(DIST_SUBDIR)/ \
386               --format=tar \
387               -o $(DIST_FILE) \
388             HEAD ; \
389             git describe --long > $(BR)/.version ; \
390         else \
391             (cd .. ; tar -cf $(DIST_FILE) $(DIST_SUBDIR) --exclude=*.tar) ; \
392             src/scripts/version > $(BR)/.version ; \
393         fi
394         @tar --append \
395           --file $(DIST_FILE) \
396           --transform='s,.*/.version,$(DIST_SUBDIR)/src/scripts/.version,' \
397           $(BR)/.version
398         @$(RM) $(BR)/.version $(DIST_FILE).xz
399         @xz -v --threads=0 $(DIST_FILE)
400         @$(RM) $(BR)/vpp-latest.tar.xz
401         @ln -rs $(DIST_FILE).xz $(BR)/vpp-latest.tar.xz
402
403 .PHONY: build
404 build: $(BR)/.deps.ok
405         $(call make,$(PLATFORM)_debug,$(addsuffix -install,$(TARGETS)))
406
407 .PHONY: wipedist
408 wipedist:
409         @$(RM) $(BR)/*.tar.xz
410
411 .PHONY: wipe
412 wipe: wipedist test-wipe $(BR)/.deps.ok
413         $(call make,$(PLATFORM)_debug,$(addsuffix -wipe,$(TARGETS)))
414         @find . -type f -name "*.api.json" ! -path "./src/*" -exec rm {} \;
415
416 .PHONY: rebuild
417 rebuild: wipe build
418
419 .PHONY: build-release
420 build-release: $(BR)/.deps.ok
421         $(call make,$(PLATFORM),$(addsuffix -install,$(TARGETS)))
422
423 .PHONY: wipe-release
424 wipe-release: test-wipe $(BR)/.deps.ok
425         $(call make,$(PLATFORM),$(addsuffix -wipe,$(TARGETS)))
426
427 .PHONY: rebuild-release
428 rebuild-release: wipe-release build-release
429
430 export TEST_DIR ?= $(WS_ROOT)/test
431
432 define test
433         $(if $(filter-out $(2),retest),make -C $(BR) PLATFORM=vpp TAG=$(1) CC=$(CC) vpp-install,)
434         $(eval libs:=lib lib64)
435         make -C test \
436           VPP_BUILD_DIR=$(BR)/build-$(1)-native/vpp \
437           VPP_BIN=$(BR)/install-$(1)-native/vpp/bin/vpp \
438           VPP_INSTALL_PATH=$(BR)/install-$(1)-native/ \
439           EXTENDED_TESTS=$(EXTENDED_TESTS) \
440           TEST_GCOV=$(TEST_GCOV) \
441           PYTHON=$(PYTHON) \
442           OS_ID=$(OS_ID) \
443           RND_SEED=$(RND_SEED) \
444           CACHE_OUTPUT=$(CACHE_OUTPUT) \
445           TAG=$(1) \
446           $(2)
447 endef
448
449 .PHONY: test
450 test:
451         $(call test,vpp,test)
452
453 .PHONY: test-debug
454 test-debug:
455         $(call test,vpp_debug,test)
456
457 .PHONY: test-cov
458 test-cov:
459         $(eval CC=gcc)
460         $(eval TEST_GCOV=1)
461         $(call test,vpp_gcov,cov)
462
463 .PHONY: test-cov-build
464 test-cov-build:
465         $(eval CC=gcc)
466         $(eval TEST_GCOV=1)
467         $(call test,vpp_gcov,test)
468
469 .PHONY: test-cov-prep
470 test-cov-prep:
471         $(eval CC=gcc)
472         $(call test,vpp_gcov,cov-prep)
473
474 .PHONY: test-cov-post
475 test-cov-post:
476         $(eval CC=gcc)
477         $(call test,vpp_gcov,cov-post)
478
479 .PHONY: test-all
480 test-all:
481         $(eval EXTENDED_TESTS=1)
482         $(call test,vpp,test)
483
484 .PHONY: test-all-debug
485 test-all-debug:
486         $(eval EXTENDED_TESTS=1)
487         $(call test,vpp_debug,test)
488
489 .PHONY: test-all-cov
490 test-all-cov:
491         $(eval CC=gcc)
492         $(eval TEST_GCOV=1)
493         $(eval EXTENDED_TESTS=1)
494         $(call test,vpp_gcov,test)
495
496 .PHONY: papi-wipe
497 papi-wipe: test-wipe-papi
498         $(call banner,"This command is deprecated. Please use 'test-wipe-papi'")
499
500 .PHONY: test-wipe-papi
501 test-wipe-papi:
502         @make -C test wipe-papi
503
504 .PHONY: test-help
505 test-help:
506         @make -C test help
507
508 .PHONY: test-wipe
509 test-wipe:
510         @make -C test wipe
511
512 .PHONY: test-shell
513 test-shell:
514         $(call test,vpp,shell)
515
516 .PHONY: test-shell-debug
517 test-shell-debug:
518         $(call test,vpp_debug,shell)
519
520 .PHONY: test-shell-cov
521 test-shell-cov:
522         $(eval CC=gcc)
523         $(eval TEST_GCOV=1)
524         $(call test,vpp_gcov,shell)
525
526 .PHONY: test-dep
527 test-dep:
528         @make -C test test-dep
529
530 .PHONY: test-doc
531 test-doc:
532         @echo "make test-doc is DEPRECATED: use 'make docs'"
533         sleep 300
534
535 .PHONY: test-wipe-doc
536 test-wipe-doc:
537         @echo "make test-wipe-doc is DEPRECATED"
538         sleep 300
539
540 .PHONY: test-wipe-cov
541 test-wipe-cov:
542         $(call make,$(PLATFORM)_gcov,$(addsuffix -wipe,$(TARGETS)))
543         @make -C test wipe-cov
544
545 .PHONY: test-wipe-all
546 test-wipe-all:
547         @make -C test wipe-all
548
549 # Note: All python venv consolidated in test/Makefile, test/requirements*.txt
550 .PHONY: test-checkstyle
551 test-checkstyle:
552         $(warning test-checkstyle is deprecated. Running checkstyle-python.")
553         @make -C test checkstyle-python-all
554
555 # Note: All python venv consolidated in test/Makefile, test/requirements*.txt
556 .PHONY: test-checkstyle-diff
557 test-checkstyle-diff:
558         $(warning test-checkstyle-diff is deprecated. Running checkstyle-python.")
559         @make -C test checkstyle-python-all
560
561 .PHONY: test-refresh-deps
562 test-refresh-deps:
563         @make -C test refresh-deps
564
565 .PHONY: retest
566 retest:
567         $(call test,vpp,retest)
568
569 .PHONY: retest-debug
570 retest-debug:
571         $(call test,vpp_debug,retest)
572
573 .PHONY: retest-all
574 retest-all:
575         $(eval EXTENDED_TESTS=1)
576         $(call test,vpp,retest)
577
578 .PHONY: retest-all-debug
579 retest-all-debug:
580         $(eval EXTENDED_TESTS=1)
581         $(call test,vpp_debug,retest)
582
583 .PHONY: test-start-vpp-in-gdb
584 test-start-vpp-in-gdb:
585         $(call test,vpp,start-gdb)
586
587 .PHONY: test-start-vpp-debug-in-gdb
588 test-start-vpp-debug-in-gdb:
589         $(call test,vpp_debug,start-gdb)
590
591 ifeq ("$(wildcard $(STARTUP_CONF))","")
592 define run
593         @echo "WARNING: STARTUP_CONF not defined or file doesn't exist."
594         @echo "         Running with minimal startup config: $(MINIMAL_STARTUP_CONF)\n"
595         @cd $(STARTUP_DIR) && \
596           $(SUDO) $(2) $(1)/vpp/bin/vpp $(MINIMAL_STARTUP_CONF)
597 endef
598 else
599 define run
600         @cd $(STARTUP_DIR) && \
601           $(SUDO) $(2) $(1)/vpp/bin/vpp $(shell cat $(STARTUP_CONF) | sed -e 's/#.*//')
602 endef
603 endif
604
605 %.files: .FORCE
606         @find src -name '*.[chS]' > $@
607
608 .FORCE:
609
610 .PHONY: run
611 run:
612         $(call run, $(BR)/install-$(PLATFORM)_debug-native)
613
614 .PHONY: run-release
615 run-release:
616         $(call run, $(BR)/install-$(PLATFORM)-native)
617
618 .PHONY: debug
619 debug:
620         $(call run, $(BR)/install-$(PLATFORM)_debug-native,$(GDB) $(GDB_ARGS) --args)
621
622 .PHONY: build-coverity
623 build-coverity:
624         $(call make,$(PLATFORM)_coverity,install-packages)
625         @make -C build-root PLATFORM=vpp TAG=vpp_coverity libmemif-install
626
627 .PHONY: debug-release
628 debug-release:
629         $(call run, $(BR)/install-$(PLATFORM)-native,$(GDB) $(GDB_ARGS) --args)
630
631 .PHONY: build-vat
632 build-vat:
633         $(call make,$(PLATFORM)_debug,vpp-api-test-install)
634
635 .PHONY: run-vat
636 run-vat:
637         @$(SUDO) $(BR)/install-$(PLATFORM)_debug-native/vpp/bin/vpp_api_test
638
639 .PHONY: pkg-deb
640 pkg-deb:
641         $(call make,$(PLATFORM),vpp-package-deb)
642
643 .PHONY: pkg-snap
644 pkg-snap:
645         cd extras/snap ;                        \
646         ./prep ;                                \
647         SNAPCRAFT_BUILD_ENVIRONMENT_MEMORY=8G   \
648         SNAPCRAFT_BUILD_ENVIRONMENT_CPU=6       \
649         snapcraft --debug
650
651 .PHONY: snap-clean
652 snap-clean:
653         cd extras/snap ;                        \
654         snapcraft clean ;                       \
655         rm -f *.snap *.tgz
656
657 .PHONY: pkg-deb-debug
658 pkg-deb-debug:
659         $(call make,$(PLATFORM)_debug,vpp-package-deb)
660
661 .PHONY: pkg-rpm
662 pkg-rpm: dist
663         make -C extras/rpm
664
665 .PHONY: pkg-srpm
666 pkg-srpm: dist
667         make -C extras/rpm srpm
668
669 .PHONY: install-ext-deps
670 install-ext-deps:
671         make -C build/external install-$(PKG)
672
673 .PHONY: install-ext-dep
674 install-ext-dep: install-ext-deps
675
676 .PHONY: json-api-files
677 json-api-files:
678         $(WS_ROOT)/src/tools/vppapigen/generate_json.py
679
680 .PHONY: json-api-files-debug
681 json-api-files-debug:
682         $(WS_ROOT)/src/tools/vppapigen/generate_json.py --debug-target
683
684 .PHONY: go-api-files
685 go-api-files: json-api-files
686         $(WS_ROOT)/src/tools/vppapigen/generate_go.py $(ARGS)
687
688 .PHONY: ctags
689 ctags: ctags.files
690         @ctags --totals --tag-relative=yes -L $<
691         @rm $<
692
693 .PHONY: gtags
694 gtags: ctags
695         @gtags --gtagslabel=ctags
696
697 .PHONY: cscope
698 cscope: cscope.files
699         @cscope -b -q -v
700
701 .PHONY: compdb
702 compdb:
703         @ninja -C build-root/build-vpp_debug-native/vpp build.ninja
704         @ninja -C build-root/build-vpp_debug-native/vpp -t compdb | \
705           src/scripts/compdb_cleanup.py > compile_commands.json
706
707 .PHONY: checkstyle
708 checkstyle: checkfeaturelist
709         @extras/scripts/checkstyle.sh
710
711 .PHONY: checkstyle-commit
712 checkstyle-commit:
713         @extras/scripts/check_commit_msg.sh
714
715 .PHONY: checkstyle-test
716 checkstyle-test:
717         $(warning test-checkstyle is deprecated. Running checkstyle-python.")
718         @make -C test checkstyle-python-all
719
720 # Note: All python venv consolidated in test/Makefile, test/requirements*.txt
721 .PHONY: checkstyle-python
722 checkstyle-python:
723         @make -C test checkstyle-python-all
724
725 .PHONY: checkstyle-all
726 checkstyle-all: checkstyle-commit checkstyle checkstyle-python docs-spell
727
728 .PHONY: fixstyle
729 fixstyle:
730         @extras/scripts/checkstyle.sh --fix
731
732 # Note: All python venv consolidated in test/Makefile, test/requirements*.txt
733 .PHONY: fixstyle-python
734 fixstyle-python:
735         @make -C test fixstyle-python-all
736
737 .PHONY: checkstyle-api
738 checkstyle-api:
739         @extras/scripts/crcchecker.py --check-patchset
740
741 # necessary because Bug 1696324 - Update to python3.6 breaks PyYAML dependencies
742 # Status:       CLOSED CANTFIX
743 # https://bugzilla.redhat.com/show_bug.cgi?id=1696324
744 .PHONY: centos-pyyaml
745 centos-pyyaml:
746 ifeq ($(OS_ID)-$(OS_VERSION_ID),centos-8)
747         @sudo -E yum install $(CONFIRM) python3-pyyaml
748 endif
749
750 .PHONY: featurelist
751 featurelist: centos-pyyaml
752         @extras/scripts/fts.py --all --markdown
753
754 .PHONY: checkfeaturelist
755 checkfeaturelist: centos-pyyaml
756         @extras/scripts/fts.py --validate --all
757
758 #
759 # Build the documentation
760 #
761
762 .PHONY: bootstrap-doxygen
763 bootstrap-doxygen:
764         @echo "make bootstrap-doxygen is DEPRECATED"
765         sleep 300
766
767 .PHONY: doxygen
768 doxygen: docs
769         @echo "make doxygen is DEPRECATED: use 'make docs'"
770         sleep 300
771
772 .PHONY: wipe-doxygen
773 wipe-doxygen:
774         @echo "make wipe-doxygen is DEPRECATED"
775         sleep 300
776
777 .PHONY: docs-%
778 docs-%:
779         @make -C $(WS_ROOT)/docs $*
780
781 .PHONY: docs
782 docs:
783         @make -C $(WS_ROOT)/docs docs
784
785 .PHONY: pkg-verify
786 pkg-verify: install-dep $(BR)/.deps.ok install-ext-deps
787         $(call banner,"Building for PLATFORM=vpp")
788         @make -C build-root PLATFORM=vpp TAG=vpp wipe-all install-packages
789         $(call banner,"Building sample-plugin")
790         @make -C build-root PLATFORM=vpp TAG=vpp sample-plugin-install
791         $(call banner,"Building libmemif")
792         @make -C build-root PLATFORM=vpp TAG=vpp libmemif-install
793         $(call banner,"Building $(PKG) packages")
794         @make pkg-$(PKG)
795
796 # Note: 'make verify' target is not used by ci-management scripts
797 MAKE_VERIFY_GATE_OS ?= ubuntu-22.04
798 .PHONY: verify
799 verify: pkg-verify
800 ifeq ($(OS_ID)-$(OS_VERSION_ID),$(MAKE_VERIFY_GATE_OS))
801         $(call banner,"Testing vppapigen")
802         @src/tools/vppapigen/test_vppapigen.py
803         $(call banner,"Running tests")
804         @make COMPRESS_FAILED_TEST_LOGS=yes RETRIES=3 test
805 else
806         $(call banner,"Skipping tests. Tests under 'make verify' supported on $(MAKE_VERIFY_GATE_OS)")
807 endif
808
809 .PHONY: check-dpdk-mlx
810 check-dpdk-mlx:
811         @[ $$(make -sC build/external dpdk-show-DPDK_MLX_DEFAULT) = y ]