X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2FMakefile;h=ef1949529fb1717a1cfb77b8dd21d8e0c00660fa;hb=50132fa8c14dd74a77b760bc603f96d7027bb73a;hp=de6aaa7a7935047b938523c7279c17e4359415d0;hpb=177bbdcd8fa4e7621c5bdd3afd8c6e74b603e096;p=vpp.git diff --git a/test/Makefile b/test/Makefile index de6aaa7a793..ef1949529fb 100644 --- a/test/Makefile +++ b/test/Makefile @@ -7,34 +7,42 @@ endif PYTHON_VENV_PATH=$(VPP_PYTHON_PREFIX)/virtualenv PYTHON_DEPENDS=scapy==2.3.3 pexpect -SCAPY_SOURCE=$(WS_ROOT)/build-root/python/virtualenv/lib/python2.7/site-packages/ +SCAPY_SOURCE=$(PYTHON_VENV_PATH)/lib/python2.7/site-packages/ +BUILD_COV_DIR = $(BR)/test-cov +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 -.pip-install.ok: - @virtualenv $(PYTHON_VENV_PATH) +PAPI_INSTALL_FLAGS=$(PIP_INSTALL_DONE) $(PIP_PATCH_DONE) $(PAPI_INSTALL_DONE) + +$(PIP_INSTALL_DONE): + @virtualenv $(PYTHON_VENV_PATH) -p python2.7 @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && pip install $(PYTHON_DEPENDS)" @touch $@ -.pip-patch.ok: .pip-install.ok +$(PIP_PATCH_DONE): $(PIP_INSTALL_DONE) @echo --- patching --- + @sleep 1 # Ensure python recompiles patched *.py files -> *.pyc for f in $(CURDIR)/patches/scapy-2.3.3/*.patch ; do \ echo Applying patch: $$(basename $$f) ; \ patch -p1 -d $(SCAPY_SOURCE) < $$f ; \ done @touch $@ -.install.ok: .pip-patch.ok - @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && cd $(WS_ROOT)/vpp-api/python && python setup.py install" +$(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" @touch $@ -PHONIES=.install.ok .pip-patch.ok .pip-install.ok -.PHONY: $(PHONIES) - -test: reset verify-python-path .install.ok +define retest-func @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && python run_tests.py discover -p test_$(TEST)\"*.py\"" +endef + +test: reset verify-python-path $(PAPI_INSTALL_DONE) + $(call retest-func) retest: reset verify-python-path - @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && python run_tests.py discover -p test_$(TEST)\"*.py\"" + $(call retest-func) .PHONY: wipe doc @@ -43,16 +51,47 @@ reset: @rm -rf /tmp/vpp-unittest-* wipe: reset - @rm -f $(PHONIES) + @rm -rf $(PYTHON_VENV_PATH) + @rm -f $(PAPI_INSTALL_FLAGS) doc: verify-python-path - @virtualenv $(PYTHON_VENV_PATH) - @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && pip install $(PYTHON_DEPENDS) sphinx" + @virtualenv $(PYTHON_VENV_PATH) -p python2.7 + @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && pip install $(PYTHON_DEPENDS) 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" +.PHONY: wipe-doc + wipe-doc: @make -C doc wipe BR=$(BR) +cov: wipe-cov reset verify-python-path $(PAPI_INSTALL_DONE) + @lcov --zerocounters --directory $(VPP_TEST_BUILD_DIR) + $(call retest-func) + @mkdir $(BUILD_COV_DIR) + @lcov --capture --directory $(VPP_TEST_BUILD_DIR) --output-file $(BUILD_COV_DIR)/coverage.info + @genhtml $(BUILD_COV_DIR)/coverage.info --output-directory $(BUILD_COV_DIR)/html + @echo + @echo "Build finished. Code coverage report is in $(BUILD_COV_DIR)/html/index.html" + +.PHONY: wipe-cov + +wipe-cov: wipe + @rm -rf $(BUILD_COV_DIR) + +.PHONY: checkstyle +checkstyle: verify-python-path + @virtualenv $(PYTHON_VENV_PATH) -p python2.7 + @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && pip install $(PYTHON_DEPENDS) pep8" + @bash -c "source $(PYTHON_VENV_PATH)/bin/activate &&\ + pep8 --show-source -v $(WS_ROOT)/test/*.py ||\ + (echo \"*******************************************************************\" &&\ + echo \"* Test framework PEP8 compliance check FAILED \" &&\ + echo \"*******************************************************************\" &&\ + false)" + @echo "*******************************************************************" + @echo "* Test framework PEP8 compliance check passed" + @echo "*******************************************************************" + help: @echo "Running tests:" @echo "" @@ -60,7 +99,7 @@ help: @echo " test-debug - build and run functional tests (debug build)" @echo " retest - run functional tests" @echo " retest-debug - run functional tests (debug build)" - @echo " wipe-test - wipe (temporary) files generated by unit tests" + @echo " test-wipe - wipe (temporary) files generated by unit tests" @echo "" @echo "Arguments controlling test runs:" @echo " V=[0|1|2] - set test verbosity level" @@ -76,5 +115,12 @@ help: @echo "" @echo "Creating test documentation" @echo " test-doc - generate documentation for test framework" - @echo " wipe-test-doc - wipe documentation for test framework" + @echo " test-wipe-doc - wipe documentation for test framework" + @echo "" + @echo "Creating test code coverage report" + @echo " test-cov - generate code coverage report for test framework" + @echo " test-wipe-cov - wipe code coverage report for test framework" + @echo "" + @echo "Verifying code-style" + @echo " test-checkstyle - check PEP8 compliance" @echo ""