diff options
Diffstat (limited to 'test/Makefile')
-rw-r--r-- | test/Makefile | 92 |
1 files changed, 47 insertions, 45 deletions
diff --git a/test/Makefile b/test/Makefile index 0369018af2f..eae2d894b1f 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,10 +1,10 @@ -.PHONY: verify-python-path +.PHONY: verify-test-dir -VPP_TEST_FAILED_DIR=/tmp/vpp-failed-unittests/ +FAILED_DIR=/tmp/vpp-failed-unittests/ -verify-python-path: -ifndef VPP_PYTHON_PREFIX - $(error VPP_PYTHON_PREFIX is not set) +verify-test-dir: +ifndef TEST_DIR + $(error TEST_DIR is not set) endif .PHONY: verify-no-running-vpp @@ -65,22 +65,24 @@ ifneq ($(EXTERN_TESTS),) UNITTEST_EXTRA_OPTS=$(UNITTEST_FAILFAST_OPTS) -d $(EXTERN_TESTS) endif +VENV_PATH=$(TEST_DIR)/run/venv + ifeq ($(TEST_DEBUG),1) -VPP_PYTHON_PREFIX:=$(VPP_PYTHON_PREFIX)/debug +TEST_RUN_DIR:=$(VENV_PATH)/run-debug PYTHON_EXTRA_DEPENDS=objgraph pympler else +TEST_RUN_DIR:=$(VENV_PATH)/run PYTHON_EXTRA_DEPENDS= endif -PYTHON_VENV_PATH=$(VPP_PYTHON_PREFIX)/virtualenv PYTHON_DEPENDS=$(PYTHON_EXTRA_DEPENDS) -r requirements.txt -SCAPY_SOURCE=$(shell find $(PYTHON_VENV_PATH) -name site-packages) -BUILD_COV_DIR=$(BR)/test-cov +SCAPY_SOURCE=$(shell find $(VENV_PATH) -name site-packages) +BUILD_COV_DIR=$(TEST_DIR)/coverage -GET_PIP_SCRIPT=$(VPP_PYTHON_PREFIX)/get-pip.py -PIP_INSTALL_DONE=$(VPP_PYTHON_PREFIX)/pip-install.done -PIP_PATCH_DONE=$(VPP_PYTHON_PREFIX)/pip-patch.done -PAPI_INSTALL_DONE=$(VPP_PYTHON_PREFIX)/papi-install.done +GET_PIP_SCRIPT=$(TEST_RUN_DIR)/get-pip.py +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) @@ -91,13 +93,13 @@ PYTHON_INTERP=$(PYTHON) endif $(GET_PIP_SCRIPT): - @mkdir -p $(VPP_PYTHON_PREFIX) - @bash -c "cd $(VPP_PYTHON_PREFIX) && curl -O https://bootstrap.pypa.io/get-pip.py" + @mkdir -p $(TEST_RUN_DIR) + @bash -c "cd $(TEST_RUN_DIR) && curl -O https://bootstrap.pypa.io/get-pip.py" $(PIP_INSTALL_DONE): $(GET_PIP_SCRIPT) - @virtualenv $(PYTHON_VENV_PATH) -p $(PYTHON_INTERP) - @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && python $(GET_PIP_SCRIPT)" - @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && pip install $(PYTHON_DEPENDS)" + @virtualenv $(VENV_PATH) -p $(PYTHON_INTERP) + @bash -c "source $(VENV_PATH)/bin/activate && python $(GET_PIP_SCRIPT)" + @bash -c "source $(VENV_PATH)/bin/activate && pip install $(PYTHON_DEPENDS)" @touch $@ $(PIP_PATCH_DONE): $(PIP_INSTALL_DONE) @@ -110,11 +112,11 @@ $(PIP_PATCH_DONE): $(PIP_INSTALL_DONE) @touch $@ $(PAPI_INSTALL_DONE): $(PIP_PATCH_DONE) - @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && cd $(WS_ROOT)/src/vpp-api/python && python setup.py install" + @bash -c "source $(VENV_PATH)/bin/activate && cd $(WS_ROOT)/src/vpp-api/python && python setup.py install" @touch $@ define retest-func -@env FORCE_FOREGROUND=$(FORCE_FOREGROUND) VPP_TEST_FAILED_DIR=$(VPP_TEST_FAILED_DIR) scripts/setsid_wrapper.sh $(FORCE_FOREGROUND) $(PYTHON_VENV_PATH)/bin/activate python $(PYTHON_PROFILE_OPTS) run_tests.py -d $(TEST_DIR) $(UNITTEST_EXTRA_OPTS) || env VPP_TEST_FAILED_DIR=$(VPP_TEST_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 $(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 endef .PHONY: sanity @@ -123,8 +125,8 @@ ifeq ($(SANITY),no) SANITY_IMPORT_VPP_PAPI_CMD=true SANITY_RUN_VPP_CMD=true else -SANITY_IMPORT_VPP_PAPI_CMD=source $(PYTHON_VENV_PATH)/bin/activate && python sanity_import_vpp_papi.py -SANITY_RUN_VPP_CMD=source $(PYTHON_VENV_PATH)/bin/activate && python sanity_run_vpp.py +SANITY_IMPORT_VPP_PAPI_CMD=source $(VENV_PATH)/bin/activate && python sanity_import_vpp_papi.py +SANITY_RUN_VPP_CMD=source $(VENV_PATH)/bin/activate && python sanity_run_vpp.py endif ifndef TEST_JOBS @@ -166,21 +168,21 @@ ext: make -C ext;\ fi -test-dep: verify-python-path $(PAPI_INSTALL_DONE) +test-dep: verify-test-dir $(PAPI_INSTALL_DONE) -test: verify-python-path $(PAPI_INSTALL_DONE) ext sanity reset +test: verify-test-dir $(PAPI_INSTALL_DONE) ext sanity reset $(call retest-func) -retest: verify-python-path sanity reset +retest: verify-test-dir sanity reset $(call retest-func) -shell: verify-python-path $(PAPI_INSTALL_DONE) - @echo "source $(PYTHON_VENV_PATH)/bin/activate;\ +shell: verify-test-dir $(PAPI_INSTALL_DONE) + @echo "source $(VENV_PATH)/bin/activate;\ echo '***';\ - echo VPP_TEST_BUILD_DIR=$(VPP_TEST_BUILD_DIR);\ - echo VPP_TEST_BIN=$(VPP_TEST_BIN);\ - echo VPP_TEST_PLUGIN_PATH=$(VPP_TEST_PLUGIN_PATH);\ - echo VPP_TEST_INSTALL_PATH=$(VPP_TEST_INSTALL_PATH);\ + echo _BUILD_DIR=$(VPP_BUILD_DIR);\ + echo _BIN=$(VPP_BIN);\ + echo _PLUGIN_PATH=$(VPP_PLUGIN_PATH);\ + echo _INSTALL_PATH=$(VPP_INSTALL_PATH);\ echo EXTERN_TESTS=$(EXTERN_TESTS);\ echo EXTERN_PLUGINS=$(EXTERN_PLUGINS);\ echo EXTERN_COV_DIR=$(EXTERN_COV_DIR);\ @@ -193,30 +195,30 @@ shell: verify-python-path $(PAPI_INSTALL_DONE) reset: @rm -f /dev/shm/vpp-unittest-* @rm -rf /tmp/vpp-unittest-* - @rm -rf $(VPP_TEST_FAILED_DIR) - @mkdir $(VPP_TEST_FAILED_DIR) + @rm -rf $(FAILED_DIR) + @mkdir $(FAILED_DIR) wipe: reset @make -C ext clean - @rm -rf $(PYTHON_VENV_PATH) + @rm -rf $(VENV_PATH) @rm -f $(PAPI_INSTALL_FLAGS) -doc: verify-python-path $(PIP_PATCH_DONE) - @virtualenv $(PYTHON_VENV_PATH) -p $(PYTHON_INTERP) - @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && pip install sphinx sphinx-rtd-theme" - @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && make -C doc WS_ROOT=$(WS_ROOT) BR=$(BR) NO_VPP_PAPI=1 html" +doc: verify-test-dir $(PIP_PATCH_DONE) + @virtualenv $(VENV_PATH) -p $(PYTHON_INTERP) + @bash -c "source $(VENV_PATH)/bin/activate && pip install sphinx sphinx-rtd-theme" + @bash -c "source $(VENV_PATH)/bin/activate && make -C doc WS_ROOT=$(WS_ROOT) BR=$(BR) NO_VPP_PAPI=1 html" .PHONY: wipe-doc wipe-doc: @make -C doc wipe BR=$(BR) -cov: wipe-cov reset ext verify-python-path $(PAPI_INSTALL_DONE) - @lcov --zerocounters --directory $(VPP_TEST_BUILD_DIR) +cov: wipe-cov reset ext verify-test-dir $(PAPI_INSTALL_DONE) + @lcov --zerocounters --directory $(_BUILD_DIR) @test -z "$(EXTERN_COV_DIR)" || lcov --zerocounters --directory $(EXTERN_COV_DIR) $(call retest-func) @mkdir $(BUILD_COV_DIR) - @lcov --capture --directory $(VPP_TEST_BUILD_DIR) --output-file $(BUILD_COV_DIR)/coverage.info + @lcov --capture --directory $(_BUILD_DIR) --output-file $(BUILD_COV_DIR)/coverage.info @test -z "$(EXTERN_COV_DIR)" || lcov --capture --directory $(EXTERN_COV_DIR) --output-file $(BUILD_COV_DIR)/extern-coverage.info @genhtml $(BUILD_COV_DIR)/coverage.info --output-directory $(BUILD_COV_DIR)/html @test -z "$(EXTERN_COV_DIR)" || genhtml $(BUILD_COV_DIR)/extern-coverage.info --output-directory $(BUILD_COV_DIR)/extern-html @@ -230,10 +232,10 @@ wipe-cov: wipe @rm -rf $(BUILD_COV_DIR) .PHONY: checkstyle -checkstyle: verify-python-path - @virtualenv $(PYTHON_VENV_PATH) -p $(PYTHON_INTERP) - @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && pip install pycodestyle" - @bash -c "source $(PYTHON_VENV_PATH)/bin/activate &&\ +checkstyle: verify-test-dir + @virtualenv $(VENV_PATH) -p $(PYTHON_INTERP) + @bash -c "source $(VENV_PATH)/bin/activate && pip install pycodestyle" + @bash -c "source $(VENV_PATH)/bin/activate &&\ pycodestyle --show-source --ignore=W504,E126,E241,E226,E305,E704,E741,E722 -v $(WS_ROOT)/test/*.py ||\ (echo \"*******************************************************************\" &&\ echo \"* Test framework PEP8 compliance check FAILED \" &&\ |