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