Klement Sekera | 277b89c | 2016-10-28 13:20:27 +0200 | [diff] [blame] | 1 | .PHONY: verify-python-path |
Damjan Marion | f56b77a | 2016-10-03 19:44:57 +0200 | [diff] [blame] | 2 | |
Klement Sekera | 277b89c | 2016-10-28 13:20:27 +0200 | [diff] [blame] | 3 | verify-python-path: |
| 4 | ifndef VPP_PYTHON_PREFIX |
| 5 | $(error VPP_PYTHON_PREFIX is not set) |
| 6 | endif |
| 7 | |
| 8 | PYTHON_VENV_PATH=$(VPP_PYTHON_PREFIX)/virtualenv |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 9 | PYTHON_DEPENDS=scapy==2.3.3 pexpect |
Klement Sekera | 9f9d07b | 2016-12-12 09:20:50 +0100 | [diff] [blame] | 10 | SCAPY_SOURCE=$(PYTHON_VENV_PATH)/lib/python2.7/site-packages/ |
Juraj Sloboda | 0279b29 | 2016-11-16 19:50:24 +0100 | [diff] [blame] | 11 | BUILD_COV_DIR = $(BR)/test-cov |
Klement Sekera | 277b89c | 2016-10-28 13:20:27 +0200 | [diff] [blame] | 12 | |
Klement Sekera | 9f9d07b | 2016-12-12 09:20:50 +0100 | [diff] [blame] | 13 | PIP_INSTALL_DONE=$(VPP_PYTHON_PREFIX)/pip-install.done |
| 14 | PIP_PATCH_DONE=$(VPP_PYTHON_PREFIX)/pip-patch.done |
| 15 | PAPI_INSTALL_DONE=$(VPP_PYTHON_PREFIX)/papi-install.done |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 16 | |
Klement Sekera | 9f9d07b | 2016-12-12 09:20:50 +0100 | [diff] [blame] | 17 | PAPI_INSTALL_FLAGS=$(PIP_INSTALL_DONE) $(PIP_PATCH_DONE) $(PAPI_INSTALL_DONE) |
| 18 | |
| 19 | $(PIP_INSTALL_DONE): |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 20 | @virtualenv $(PYTHON_VENV_PATH) |
Klement Sekera | 778c276 | 2016-11-08 02:00:28 +0100 | [diff] [blame] | 21 | @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && pip install $(PYTHON_DEPENDS)" |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 22 | @touch $@ |
| 23 | |
Klement Sekera | 9f9d07b | 2016-12-12 09:20:50 +0100 | [diff] [blame] | 24 | $(PIP_PATCH_DONE): $(PIP_INSTALL_DONE) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 25 | @echo --- patching --- |
| 26 | for f in $(CURDIR)/patches/scapy-2.3.3/*.patch ; do \ |
| 27 | echo Applying patch: $$(basename $$f) ; \ |
| 28 | patch -p1 -d $(SCAPY_SOURCE) < $$f ; \ |
| 29 | done |
| 30 | @touch $@ |
| 31 | |
Klement Sekera | 9f9d07b | 2016-12-12 09:20:50 +0100 | [diff] [blame] | 32 | $(PAPI_INSTALL_DONE): $(PIP_PATCH_DONE) |
Damjan Marion | 37d77e9 | 2016-12-28 15:14:46 +0100 | [diff] [blame] | 33 | @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && cd $(WS_ROOT)/src/vpp-api/python && python setup.py install" |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 34 | @touch $@ |
| 35 | |
Juraj Sloboda | 0279b29 | 2016-11-16 19:50:24 +0100 | [diff] [blame] | 36 | define retest-func |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 37 | @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && python run_tests.py discover -p test_$(TEST)\"*.py\"" |
Juraj Sloboda | 0279b29 | 2016-11-16 19:50:24 +0100 | [diff] [blame] | 38 | endef |
| 39 | |
Klement Sekera | 9f9d07b | 2016-12-12 09:20:50 +0100 | [diff] [blame] | 40 | test: reset verify-python-path $(PAPI_INSTALL_DONE) |
Juraj Sloboda | 0279b29 | 2016-11-16 19:50:24 +0100 | [diff] [blame] | 41 | $(call retest-func) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 42 | |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 43 | retest: reset verify-python-path |
Juraj Sloboda | 0279b29 | 2016-11-16 19:50:24 +0100 | [diff] [blame] | 44 | $(call retest-func) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 45 | |
Klement Sekera | 277b89c | 2016-10-28 13:20:27 +0200 | [diff] [blame] | 46 | .PHONY: wipe doc |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 47 | |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 48 | reset: |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 49 | @rm -f /dev/shm/vpp-unittest-* |
| 50 | @rm -rf /tmp/vpp-unittest-* |
| 51 | |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 52 | wipe: reset |
Klement Sekera | 9f9d07b | 2016-12-12 09:20:50 +0100 | [diff] [blame] | 53 | @rm -rf $(PYTHON_VENV_PATH) |
| 54 | @rm -f $(PAPI_INSTALL_FLAGS) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 55 | |
Klement Sekera | 277b89c | 2016-10-28 13:20:27 +0200 | [diff] [blame] | 56 | doc: verify-python-path |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 57 | @virtualenv $(PYTHON_VENV_PATH) |
Klement Sekera | 778c276 | 2016-11-08 02:00:28 +0100 | [diff] [blame] | 58 | @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && pip install $(PYTHON_DEPENDS) sphinx" |
Klement Sekera | 277b89c | 2016-10-28 13:20:27 +0200 | [diff] [blame] | 59 | @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && make -C doc WS_ROOT=$(WS_ROOT) BR=$(BR) NO_VPP_PAPI=1 html" |
| 60 | |
Klement Sekera | 9f9d07b | 2016-12-12 09:20:50 +0100 | [diff] [blame] | 61 | .PHONY: wipe-doc |
| 62 | |
Klement Sekera | 277b89c | 2016-10-28 13:20:27 +0200 | [diff] [blame] | 63 | wipe-doc: |
| 64 | @make -C doc wipe BR=$(BR) |
| 65 | |
Klement Sekera | 9f9d07b | 2016-12-12 09:20:50 +0100 | [diff] [blame] | 66 | cov: wipe-cov reset verify-python-path $(PAPI_INSTALL_DONE) |
Juraj Sloboda | 0279b29 | 2016-11-16 19:50:24 +0100 | [diff] [blame] | 67 | @lcov --zerocounters --directory $(VPP_TEST_BUILD_DIR) |
| 68 | $(call retest-func) |
| 69 | @mkdir $(BUILD_COV_DIR) |
| 70 | @lcov --capture --directory $(VPP_TEST_BUILD_DIR) --output-file $(BUILD_COV_DIR)/coverage.info |
| 71 | @genhtml $(BUILD_COV_DIR)/coverage.info --output-directory $(BUILD_COV_DIR)/html |
| 72 | @echo |
| 73 | @echo "Build finished. Code coverage report is in $(BUILD_COV_DIR)/html/index.html" |
| 74 | |
Klement Sekera | 9f9d07b | 2016-12-12 09:20:50 +0100 | [diff] [blame] | 75 | .PHONY: wipe-cov |
| 76 | |
Juraj Sloboda | 0279b29 | 2016-11-16 19:50:24 +0100 | [diff] [blame] | 77 | wipe-cov: wipe |
| 78 | @rm -rf $(BUILD_COV_DIR) |
| 79 | |
Klement Sekera | 277b89c | 2016-10-28 13:20:27 +0200 | [diff] [blame] | 80 | help: |
| 81 | @echo "Running tests:" |
| 82 | @echo "" |
| 83 | @echo " test - build and run functional tests" |
| 84 | @echo " test-debug - build and run functional tests (debug build)" |
| 85 | @echo " retest - run functional tests" |
| 86 | @echo " retest-debug - run functional tests (debug build)" |
Juraj Sloboda | 0279b29 | 2016-11-16 19:50:24 +0100 | [diff] [blame] | 87 | @echo " test-wipe - wipe (temporary) files generated by unit tests" |
Klement Sekera | 277b89c | 2016-10-28 13:20:27 +0200 | [diff] [blame] | 88 | @echo "" |
| 89 | @echo "Arguments controlling test runs:" |
| 90 | @echo " V=[0|1|2] - set test verbosity level" |
| 91 | @echo " DEBUG=<type> - set VPP debugging kind" |
| 92 | @echo " DEBUG=core - detect coredump and load it in gdb on crash" |
| 93 | @echo " DEBUG=gdb - allow easy debugging by printing VPP PID " |
| 94 | @echo " and waiting for user input before running " |
| 95 | @echo " and tearing down a testcase" |
| 96 | @echo " DEBUG=gdbserver - run gdb inside a gdb server, otherwise " |
| 97 | @echo " same as above" |
| 98 | @echo " STEP=[yes|no] - ease debugging by stepping through a testcase " |
| 99 | @echo " TEST=<name> - only run specific test" |
| 100 | @echo "" |
| 101 | @echo "Creating test documentation" |
| 102 | @echo " test-doc - generate documentation for test framework" |
Juraj Sloboda | 0279b29 | 2016-11-16 19:50:24 +0100 | [diff] [blame] | 103 | @echo " test-wipe-doc - wipe documentation for test framework" |
| 104 | @echo "" |
| 105 | @echo "Creating test code coverage report" |
| 106 | @echo " test-cov - generate code coverage report for test framework" |
| 107 | @echo " test-wipe-cov - wipe code coverage report for test framework" |
Klement Sekera | 277b89c | 2016-10-28 13:20:27 +0200 | [diff] [blame] | 108 | @echo "" |