blob: 82095883b55d04a40a48dc812b698b1ab719b4ea [file] [log] [blame]
BenoƮt Ganne9fb6d402019-04-15 15:28:21 +02001ASAN_OPTIONS?=verify_asan_link_order=0:detect_leaks=0:abort_on_error=1:unmap_shadow_on_exit=1:disable_coredump=0
2export ASAN_OPTIONS
3
Dave Wallacef0797d12019-11-15 17:29:15 -05004.PHONY: verify-env
5verify-env:
6ifndef WS_ROOT
7 $(error WS_ROOT is not set)
8endif
9ifndef BR
10 $(error BR is not set)
11endif
Klement Sekerab8c72a42018-11-08 11:21:39 +010012ifndef TEST_DIR
13 $(error TEST_DIR is not set)
Klement Sekera277b89c2016-10-28 13:20:27 +020014endif
15
Dave Wallaceeddd8e32021-05-12 21:43:59 -040016export TEST_BR = $(TEST_DIR)
17export TEST_DOC_BR = $(TEST_DIR)/doc/build
Dave Wallacef0797d12019-11-15 17:29:15 -050018FAILED_DIR=/tmp/vpp-failed-unittests/
Dave Wallaceeddd8e32021-05-12 21:43:59 -040019VPP_TEST_DIRS=$(shell ls -d $(TEST_DIR) $(EXTERN_TESTS))
Dave Wallacef0797d12019-11-15 17:29:15 -050020
Klement Sekerae2636852021-03-16 12:52:12 +010021FORCE_NO_WIPE=0
Klement Sekeradb4e84c2017-08-11 10:06:15 +020022ifeq ($(DEBUG),gdb)
23FORCE_FOREGROUND=1
24else ifeq ($(DEBUG),gdbserver)
25FORCE_FOREGROUND=1
Dave Wallace24564332019-10-21 02:53:14 +000026else ifeq ($(DEBUG),gdb-all)
27FORCE_FOREGROUND=1
28else ifeq ($(DEBUG),gdbserver-all)
29FORCE_FOREGROUND=1
Klement Sekerab90be672017-10-10 06:44:05 +020030else ifeq ($(DEBUG),core)
31FORCE_FOREGROUND=1
Klement Sekerae2636852021-03-16 12:52:12 +010032else ifeq ($(DEBUG),attach)
33FORCE_FOREGROUND=1
34FORCE_NO_WIPE=1
juraj.linkes184870a2018-07-16 14:22:01 +020035else ifeq ($(STEP),yes)
36FORCE_FOREGROUND=1
37else ifeq ($(STEP),y)
38FORCE_FOREGROUND=1
39else ifeq ($(STEP),1)
40FORCE_FOREGROUND=1
Klement Sekeradb4e84c2017-08-11 10:06:15 +020041else
42FORCE_FOREGROUND=0
43endif
44
Klement Sekerabbfa5fd2018-06-27 13:54:32 +020045ifdef PROFILE_OUTPUT
46PROFILE_OUTPUT_OPTS=-o $(PROFILE_OUTPUT)
47endif
48
49ifndef PROFILE_SORT_BY
50PROFILE_SORT_BY=cumtime
51endif
52
53ifeq ($(PROFILE),1)
54PYTHON_PROFILE_OPTS=-m cProfile $(PROFILE_OUTPUT_OPTS) -s $(PROFILE_SORT_BY)
55FORCE_FOREGROUND=1
56endif
57
Klement Sekera993e0ed2017-03-16 09:14:59 +010058UNITTEST_EXTRA_OPTS=
59UNITTEST_FAILFAST_OPTS=
Klement Sekeraacb9b8e2017-02-14 02:55:31 +010060
61ifeq ($(FAILFAST),1)
Klement Sekera993e0ed2017-03-16 09:14:59 +010062UNITTEST_EXTRA_OPTS=-f
63endif
64
65ifneq ($(EXTERN_TESTS),)
66UNITTEST_EXTRA_OPTS=$(UNITTEST_FAILFAST_OPTS) -d $(EXTERN_TESTS)
Klement Sekeraacb9b8e2017-02-14 02:55:31 +010067endif
68
Dave Wallaceeddd8e32021-05-12 21:43:59 -040069VENV_PATH=$(TEST_DIR)/venv
Klement Sekerab8c72a42018-11-08 11:21:39 +010070
Klement Sekeraebbaf552018-02-17 13:41:33 +010071ifeq ($(TEST_DEBUG),1)
Dave Wallacef0797d12019-11-15 17:29:15 -050072VENV_RUN_DIR:=$(VENV_PATH)/run-debug
Klement Sekeraebbaf552018-02-17 13:41:33 +010073else
Dave Wallacef0797d12019-11-15 17:29:15 -050074VENV_RUN_DIR:=$(VENV_PATH)/run
Klement Sekeraebbaf552018-02-17 13:41:33 +010075endif
76
vagrant937bf302017-04-07 01:48:47 +000077ifeq ($(PYTHON),)
Ole Troan6e6ad642020-02-04 13:28:13 +010078PYTHON_INTERP=python3
vagrant937bf302017-04-07 01:48:47 +000079else
80PYTHON_INTERP=$(PYTHON)
81endif
82
Aloys Augustin28fa8cb2019-06-21 17:04:29 +020083PYTHON_VERSION=$(shell $(PYTHON_INTERP) -c 'import sys; print(sys.version_info.major)')
Aloys Augustinef29fa42020-05-25 18:07:24 +020084PIP_VERSION=20.1.1
85# Keep in sync with requirements.txt
86PIP_TOOLS_VERSION=5.1.2
Aloys Augustin28fa8cb2019-06-21 17:04:29 +020087PYTHON_DEPENDS=requirements-$(PYTHON_VERSION).txt
Ole Troan6e6ad642020-02-04 13:28:13 +010088SCAPY_SOURCE=$(shell find $(VENV_PATH)/lib/python* -name site-packages)
Dave Wallacef0797d12019-11-15 17:29:15 -050089BUILD_COV_DIR=$(TEST_BR)/coverage
Aloys Augustin28fa8cb2019-06-21 17:04:29 +020090
Aloys Augustinef29fa42020-05-25 18:07:24 +020091PIP_TOOLS_INSTALL_DONE=$(VENV_RUN_DIR)/pip-tools-install-$(PYTHON_VERSION)-$(PIP_TOOLS_VERSION).done
92PIP_INSTALL_DONE=$(VENV_RUN_DIR)/pip-install-$(PYTHON_VERSION)-$(PIP_VERSION).done
Dave Wallacef0797d12019-11-15 17:29:15 -050093PIP_PATCH_DONE=$(VENV_RUN_DIR)/pip-patch-$(PYTHON_VERSION).done
94PAPI_INSTALL_DONE=$(VENV_RUN_DIR)/papi-install-$(PYTHON_VERSION).done
95PAPI_PYTHON_SRC_DIR=$(WS_ROOT)/src/vpp-api/python
96PAPI_WIPE_DIST=$(WS_ROOT)/src/vpp-api/vapi/__pycache__ \
97 $(PAPI_PYTHON_SRC_DIR)/build \
98 $(PAPI_PYTHON_SRC_DIR)/vpp_papi.egg-info \
99 $(PAPI_PYTHON_SRC_DIR)/vpp_papi/__pycache__
Aloys Augustin28fa8cb2019-06-21 17:04:29 +0200100
Aloys Augustin28fa8cb2019-06-21 17:04:29 +0200101$(PIP_TOOLS_INSTALL_DONE):
102 @rm -rf $(VENV_PATH)
Dave Wallacef0797d12019-11-15 17:29:15 -0500103 @mkdir -p $(VENV_RUN_DIR)
Klement Sekera7554aef2021-03-30 19:46:06 +0200104 @$(PYTHON_INTERP) -m venv $(VENV_PATH)
Aloys Augustin8adb92b2019-07-23 15:19:28 +0200105 # pip version pinning
106 @bash -c "source $(VENV_PATH)/bin/activate && \
107 $(PYTHON_INTERP) -m pip install pip===$(PIP_VERSION)"
Aloys Augustin28fa8cb2019-06-21 17:04:29 +0200108 @bash -c "source $(VENV_PATH)/bin/activate && \
109 $(PYTHON_INTERP) -m pip install pip-tools===$(PIP_TOOLS_VERSION)"
110 @touch $@
111
Aloys Augustin8eca60d2020-06-24 11:33:20 +0200112$(PYTHON_DEPENDS): requirements.txt
Aloys Augustin28fa8cb2019-06-21 17:04:29 +0200113 @bash -c "source $(VENV_PATH)/bin/activate && \
114 CUSTOM_COMPILE_COMMAND='make test-refresh-deps (or update requirements.txt)' \
115 $(PYTHON_INTERP) -m piptools compile -q --generate-hashes requirements.txt --output-file $@"
116
Aloys Augustin8eca60d2020-06-24 11:33:20 +0200117$(PIP_INSTALL_DONE): $(PIP_TOOLS_INSTALL_DONE) $(PYTHON_DEPENDS)
Aloys Augustin28fa8cb2019-06-21 17:04:29 +0200118 @bash -c "source $(VENV_PATH)/bin/activate && \
119 $(PYTHON_INTERP) -m piptools sync $(PYTHON_DEPENDS)"
Neale Ranns177bbdc2016-11-15 09:46:51 +0000120 @touch $@
121
Klement Sekera9f9d07b2016-12-12 09:20:50 +0100122$(PIP_PATCH_DONE): $(PIP_INSTALL_DONE)
Neale Ranns177bbdc2016-11-15 09:46:51 +0000123 @echo --- patching ---
Dave Wallace6f692d62017-01-26 21:07:10 -0500124 @sleep 1 # Ensure python recompiles patched *.py files -> *.pyc
snaramre5d4b8912019-12-13 23:39:35 +0000125 for f in $(CURDIR)/patches/scapy-2.4.3/*.patch ; do \
Neale Ranns177bbdc2016-11-15 09:46:51 +0000126 echo Applying patch: $$(basename $$f) ; \
Aloys Augustin28fa8cb2019-06-21 17:04:29 +0200127 patch --forward -p1 -d $(SCAPY_SOURCE) < $$f ; \
128 retCode=$$?; \
Aloys Augustin8eca60d2020-06-24 11:33:20 +0200129 [ $$retCode -gt 1 ] && exit $$retCode; \
Aloys Augustin28fa8cb2019-06-21 17:04:29 +0200130 done; \
131 touch $@
Neale Ranns177bbdc2016-11-15 09:46:51 +0000132
Klement Sekera9f9d07b2016-12-12 09:20:50 +0100133$(PAPI_INSTALL_DONE): $(PIP_PATCH_DONE)
Dave Wallacef0797d12019-11-15 17:29:15 -0500134 @bash -c "source $(VENV_PATH)/bin/activate && $(PYTHON_INTERP) -m pip install -e $(PAPI_PYTHON_SRC_DIR)"
Neale Ranns177bbdc2016-11-15 09:46:51 +0000135 @touch $@
136
Dave Wallacef0797d12019-11-15 17:29:15 -0500137.PHONY: refresh-deps
Aloys Augustin28fa8cb2019-06-21 17:04:29 +0200138refresh-deps: clean-deps $(PYTHON_DEPENDS)
139
Dave Wallacef0797d12019-11-15 17:29:15 -0500140.PHONY: clean-deps
Aloys Augustin28fa8cb2019-06-21 17:04:29 +0200141clean-deps:
142 @rm -f $(PYTHON_DEPENDS)
143
Dave Wallacef0797d12019-11-15 17:29:15 -0500144INTERN_PLUGIN_SRC_DIR=$(WS_ROOT)/src/plugins
Dave Wallacea43c93f2019-08-22 00:32:29 +0000145ifneq ($(EXTERN_PLUGIN_SRC_DIR),)
146PLUGIN_SRC_DIR=$(EXTERN_PLUGIN_SRC_DIR)
147else
Dave Wallacef0797d12019-11-15 17:29:15 -0500148PLUGIN_SRC_DIR=$(INTERN_PLUGIN_SRC_DIR)
Dave Wallacea43c93f2019-08-22 00:32:29 +0000149endif
Dave Wallacea43c93f2019-08-22 00:32:29 +0000150
Juraj Sloboda0279b292016-11-16 19:50:24 +0100151define retest-func
Dave Wallaceeddd8e32021-05-12 21:43:59 -0400152@env VPP_IN_GDB=$(VPP_IN_GDB) FORCE_FOREGROUND=$(FORCE_FOREGROUND) FAILED_DIR=$(FAILED_DIR) VENV_PATH=$(VENV_PATH) scripts/setsid_wrapper.sh $(FORCE_FOREGROUND) $(VENV_PATH)/bin/activate $(PYTHON_INTERP) $(PYTHON_PROFILE_OPTS) run_tests.py -d $(TEST_DIR) $(UNITTEST_EXTRA_OPTS) || env FAILED_DIR=$(FAILED_DIR) COMPRESS_FAILED_TEST_LOGS=$(COMPRESS_FAILED_TEST_LOGS) scripts/compress_failed.sh
Juraj Sloboda0279b292016-11-16 19:50:24 +0100153endef
154
Klement Sekerac160ae02017-03-09 08:20:13 +0100155.PHONY: sanity
156
Klement Sekera41a9e512017-10-17 07:59:31 +0200157ifeq ($(SANITY),no)
158SANITY_IMPORT_VPP_PAPI_CMD=true
159SANITY_RUN_VPP_CMD=true
160else
Dave Wallaceeddd8e32021-05-12 21:43:59 -0400161SANITY_IMPORT_VPP_PAPI_CMD=source $(VENV_PATH)/bin/activate && $(PYTHON_INTERP) sanity_import_vpp_papi.py
162SANITY_RUN_VPP_CMD=source $(VENV_PATH)/bin/activate && $(PYTHON_INTERP) sanity_run_vpp.py
Klement Sekera41a9e512017-10-17 07:59:31 +0200163endif
164
juraj.linkes184870a2018-07-16 14:22:01 +0200165ifndef TEST_JOBS
166PARALLEL_ILLEGAL=0
167else ifeq ($(FORCE_FOREGROUND),0)
168PARALLEL_ILLEGAL=0
169else ifeq ($(TEST_JOBS),auto)
170PARALLEL_ILLEGAL=0
171else ifeq ($(TEST_JOBS),1)
172PARALLEL_ILLEGAL=0
173else
174PARALLEL_ILLEGAL=1
175endif
176
Klement Sekerae2636852021-03-16 12:52:12 +0100177sanity: test-dep
juraj.linkes184870a2018-07-16 14:22:01 +0200178 @bash -c "test $(PARALLEL_ILLEGAL) -eq 0 ||\
179 (echo \"*******************************************************************\" &&\
180 echo \"* Sanity check failed, TEST_JOBS is not 1 or 'auto' and DEBUG, STEP or PROFILE is set\" &&\
181 echo \"*******************************************************************\" &&\
182 false)"
Klement Sekera41a9e512017-10-17 07:59:31 +0200183 @bash -c "$(SANITY_IMPORT_VPP_PAPI_CMD) ||\
Klement Sekerac160ae02017-03-09 08:20:13 +0100184 (echo \"*******************************************************************\" &&\
185 echo \"* Sanity check failed, cannot import vpp_papi\" &&\
186 echo \"* to debug: \" &&\
187 echo \"* 1. enter test shell: make test-shell\" &&\
188 echo \"* 2. execute debugger: gdb python -ex 'run sanity_import_vpp_papi.py'\" &&\
189 echo \"*******************************************************************\" &&\
190 false)"
Klement Sekera41a9e512017-10-17 07:59:31 +0200191 @bash -c "$(SANITY_RUN_VPP_CMD) ||\
Klement Sekera3747c752017-04-10 06:30:17 +0200192 (echo \"*******************************************************************\" &&\
193 echo \"* Sanity check failed, cannot run vpp\" &&\
194 echo \"*******************************************************************\" &&\
195 false)"
Klement Sekerac160ae02017-03-09 08:20:13 +0100196
Dave Wallacef0797d12019-11-15 17:29:15 -0500197.PHONY: ext-test-apps
198ext-test-apps:
199 make -C ext test-apps
Klement Sekera8f2a4ea2017-05-04 06:15:18 +0200200
Dave Wallacef0797d12019-11-15 17:29:15 -0500201$(FAILED_DIR): reset
202 @mkdir -p $@
203
204.PHONY: test-dep
Dave Wallaceeddd8e32021-05-12 21:43:59 -0400205test-dep: $(PAPI_INSTALL_DONE) $(FAILED_DIR)
Dave Wallacef0797d12019-11-15 17:29:15 -0500206
207.PHONY: test
208test: test-dep ext-test-apps sanity
Juraj Sloboda0279b292016-11-16 19:50:24 +0100209 $(call retest-func)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200210
Dave Wallacef0797d12019-11-15 17:29:15 -0500211.PHONY: retest
212retest: verify-env sanity $(FAILED_DIR)
Juraj Sloboda0279b292016-11-16 19:50:24 +0100213 $(call retest-func)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200214
Dave Wallacef0797d12019-11-15 17:29:15 -0500215.PHONY: shell
216shell: test-dep
Klement Sekerab8c72a42018-11-08 11:21:39 +0100217 @echo "source $(VENV_PATH)/bin/activate;\
Paul Vinciguerrac701e572019-12-19 16:09:43 -0500218 export RND_SEED=$(RND_SEED);\
Klement Sekeraa86e2892017-03-09 08:01:52 +0100219 echo '***';\
Dave Wallacefd243742021-03-16 22:12:07 -0400220 echo PYTHONPATH=$(PYTHONPATH);\
Paul Vinciguerrac701e572019-12-19 16:09:43 -0500221 echo RND_SEED=$(RND_SEED);\
Klement Sekera593635d2019-02-07 19:56:50 +0100222 echo VPP_BUILD_DIR=$(VPP_BUILD_DIR);\
223 echo VPP_BIN=$(VPP_BIN);\
224 echo VPP_PLUGIN_PATH=$(VPP_PLUGIN_PATH);\
Dave Barach7d31ab22019-05-08 19:18:18 -0400225 echo VPP_TEST_PLUGIN_PATH=$(VPP_TEST_PLUGIN_PATH);\
Klement Sekera593635d2019-02-07 19:56:50 +0100226 echo VPP_INSTALL_PATH=$(VPP_INSTALL_PATH);\
Klement Sekera47e275b2017-03-21 08:21:25 +0100227 echo EXTERN_TESTS=$(EXTERN_TESTS);\
228 echo EXTERN_PLUGINS=$(EXTERN_PLUGINS);\
Klement Sekeracd6cb982017-05-11 06:55:32 +0200229 echo EXTERN_COV_DIR=$(EXTERN_COV_DIR);\
Klement Sekeraa86e2892017-03-09 08:01:52 +0100230 echo LD_LIBRARY_PATH=$(LD_LIBRARY_PATH);\
231 echo '***';\
232 exec </dev/tty" | bash -i
233
Dave Wallacef0797d12019-11-15 17:29:15 -0500234.PHONY: reset
Neale Ranns177bbdc2016-11-15 09:46:51 +0000235reset:
Klement Sekeraaa7a2a12021-03-18 15:22:57 +0100236 @rm -f /dev/shm/vpp-unittest-*
Klement Sekerae2636852021-03-16 12:52:12 +0100237 @if [ $(FORCE_NO_WIPE) -eq "0" ] ; then rm -rf /tmp/vpp-unittest-*; fi
Dave Wallacef0797d12019-11-15 17:29:15 -0500238 @rm -f /tmp/api_post_mortem.*
Klement Sekerab8c72a42018-11-08 11:21:39 +0100239 @rm -rf $(FAILED_DIR)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200240
Dave Wallacef0797d12019-11-15 17:29:15 -0500241.PHONY: wipe
Neale Ranns177bbdc2016-11-15 09:46:51 +0000242wipe: reset
Klement Sekeraa61d1252017-09-27 06:48:44 +0200243 @make -C ext clean
Klement Sekerab8c72a42018-11-08 11:21:39 +0100244 @rm -rf $(VENV_PATH)
Neale Ranns02da9262021-01-08 08:43:14 +0000245 @rm -rf $(patsubst %,%/__pycache__, $(VPP_TEST_DIRS))
Neale Ranns177bbdc2016-11-15 09:46:51 +0000246
Aloys Augustin1f2e1462020-04-07 15:43:33 +0200247$(TEST_DOC_BR): $(PIP_INSTALL_DONE)
Dave Wallacef0797d12019-11-15 17:29:15 -0500248 @mkdir -p $@
Dave Wallacef0797d12019-11-15 17:29:15 -0500249 @bash -c "source $(VENV_PATH)/bin/activate && make -C doc html"
250
251.PHONY: doc
Dave Wallaceeddd8e32021-05-12 21:43:59 -0400252doc: $(PIP_PATCH_DONE) $(TEST_DOC_BR)
Dave Wallacef0797d12019-11-15 17:29:15 -0500253 @echo
254 @echo "Test Documentation URL: $(TEST_DOC_BR)/html/index.html"
255 @echo "Run 'make test-wipe-doc test-doc' to rebuild the test docs"
256 @echo
Klement Sekera277b89c2016-10-28 13:20:27 +0200257
Klement Sekera9f9d07b2016-12-12 09:20:50 +0100258.PHONY: wipe-doc
Klement Sekera277b89c2016-10-28 13:20:27 +0200259wipe-doc:
Dave Wallacef0797d12019-11-15 17:29:15 -0500260 @rm -rf $(TEST_DOC_BR)
Klement Sekera277b89c2016-10-28 13:20:27 +0200261
Dave Wallacef0797d12019-11-15 17:29:15 -0500262$(BUILD_COV_DIR):
263 @mkdir -p $@
264
265.PHONY: cov
266cov: wipe-cov test-dep ext $(BUILD_COV_DIR)
Klement Sekera593635d2019-02-07 19:56:50 +0100267 @lcov --zerocounters --directory $(VPP_BUILD_DIR)
Klement Sekeracd6cb982017-05-11 06:55:32 +0200268 @test -z "$(EXTERN_COV_DIR)" || lcov --zerocounters --directory $(EXTERN_COV_DIR)
Juraj Sloboda0279b292016-11-16 19:50:24 +0100269 $(call retest-func)
Klement Sekera593635d2019-02-07 19:56:50 +0100270 @lcov --capture --directory $(VPP_BUILD_DIR) --output-file $(BUILD_COV_DIR)/coverage.info
Klement Sekeracd6cb982017-05-11 06:55:32 +0200271 @test -z "$(EXTERN_COV_DIR)" || lcov --capture --directory $(EXTERN_COV_DIR) --output-file $(BUILD_COV_DIR)/extern-coverage.info
Juraj Sloboda0279b292016-11-16 19:50:24 +0100272 @genhtml $(BUILD_COV_DIR)/coverage.info --output-directory $(BUILD_COV_DIR)/html
Klement Sekeracd6cb982017-05-11 06:55:32 +0200273 @test -z "$(EXTERN_COV_DIR)" || genhtml $(BUILD_COV_DIR)/extern-coverage.info --output-directory $(BUILD_COV_DIR)/extern-html
Juraj Sloboda0279b292016-11-16 19:50:24 +0100274 @echo
275 @echo "Build finished. Code coverage report is in $(BUILD_COV_DIR)/html/index.html"
Klement Sekeracd6cb982017-05-11 06:55:32 +0200276 @test -z "$(EXTERN_COV_DIR)" || echo "Code coverage report for out-of-tree objects is in $(BUILD_COV_DIR)/extern-html/index.html"
Juraj Sloboda0279b292016-11-16 19:50:24 +0100277
Klement Sekera9f9d07b2016-12-12 09:20:50 +0100278.PHONY: wipe-cov
Juraj Sloboda0279b292016-11-16 19:50:24 +0100279wipe-cov: wipe
280 @rm -rf $(BUILD_COV_DIR)
281
Dave Wallacef0797d12019-11-15 17:29:15 -0500282.PHONY: wipe-papi
283wipe-papi:
284 @rm -rf $(PAPI_INSTALL_DONE) $(PAPI_WIPE_DIST)
Paul Vinciguerra2648e442019-07-09 16:49:46 -0400285
Dave Wallacef0797d12019-11-15 17:29:15 -0500286.PHONY: wipe-all
287wipe-all: wipe wipe-papi wipe-doc wipe-cov
288 @rm -rf $(TEST_BR)
Paul Vinciguerra2648e442019-07-09 16:49:46 -0400289
Klement Sekerae0b63b22021-03-24 23:24:52 +0100290.PHONY: checkstyle-diff
Dave Wallaceeddd8e32021-05-12 21:43:59 -0400291checkstyle-diff: $(PIP_INSTALL_DONE)
Klement Sekerae0b63b22021-03-24 23:24:52 +0100292 @bash -c "source $(VENV_PATH)/bin/activate &&\
293 $(PYTHON_INTERP) -m pip install pycodestyle"
294 @bash -c "source $(VENV_PATH)/bin/activate &&\
295 cd $(WS_ROOT) && git diff --name-only --no-color --relative HEAD~1 ':!*.patch' | grep '.py$$' | xargs -n 1 -I XXX \
296 pycodestyle --show-source --ignore=W504,E126,E241,E226,E305,E704,E741,E722 -v XXX ||\
297 (echo \"*********************************************************************\" &&\
298 echo \"* Test framework PEP8 compliance check FAILED (checked changed files)\" &&\
299 echo \"*********************************************************************\" &&\
300 false)"
301 @echo "*********************************************************************"
302 @echo "* Test framework PEP8 compliance check passed (checked changed files)"
303 @echo "*********************************************************************"
304
Klement Sekerae2636852021-03-16 12:52:12 +0100305.PHONY: start-gdb
306start-gdb: sanity
307 $(eval VPP_IN_GDB=1)
308 $(eval FORCE_FOREGROUND=1)
309 $(call retest-func)
310
Klement Sekera72715ee2017-01-17 10:37:05 +0100311.PHONY: checkstyle
Dave Wallaceeddd8e32021-05-12 21:43:59 -0400312checkstyle: $(PIP_INSTALL_DONE)
Ole Troan4aacc012019-10-23 11:47:33 +0200313 @bash -c "source $(VENV_PATH)/bin/activate &&\
314 $(PYTHON_INTERP) -m pip install pycodestyle"
Klement Sekerab8c72a42018-11-08 11:21:39 +0100315 @bash -c "source $(VENV_PATH)/bin/activate &&\
Dave Wallaceeddd8e32021-05-12 21:43:59 -0400316 pycodestyle --show-source --ignore=W504,E126,E241,E226,E305,E704,E741,E722 -v *.py ||\
Klement Sekera72715ee2017-01-17 10:37:05 +0100317 (echo \"*******************************************************************\" &&\
Klement Sekerae0b63b22021-03-24 23:24:52 +0100318 echo \"* Test framework PEP8 compliance check FAILED (checked all files)\" &&\
Klement Sekera72715ee2017-01-17 10:37:05 +0100319 echo \"*******************************************************************\" &&\
320 false)"
321 @echo "*******************************************************************"
Klement Sekerae0b63b22021-03-24 23:24:52 +0100322 @echo "* Test framework PEP8 compliance check passed (checked all files)"
Klement Sekera72715ee2017-01-17 10:37:05 +0100323 @echo "*******************************************************************"
324
Dave Wallacef0797d12019-11-15 17:29:15 -0500325.PHONY: help
Klement Sekera277b89c2016-10-28 13:20:27 +0200326help:
327 @echo "Running tests:"
328 @echo ""
Dave Wallacef0797d12019-11-15 17:29:15 -0500329 @echo " test - build and run (basic) functional tests"
330 @echo " test-debug - build and run (basic) functional tests (debug build)"
331 @echo " test-all - build and run functional and extended tests"
332 @echo " test-all-debug - build and run functional and extended tests (debug build)"
333 @echo " retest - run functional tests"
334 @echo " retest-debug - run functional tests (debug build)"
335 @echo " retest-all - run functional and extended tests"
336 @echo " retest-all-debug - run functional and extended tests (debug build)"
337 @echo " test-cov - generate code coverage report for test framework"
338 @echo " test-gcov - build and run functional tests (gcov build)"
Dave Wallacef0797d12019-11-15 17:29:15 -0500339 @echo " test-wipe - wipe (temporary) files generated by unit tests"
340 @echo " test-wipe-cov - wipe code coverage report for test framework"
341 @echo " test-wipe-doc - wipe documentation for test framework"
342 @echo " test-wipe-papi - rebuild vpp_papi sources"
343 @echo " test-wipe-all - wipe (temporary) files generated by unit tests, docs, and coverage"
344 @echo " test-shell - enter shell with test environment"
345 @echo " test-shell-debug - enter shell with test environment (debug build)"
Klement Sekerae2636852021-03-16 12:52:12 +0100346 @echo " test-checkstyle - check PEP8 compliance for test framework"
347 @echo " test-refresh-deps - refresh the Python dependencies for the tests"
Klement Sekera277b89c2016-10-28 13:20:27 +0200348 @echo ""
349 @echo "Arguments controlling test runs:"
Dave Wallacef0797d12019-11-15 17:29:15 -0500350 @echo " V=[0|1|2] - set test verbosity level"
351 @echo " 0=ERROR, 1=INFO, 2=DEBUG"
Klement Sekera558ceab2021-04-08 19:37:41 +0200352 @echo " TEST_JOBS=[<n>|auto] - use at most <n> parallel python processes for test execution, if auto, set to number of available cpus (default: 1)"
353 @echo " MAX_VPP_CPUS=[<n>|auto]- use at most <n> cpus for running vpp main and worker threads, if auto, set to number of available cpus (default: auto)"
Dave Wallacef0797d12019-11-15 17:29:15 -0500354 @echo " CACHE_OUTPUT=[0|1] - cache VPP stdout/stderr and log as one block after test finishes (default: 1)"
355 @echo " FAILFAST=[0|1] - fail fast if 1, complete all tests if 0"
356 @echo " TIMEOUT=<timeout> - fail test suite if any single test takes longer than <timeout> (in seconds) to finish (default: 600)"
357 @echo " RETRIES=<n> - retry failed tests <n> times"
358 @echo " DEBUG=<type> - set VPP debugging kind"
359 @echo " DEBUG=core - detect coredump and load it in gdb on crash"
360 @echo " DEBUG=gdb - allow easy debugging by printing VPP PID"
361 @echo " and waiting for user input before running"
362 @echo " and tearing down a testcase"
363 @echo " DEBUG=gdbserver - run gdb inside a gdb server, otherwise"
364 @echo " same as above"
Klement Sekerae2636852021-03-16 12:52:12 +0100365 @echo " DEBUG=attach - attach test case to already running vpp in gdb (see test-start-vpp-in-gdb)"
366 @echo ""
Dave Wallacef0797d12019-11-15 17:29:15 -0500367 @echo " STEP=[yes|no] - ease debugging by stepping through a testcase"
368 @echo " SANITY=[yes|no] - perform sanity import of vpp-api/sanity vpp run before running tests (default: yes)"
369 @echo " EXTENDED_TESTS=[1|y] - used by '[re]test-all' & '[re]test-all-debug' to run extended tests"
370 @echo " TEST=<filter> - filter the set of tests:"
371 @echo " by file-name - only run tests from specified file, e.g. TEST=test_bfd selects all tests from test_bfd.py"
372 @echo " by file-suffix - same as file-name, but 'test_' is omitted e.g. TEST=bfd selects all tests from test_bfd.py"
373 @echo " by wildcard - wildcard filter is <file>.<class>.<test function>, each can be replaced by '*'"
374 @echo " e.g. TEST='test_bfd.*.*' is equivalent to above example of filter by file-name"
375 @echo " TEST='bfd.*.*' is equivalent to above example of filter by file-suffix"
376 @echo " TEST='bfd.BFDAPITestCase.*' selects all tests from test_bfd.py which are part of BFDAPITestCase class"
377 @echo " TEST='bfd.BFDAPITestCase.test_add_bfd' selects a single test named test_add_bfd from test_bfd.py/BFDAPITestCase"
378 @echo " TEST='*.*.test_add_bfd' selects all test functions named test_add_bfd from all files/classes"
Klement Sekera277b89c2016-10-28 13:20:27 +0200379 @echo ""
Ray Kinsella4830e4f2020-03-10 14:35:32 +0000380 @echo " VARIANT=<variant> - specify which march node variant to unit test"
Ray Kinsellaf9c8fe42020-08-14 15:27:10 +0100381 @echo " e.g. VARIANT=skx test the skx march variants"
382 @echo " e.g. VARIANT=icl test the icl march variants"
Ray Kinsella4830e4f2020-03-10 14:35:32 +0000383 @echo ""
Dave Wallacef0797d12019-11-15 17:29:15 -0500384 @echo " COREDUMP_SIZE=<size> - pass <size> as unix { coredump-size <size> } argument to vpp"
385 @echo " e.g. COREDUMP_SIZE=4g"
386 @echo " COREDUMP_SIZE=unlimited"
387 @echo " COREDUMP_COMPRESS=1 - compress core files if not debugging them"
388 @echo " EXTERN_TESTS=<path> - path to out-of-tree test_<name>.py files containing test cases"
389 @echo " EXTERN_PLUGINS=<path> - path to out-of-tree plugins to be loaded by vpp under test"
390 @echo " EXTERN_COV_DIR=<path> - path to out-of-tree prefix, where source, object and .gcda files can be found for coverage report"
Klement Sekerab93d1422017-03-02 08:16:20 +0100391 @echo ""
Dave Wallacef0797d12019-11-15 17:29:15 -0500392 @echo " PROFILE=1 - enable profiling of test framework via cProfile module"
393 @echo " PROFILE_SORT_BY=opt - sort profiling report by opt - consult cProfile documentation for possible values (default: cumtime)"
394 @echo " PROFILE_OUTPUT=file - output profiling info to file - use absolute path (default: stdout)"
Klement Sekerabbfa5fd2018-06-27 13:54:32 +0200395 @echo ""
Dave Wallacef0797d12019-11-15 17:29:15 -0500396 @echo " TEST_DEBUG=1 - turn on debugging of the test framework itself (expert)"
Klement Sekeraebbaf552018-02-17 13:41:33 +0100397 @echo ""
Dave Wallacef0797d12019-11-15 17:29:15 -0500398 @echo " SKIP_AARCH64=1 - skip tests that are failing on the ARM platorm in FD.io CI"
juraj.linkes68ebc832018-11-29 09:37:08 +0100399 @echo ""
Dave Wallacef0797d12019-11-15 17:29:15 -0500400 @echo " RND_SEED=seed - Seed RND with given seed"
Klement Sekera45a95dd2019-11-05 11:18:25 +0000401 @echo ""
Klement Sekerae2636852021-03-16 12:52:12 +0100402 @echo "Starting VPP in GDB for use with DEBUG=attach:"
403 @echo ""
404 @echo " test-start-vpp-in-gdb - start VPP in gdb (release)"
405 @echo " test-start-vpp-debug-in-gdb - start VPP in gdb (debug)"
406 @echo ""
407 @echo "Arguments controlling VPP in GDB runs:"
408 @echo " "
409 @echo " VPP_IN_GDB_TMP_DIR - specify directory to run VPP IN (default: /tmp/unittest-attach-gdb)"
410 @echo " VPP_IN_GDB_NO_RMDIR=0 - don't remove existing tmp dir but fail instead"
411 @echo " VPP_IN_GDB_CMDLINE=1 - add 'interactive' to VPP arguments to run with command line"
412 @echo ""
Klement Sekera277b89c2016-10-28 13:20:27 +0200413 @echo "Creating test documentation"
Dave Wallacef0797d12019-11-15 17:29:15 -0500414 @echo " test-doc - generate documentation for test framework"
415 @echo " test-wipe-doc - wipe documentation for test framework"
Juraj Sloboda0279b292016-11-16 19:50:24 +0100416 @echo ""
417 @echo "Creating test code coverage report"
Dave Wallacef0797d12019-11-15 17:29:15 -0500418 @echo " test-cov - generate code coverage report for test framework"
419 @echo " test-wipe-cov - wipe code coverage report for test framework"
Klement Sekera277b89c2016-10-28 13:20:27 +0200420 @echo ""
Klement Sekera72715ee2017-01-17 10:37:05 +0100421 @echo "Verifying code-style"
Dave Wallacef0797d12019-11-15 17:29:15 -0500422 @echo " test-checkstyle - check PEP8 compliance"
Klement Sekera72715ee2017-01-17 10:37:05 +0100423 @echo ""