X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2FMakefile;h=3a78a3f08af059ee7ce1476d10e477aa866bb3ff;hb=320998a8126766c0db92d9c7652f765f9565a7b5;hp=8c06516f9911bd610fba1667f63fd02c14ac4530;hpb=7d31ab2a5cc2124ddd973ac5dfac2219619f345a;p=vpp.git diff --git a/test/Makefile b/test/Makefile index 8c06516f991..3a78a3f08af 100644 --- a/test/Makefile +++ b/test/Makefile @@ -19,6 +19,10 @@ ifeq ($(DEBUG),gdb) FORCE_FOREGROUND=1 else ifeq ($(DEBUG),gdbserver) FORCE_FOREGROUND=1 +else ifeq ($(DEBUG),gdb-all) +FORCE_FOREGROUND=1 +else ifeq ($(DEBUG),gdbserver-all) +FORCE_FOREGROUND=1 else ifeq ($(DEBUG),core) FORCE_FOREGROUND=1 else ifeq ($(STEP),yes) @@ -69,32 +73,49 @@ VENV_PATH=$(TEST_DIR)/run/venv ifeq ($(TEST_DEBUG),1) TEST_RUN_DIR:=$(VENV_PATH)/run-debug -PYTHON_EXTRA_DEPENDS=objgraph pympler else TEST_RUN_DIR:=$(VENV_PATH)/run -PYTHON_EXTRA_DEPENDS= endif -PYTHON_DEPENDS=$(PYTHON_EXTRA_DEPENDS) -r requirements.txt -SCAPY_SOURCE=$(shell find $(VENV_PATH)/lib/$(PYTHON) -name site-packages) -BUILD_COV_DIR=$(TEST_DIR)/coverage - -PIP_INSTALL_DONE=$(TEST_RUN_DIR)/pip-install.done -PIP_PATCH_DONE=$(TEST_RUN_DIR)/pip-patch.done -PAPI_INSTALL_DONE=$(TEST_RUN_DIR)/papi-install.done - -PAPI_INSTALL_FLAGS=$(PIP_INSTALL_DONE) $(PIP_PATCH_DONE) $(PAPI_INSTALL_DONE) - ifeq ($(PYTHON),) -PYTHON_INTERP=python2.7 +PYTHON_INTERP=python3.6 else PYTHON_INTERP=$(PYTHON) endif -$(PIP_INSTALL_DONE): +PYTHON_VERSION=$(shell $(PYTHON_INTERP) -c 'import sys; print(sys.version_info.major)') +PIP_VERSION=19.1.1 +PIP_TOOLS_VERSION=3.8.0 # Keep in sync with requirements.txt +PYTHON_DEPENDS=requirements-$(PYTHON_VERSION).txt +SCAPY_SOURCE=$(shell find $(VENV_PATH)/lib/$(PYTHON_INTERP) -name site-packages) +BUILD_COV_DIR=$(TEST_DIR)/coverage + +PIP_TOOLS_INSTALL_DONE=$(TEST_RUN_DIR)/pip-tools-install-$(PYTHON_VERSION).done +PIP_INSTALL_DONE=$(TEST_RUN_DIR)/pip-install-$(PYTHON_VERSION).done +PIP_PATCH_DONE=$(TEST_RUN_DIR)/pip-patch-$(PYTHON_VERSION).done +PAPI_INSTALL_DONE=$(TEST_RUN_DIR)/papi-install-$(PYTHON_VERSION).done + +PAPI_INSTALL_FLAGS=$(PIP_INSTALL_DONE) $(PIP_PATCH_DONE) $(PAPI_INSTALL_DONE) + +$(PIP_TOOLS_INSTALL_DONE): + @rm -rf $(VENV_PATH) @mkdir -p $(TEST_RUN_DIR) @virtualenv $(VENV_PATH) -p $(PYTHON_INTERP) - @bash -c "source $(VENV_PATH)/bin/activate && $(PYTHON_INTERP) -m pip install $(PYTHON_DEPENDS)" + # pip version pinning + @bash -c "source $(VENV_PATH)/bin/activate && \ + $(PYTHON_INTERP) -m pip install pip===$(PIP_VERSION)" + @bash -c "source $(VENV_PATH)/bin/activate && \ + $(PYTHON_INTERP) -m pip install pip-tools===$(PIP_TOOLS_VERSION)" + @touch $@ + +$(PYTHON_DEPENDS): $(PIP_TOOLS_INSTALL_DONE) requirements.txt + @bash -c "source $(VENV_PATH)/bin/activate && \ + CUSTOM_COMPILE_COMMAND='make test-refresh-deps (or update requirements.txt)' \ + $(PYTHON_INTERP) -m piptools compile -q --generate-hashes requirements.txt --output-file $@" + +$(PIP_INSTALL_DONE): $(PYTHON_DEPENDS) + @bash -c "source $(VENV_PATH)/bin/activate && \ + $(PYTHON_INTERP) -m piptools sync $(PYTHON_DEPENDS)" @touch $@ $(PIP_PATCH_DONE): $(PIP_INSTALL_DONE) @@ -102,16 +123,31 @@ $(PIP_PATCH_DONE): $(PIP_INSTALL_DONE) @sleep 1 # Ensure python recompiles patched *.py files -> *.pyc for f in $(CURDIR)/patches/scapy-2.4/*.patch ; do \ echo Applying patch: $$(basename $$f) ; \ - patch -p1 -d $(SCAPY_SOURCE) < $$f ; \ - done - @touch $@ + patch --forward -p1 -d $(SCAPY_SOURCE) < $$f ; \ + retCode=$$?; \ + [ $$retCode -gt 1 ] && exit $$retCode; \ + done; \ + touch $@ $(PAPI_INSTALL_DONE): $(PIP_PATCH_DONE) @bash -c "source $(VENV_PATH)/bin/activate && $(PYTHON_INTERP) -m pip install -e $(WS_ROOT)/src/vpp-api/python" @touch $@ +.PHONY: update-deps clear-deps +refresh-deps: clean-deps $(PYTHON_DEPENDS) + +clean-deps: + @rm -f $(PYTHON_DEPENDS) + +ifneq ($(EXTERN_PLUGIN_SRC_DIR),) +PLUGIN_SRC_DIR=$(EXTERN_PLUGIN_SRC_DIR) +else +PLUGIN_SRC_DIR=$(WS_ROOT)/src/plugins +endif +PLUGIN_TEST_DIRS=$(shell find $(PLUGIN_SRC_DIR) -type d -name test -exec echo -n " -d {}" \;) + define retest-func -@env 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 +@env 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)$(PLUGIN_TEST_DIRS) $(UNITTEST_EXTRA_OPTS) || env FAILED_DIR=$(FAILED_DIR) COMPRESS_FAILED_TEST_LOGS=$(COMPRESS_FAILED_TEST_LOGS) scripts/compress_failed.sh endef .PHONY: sanity @@ -159,9 +195,7 @@ sanity: verify-no-running-vpp .PHONY: ext ext: - @if [ "$(EXTENDED_TESTS)" = "yes" ]; then\ - make -C ext;\ - fi + make -C ext test-dep: verify-test-dir $(PAPI_INSTALL_DONE) @@ -200,8 +234,8 @@ wipe: reset @rm -f $(PAPI_INSTALL_FLAGS) doc: verify-test-dir $(PIP_PATCH_DONE) - @virtualenv $(VENV_PATH) -p python3 - @bash -c "source $(VENV_PATH)/bin/activate && python3 -m pip install sphinx sphinx-rtd-theme" + @bash -c "source $(VENV_PATH)/bin/activate && \ + $(PYTHON_INTERP) -m pip install sphinx sphinx-rtd-theme" @bash -c "source $(VENV_PATH)/bin/activate && make -C doc WS_ROOT=$(WS_ROOT) BR=$(BR) html" .PHONY: wipe-doc @@ -227,12 +261,17 @@ cov: wipe-cov reset ext verify-test-dir $(PAPI_INSTALL_DONE) wipe-cov: wipe @rm -rf $(BUILD_COV_DIR) +.PHONY: papi-wipe + +papi-wipe: + @rm -rf $(PAPI_INSTALL_DONE) + .PHONY: checkstyle -checkstyle: verify-test-dir - @virtualenv $(VENV_PATH) -p python3 - @bash -c "source $(VENV_PATH)/bin/activate && python3 -m pip install pycodestyle" +checkstyle: verify-test-dir $(PIP_INSTALL_DONE) + @bash -c "source $(VENV_PATH)/bin/activate &&\ + $(PYTHON_INTERP) -m pip install pycodestyle" @bash -c "source $(VENV_PATH)/bin/activate &&\ - pycodestyle --show-source --ignore=W504,E126,E241,E226,E305,E704,E741,E722 --exclude=$(WS_ROOT)/test/_*.py -v $(WS_ROOT)/test/*.py ||\ + pycodestyle --show-source --ignore=W504,E126,E241,E226,E305,E704,E741,E722 --exclude=$(WS_ROOT)/test/_*.py -v $(WS_ROOT)/test/*.py $(PLUGIN_SRC_DIR)/*/test/*.py ||\ (echo \"*******************************************************************\" &&\ echo \"* Test framework PEP8 compliance check FAILED \" &&\ echo \"*******************************************************************\" &&\ @@ -246,10 +285,11 @@ help: @echo "" @echo " test - build and run (basic) functional tests" @echo " test-debug - build and run (basic) functional tests (debug build)" - @echo " test-all - build and run (all) functional tests" - @echo " test-all-debug - build and run (all) functional tests (debug build)" + @echo " test-all - build and run functional and extended tests" + @echo " test-all-debug - build and run functional and extended tests (debug build)" @echo " retest - run functional tests" @echo " retest-debug - run functional tests (debug build)" + @echo " papi-wipe - rebuild vpp_papi sources" @echo " test-wipe - wipe (temporary) files generated by unit tests" @echo " test-shell - enter shell with test environment" @echo " test-shell-debug - enter shell with test environment (debug build)" @@ -271,7 +311,7 @@ help: @echo " same as above" @echo " STEP=[yes|no] - ease debugging by stepping through a testcase" @echo " SANITY=[yes|no] - perform sanity import of vpp-api/sanity vpp run before running tests (default: yes)" - @echo " EXTENDED_TESTS=[1|y] - run extended tests" + @echo " EXTENDED_TESTS=[1|y] - used by 'test-all' & 'test-all-debug' to run extended tests" @echo " TEST= - filter the set of tests:" @echo " by file-name - only run tests from specified file, e.g. TEST=test_bfd selects all tests from test_bfd.py" @echo " by file-suffix - same as file-name, but 'test_' is omitted e.g. TEST=bfd selects all tests from test_bfd.py" @@ -301,6 +341,8 @@ help: @echo "" @echo " SOCKET=1 - Communicate with VPP over Unix domain socket instead of SHM" @echo "" + @echo " RND_SEED=seed - Seed RND with given seed" + @echo "" @echo "Creating test documentation" @echo " test-doc - generate documentation for test framework" @echo " test-wipe-doc - wipe documentation for test framework"