blob: e49fe6b9ade2601ebcc2b5e5b3bcb1667c37c01e [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)')
Dave Wallaced1706812021-08-12 18:36:02 -040084PIP_VERSION=21.2.4
Aloys Augustinef29fa42020-05-25 18:07:24 +020085# Keep in sync with requirements.txt
Dave Wallaced1706812021-08-12 18:36:02 -040086PIP_TOOLS_VERSION=6.2.0
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$(FAILED_DIR): reset
198 @mkdir -p $@
199
200.PHONY: test-dep
Dave Wallaceeddd8e32021-05-12 21:43:59 -0400201test-dep: $(PAPI_INSTALL_DONE) $(FAILED_DIR)
Dave Wallacef0797d12019-11-15 17:29:15 -0500202
203.PHONY: test
Damjan Mariona2d6d352021-05-25 18:29:24 +0200204test: test-dep sanity
Juraj Sloboda0279b292016-11-16 19:50:24 +0100205 $(call retest-func)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200206
Dave Wallacef0797d12019-11-15 17:29:15 -0500207.PHONY: retest
208retest: verify-env sanity $(FAILED_DIR)
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: shell
212shell: test-dep
Klement Sekerab8c72a42018-11-08 11:21:39 +0100213 @echo "source $(VENV_PATH)/bin/activate;\
Paul Vinciguerrac701e572019-12-19 16:09:43 -0500214 export RND_SEED=$(RND_SEED);\
Klement Sekeraa86e2892017-03-09 08:01:52 +0100215 echo '***';\
Dave Wallacefd243742021-03-16 22:12:07 -0400216 echo PYTHONPATH=$(PYTHONPATH);\
Paul Vinciguerrac701e572019-12-19 16:09:43 -0500217 echo RND_SEED=$(RND_SEED);\
Klement Sekera593635d2019-02-07 19:56:50 +0100218 echo VPP_BUILD_DIR=$(VPP_BUILD_DIR);\
219 echo VPP_BIN=$(VPP_BIN);\
220 echo VPP_PLUGIN_PATH=$(VPP_PLUGIN_PATH);\
Dave Barach7d31ab22019-05-08 19:18:18 -0400221 echo VPP_TEST_PLUGIN_PATH=$(VPP_TEST_PLUGIN_PATH);\
Klement Sekera593635d2019-02-07 19:56:50 +0100222 echo VPP_INSTALL_PATH=$(VPP_INSTALL_PATH);\
Klement Sekera47e275b2017-03-21 08:21:25 +0100223 echo EXTERN_TESTS=$(EXTERN_TESTS);\
224 echo EXTERN_PLUGINS=$(EXTERN_PLUGINS);\
Klement Sekeracd6cb982017-05-11 06:55:32 +0200225 echo EXTERN_COV_DIR=$(EXTERN_COV_DIR);\
Klement Sekeraa86e2892017-03-09 08:01:52 +0100226 echo LD_LIBRARY_PATH=$(LD_LIBRARY_PATH);\
227 echo '***';\
228 exec </dev/tty" | bash -i
229
Dave Wallacef0797d12019-11-15 17:29:15 -0500230.PHONY: reset
Neale Ranns177bbdc2016-11-15 09:46:51 +0000231reset:
Klement Sekeraaa7a2a12021-03-18 15:22:57 +0100232 @rm -f /dev/shm/vpp-unittest-*
Klement Sekerae2636852021-03-16 12:52:12 +0100233 @if [ $(FORCE_NO_WIPE) -eq "0" ] ; then rm -rf /tmp/vpp-unittest-*; fi
Dave Wallacef0797d12019-11-15 17:29:15 -0500234 @rm -f /tmp/api_post_mortem.*
Klement Sekerab8c72a42018-11-08 11:21:39 +0100235 @rm -rf $(FAILED_DIR)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200236
Dave Wallacef0797d12019-11-15 17:29:15 -0500237.PHONY: wipe
Neale Ranns177bbdc2016-11-15 09:46:51 +0000238wipe: reset
Klement Sekerab8c72a42018-11-08 11:21:39 +0100239 @rm -rf $(VENV_PATH)
Neale Ranns02da9262021-01-08 08:43:14 +0000240 @rm -rf $(patsubst %,%/__pycache__, $(VPP_TEST_DIRS))
Neale Ranns177bbdc2016-11-15 09:46:51 +0000241
Aloys Augustin1f2e1462020-04-07 15:43:33 +0200242$(TEST_DOC_BR): $(PIP_INSTALL_DONE)
Dave Wallacef0797d12019-11-15 17:29:15 -0500243 @mkdir -p $@
Dave Wallacef0797d12019-11-15 17:29:15 -0500244 @bash -c "source $(VENV_PATH)/bin/activate && make -C doc html"
245
246.PHONY: doc
Dave Wallaceeddd8e32021-05-12 21:43:59 -0400247doc: $(PIP_PATCH_DONE) $(TEST_DOC_BR)
Dave Wallacef0797d12019-11-15 17:29:15 -0500248 @echo
249 @echo "Test Documentation URL: $(TEST_DOC_BR)/html/index.html"
250 @echo "Run 'make test-wipe-doc test-doc' to rebuild the test docs"
251 @echo
Klement Sekera277b89c2016-10-28 13:20:27 +0200252
Klement Sekera9f9d07b2016-12-12 09:20:50 +0100253.PHONY: wipe-doc
Klement Sekera277b89c2016-10-28 13:20:27 +0200254wipe-doc:
Dave Wallacef0797d12019-11-15 17:29:15 -0500255 @rm -rf $(TEST_DOC_BR)
Klement Sekera277b89c2016-10-28 13:20:27 +0200256
Dave Wallacef0797d12019-11-15 17:29:15 -0500257$(BUILD_COV_DIR):
258 @mkdir -p $@
259
260.PHONY: cov
261cov: wipe-cov test-dep ext $(BUILD_COV_DIR)
Klement Sekera593635d2019-02-07 19:56:50 +0100262 @lcov --zerocounters --directory $(VPP_BUILD_DIR)
Klement Sekeracd6cb982017-05-11 06:55:32 +0200263 @test -z "$(EXTERN_COV_DIR)" || lcov --zerocounters --directory $(EXTERN_COV_DIR)
Juraj Sloboda0279b292016-11-16 19:50:24 +0100264 $(call retest-func)
Klement Sekera593635d2019-02-07 19:56:50 +0100265 @lcov --capture --directory $(VPP_BUILD_DIR) --output-file $(BUILD_COV_DIR)/coverage.info
Klement Sekeracd6cb982017-05-11 06:55:32 +0200266 @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 +0100267 @genhtml $(BUILD_COV_DIR)/coverage.info --output-directory $(BUILD_COV_DIR)/html
Klement Sekeracd6cb982017-05-11 06:55:32 +0200268 @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 +0100269 @echo
270 @echo "Build finished. Code coverage report is in $(BUILD_COV_DIR)/html/index.html"
Klement Sekeracd6cb982017-05-11 06:55:32 +0200271 @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 +0100272
Klement Sekera9f9d07b2016-12-12 09:20:50 +0100273.PHONY: wipe-cov
Juraj Sloboda0279b292016-11-16 19:50:24 +0100274wipe-cov: wipe
275 @rm -rf $(BUILD_COV_DIR)
276
Dave Wallacef0797d12019-11-15 17:29:15 -0500277.PHONY: wipe-papi
278wipe-papi:
279 @rm -rf $(PAPI_INSTALL_DONE) $(PAPI_WIPE_DIST)
Paul Vinciguerra2648e442019-07-09 16:49:46 -0400280
Dave Wallacef0797d12019-11-15 17:29:15 -0500281.PHONY: wipe-all
282wipe-all: wipe wipe-papi wipe-doc wipe-cov
283 @rm -rf $(TEST_BR)
Paul Vinciguerra2648e442019-07-09 16:49:46 -0400284
Klement Sekerae0b63b22021-03-24 23:24:52 +0100285.PHONY: checkstyle-diff
Dave Wallaceeddd8e32021-05-12 21:43:59 -0400286checkstyle-diff: $(PIP_INSTALL_DONE)
Klement Sekerae0b63b22021-03-24 23:24:52 +0100287 @bash -c "source $(VENV_PATH)/bin/activate &&\
288 $(PYTHON_INTERP) -m pip install pycodestyle"
289 @bash -c "source $(VENV_PATH)/bin/activate &&\
290 cd $(WS_ROOT) && git diff --name-only --no-color --relative HEAD~1 ':!*.patch' | grep '.py$$' | xargs -n 1 -I XXX \
291 pycodestyle --show-source --ignore=W504,E126,E241,E226,E305,E704,E741,E722 -v XXX ||\
292 (echo \"*********************************************************************\" &&\
293 echo \"* Test framework PEP8 compliance check FAILED (checked changed files)\" &&\
294 echo \"*********************************************************************\" &&\
295 false)"
296 @echo "*********************************************************************"
297 @echo "* Test framework PEP8 compliance check passed (checked changed files)"
298 @echo "*********************************************************************"
299
Klement Sekerae2636852021-03-16 12:52:12 +0100300.PHONY: start-gdb
301start-gdb: sanity
302 $(eval VPP_IN_GDB=1)
303 $(eval FORCE_FOREGROUND=1)
304 $(call retest-func)
305
Klement Sekera72715ee2017-01-17 10:37:05 +0100306.PHONY: checkstyle
Dave Wallaceeddd8e32021-05-12 21:43:59 -0400307checkstyle: $(PIP_INSTALL_DONE)
Ole Troan4aacc012019-10-23 11:47:33 +0200308 @bash -c "source $(VENV_PATH)/bin/activate &&\
309 $(PYTHON_INTERP) -m pip install pycodestyle"
Klement Sekerab8c72a42018-11-08 11:21:39 +0100310 @bash -c "source $(VENV_PATH)/bin/activate &&\
Dave Wallaceeddd8e32021-05-12 21:43:59 -0400311 pycodestyle --show-source --ignore=W504,E126,E241,E226,E305,E704,E741,E722 -v *.py ||\
Klement Sekera72715ee2017-01-17 10:37:05 +0100312 (echo \"*******************************************************************\" &&\
Klement Sekerae0b63b22021-03-24 23:24:52 +0100313 echo \"* Test framework PEP8 compliance check FAILED (checked all files)\" &&\
Klement Sekera72715ee2017-01-17 10:37:05 +0100314 echo \"*******************************************************************\" &&\
315 false)"
316 @echo "*******************************************************************"
Klement Sekerae0b63b22021-03-24 23:24:52 +0100317 @echo "* Test framework PEP8 compliance check passed (checked all files)"
Klement Sekera72715ee2017-01-17 10:37:05 +0100318 @echo "*******************************************************************"
319
Dave Wallacef0797d12019-11-15 17:29:15 -0500320.PHONY: help
Klement Sekera277b89c2016-10-28 13:20:27 +0200321help:
322 @echo "Running tests:"
323 @echo ""
Dave Wallacef0797d12019-11-15 17:29:15 -0500324 @echo " test - build and run (basic) functional tests"
325 @echo " test-debug - build and run (basic) functional tests (debug build)"
326 @echo " test-all - build and run functional and extended tests"
327 @echo " test-all-debug - build and run functional and extended tests (debug build)"
328 @echo " retest - run functional tests"
329 @echo " retest-debug - run functional tests (debug build)"
330 @echo " retest-all - run functional and extended tests"
331 @echo " retest-all-debug - run functional and extended tests (debug build)"
332 @echo " test-cov - generate code coverage report for test framework"
333 @echo " test-gcov - build and run functional tests (gcov build)"
Dave Wallacef0797d12019-11-15 17:29:15 -0500334 @echo " test-wipe - wipe (temporary) files generated by unit tests"
335 @echo " test-wipe-cov - wipe code coverage report for test framework"
336 @echo " test-wipe-doc - wipe documentation for test framework"
337 @echo " test-wipe-papi - rebuild vpp_papi sources"
338 @echo " test-wipe-all - wipe (temporary) files generated by unit tests, docs, and coverage"
339 @echo " test-shell - enter shell with test environment"
340 @echo " test-shell-debug - enter shell with test environment (debug build)"
Klement Sekerae2636852021-03-16 12:52:12 +0100341 @echo " test-checkstyle - check PEP8 compliance for test framework"
342 @echo " test-refresh-deps - refresh the Python dependencies for the tests"
Klement Sekera277b89c2016-10-28 13:20:27 +0200343 @echo ""
344 @echo "Arguments controlling test runs:"
Dave Wallacef0797d12019-11-15 17:29:15 -0500345 @echo " V=[0|1|2] - set test verbosity level"
346 @echo " 0=ERROR, 1=INFO, 2=DEBUG"
Klement Sekera558ceab2021-04-08 19:37:41 +0200347 @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)"
348 @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 -0500349 @echo " CACHE_OUTPUT=[0|1] - cache VPP stdout/stderr and log as one block after test finishes (default: 1)"
350 @echo " FAILFAST=[0|1] - fail fast if 1, complete all tests if 0"
351 @echo " TIMEOUT=<timeout> - fail test suite if any single test takes longer than <timeout> (in seconds) to finish (default: 600)"
352 @echo " RETRIES=<n> - retry failed tests <n> times"
353 @echo " DEBUG=<type> - set VPP debugging kind"
354 @echo " DEBUG=core - detect coredump and load it in gdb on crash"
355 @echo " DEBUG=gdb - allow easy debugging by printing VPP PID"
356 @echo " and waiting for user input before running"
357 @echo " and tearing down a testcase"
358 @echo " DEBUG=gdbserver - run gdb inside a gdb server, otherwise"
359 @echo " same as above"
Klement Sekerae2636852021-03-16 12:52:12 +0100360 @echo " DEBUG=attach - attach test case to already running vpp in gdb (see test-start-vpp-in-gdb)"
361 @echo ""
Dave Wallacef0797d12019-11-15 17:29:15 -0500362 @echo " STEP=[yes|no] - ease debugging by stepping through a testcase"
363 @echo " SANITY=[yes|no] - perform sanity import of vpp-api/sanity vpp run before running tests (default: yes)"
364 @echo " EXTENDED_TESTS=[1|y] - used by '[re]test-all' & '[re]test-all-debug' to run extended tests"
365 @echo " TEST=<filter> - filter the set of tests:"
366 @echo " by file-name - only run tests from specified file, e.g. TEST=test_bfd selects all tests from test_bfd.py"
367 @echo " by file-suffix - same as file-name, but 'test_' is omitted e.g. TEST=bfd selects all tests from test_bfd.py"
368 @echo " by wildcard - wildcard filter is <file>.<class>.<test function>, each can be replaced by '*'"
369 @echo " e.g. TEST='test_bfd.*.*' is equivalent to above example of filter by file-name"
370 @echo " TEST='bfd.*.*' is equivalent to above example of filter by file-suffix"
371 @echo " TEST='bfd.BFDAPITestCase.*' selects all tests from test_bfd.py which are part of BFDAPITestCase class"
372 @echo " TEST='bfd.BFDAPITestCase.test_add_bfd' selects a single test named test_add_bfd from test_bfd.py/BFDAPITestCase"
373 @echo " TEST='*.*.test_add_bfd' selects all test functions named test_add_bfd from all files/classes"
Klement Sekera277b89c2016-10-28 13:20:27 +0200374 @echo ""
Ray Kinsella4830e4f2020-03-10 14:35:32 +0000375 @echo " VARIANT=<variant> - specify which march node variant to unit test"
Ray Kinsellaf9c8fe42020-08-14 15:27:10 +0100376 @echo " e.g. VARIANT=skx test the skx march variants"
377 @echo " e.g. VARIANT=icl test the icl march variants"
Ray Kinsella4830e4f2020-03-10 14:35:32 +0000378 @echo ""
Dave Wallacef0797d12019-11-15 17:29:15 -0500379 @echo " COREDUMP_SIZE=<size> - pass <size> as unix { coredump-size <size> } argument to vpp"
380 @echo " e.g. COREDUMP_SIZE=4g"
381 @echo " COREDUMP_SIZE=unlimited"
382 @echo " COREDUMP_COMPRESS=1 - compress core files if not debugging them"
383 @echo " EXTERN_TESTS=<path> - path to out-of-tree test_<name>.py files containing test cases"
384 @echo " EXTERN_PLUGINS=<path> - path to out-of-tree plugins to be loaded by vpp under test"
385 @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 +0100386 @echo ""
Dave Wallacef0797d12019-11-15 17:29:15 -0500387 @echo " PROFILE=1 - enable profiling of test framework via cProfile module"
388 @echo " PROFILE_SORT_BY=opt - sort profiling report by opt - consult cProfile documentation for possible values (default: cumtime)"
389 @echo " PROFILE_OUTPUT=file - output profiling info to file - use absolute path (default: stdout)"
Klement Sekerabbfa5fd2018-06-27 13:54:32 +0200390 @echo ""
Dave Wallacef0797d12019-11-15 17:29:15 -0500391 @echo " TEST_DEBUG=1 - turn on debugging of the test framework itself (expert)"
Klement Sekeraebbaf552018-02-17 13:41:33 +0100392 @echo ""
Dave Wallacef0797d12019-11-15 17:29:15 -0500393 @echo " SKIP_AARCH64=1 - skip tests that are failing on the ARM platorm in FD.io CI"
juraj.linkes68ebc832018-11-29 09:37:08 +0100394 @echo ""
Dave Wallacef0797d12019-11-15 17:29:15 -0500395 @echo " RND_SEED=seed - Seed RND with given seed"
Klement Sekera45a95dd2019-11-05 11:18:25 +0000396 @echo ""
Klement Sekerae2636852021-03-16 12:52:12 +0100397 @echo "Starting VPP in GDB for use with DEBUG=attach:"
398 @echo ""
399 @echo " test-start-vpp-in-gdb - start VPP in gdb (release)"
400 @echo " test-start-vpp-debug-in-gdb - start VPP in gdb (debug)"
401 @echo ""
402 @echo "Arguments controlling VPP in GDB runs:"
403 @echo " "
404 @echo " VPP_IN_GDB_TMP_DIR - specify directory to run VPP IN (default: /tmp/unittest-attach-gdb)"
405 @echo " VPP_IN_GDB_NO_RMDIR=0 - don't remove existing tmp dir but fail instead"
406 @echo " VPP_IN_GDB_CMDLINE=1 - add 'interactive' to VPP arguments to run with command line"
407 @echo ""
Klement Sekera277b89c2016-10-28 13:20:27 +0200408 @echo "Creating test documentation"
Dave Wallacef0797d12019-11-15 17:29:15 -0500409 @echo " test-doc - generate documentation for test framework"
410 @echo " test-wipe-doc - wipe documentation for test framework"
Juraj Sloboda0279b292016-11-16 19:50:24 +0100411 @echo ""
412 @echo "Creating test code coverage report"
Dave Wallacef0797d12019-11-15 17:29:15 -0500413 @echo " test-cov - generate code coverage report for test framework"
414 @echo " test-wipe-cov - wipe code coverage report for test framework"
Klement Sekera277b89c2016-10-28 13:20:27 +0200415 @echo ""
Klement Sekera72715ee2017-01-17 10:37:05 +0100416 @echo "Verifying code-style"
Dave Wallacef0797d12019-11-15 17:29:15 -0500417 @echo " test-checkstyle - check PEP8 compliance"
Klement Sekera72715ee2017-01-17 10:37:05 +0100418 @echo ""