blob: 54fe0582aba51fbe3c4ff0d711eb75bc8093f83f [file] [log] [blame]
Klement Sekera277b89c2016-10-28 13:20:27 +02001.PHONY: verify-python-path
Damjan Marionf56b77a2016-10-03 19:44:57 +02002
Klement Sekera277b89c2016-10-28 13:20:27 +02003verify-python-path:
4ifndef VPP_PYTHON_PREFIX
5 $(error VPP_PYTHON_PREFIX is not set)
6endif
7
8PYTHON_VENV_PATH=$(VPP_PYTHON_PREFIX)/virtualenv
Neale Ranns177bbdc2016-11-15 09:46:51 +00009PYTHON_DEPENDS=scapy==2.3.3 pexpect
Klement Sekera9f9d07b2016-12-12 09:20:50 +010010SCAPY_SOURCE=$(PYTHON_VENV_PATH)/lib/python2.7/site-packages/
Juraj Sloboda0279b292016-11-16 19:50:24 +010011BUILD_COV_DIR = $(BR)/test-cov
Klement Sekera277b89c2016-10-28 13:20:27 +020012
Klement Sekera9f9d07b2016-12-12 09:20:50 +010013PIP_INSTALL_DONE=$(VPP_PYTHON_PREFIX)/pip-install.done
14PIP_PATCH_DONE=$(VPP_PYTHON_PREFIX)/pip-patch.done
15PAPI_INSTALL_DONE=$(VPP_PYTHON_PREFIX)/papi-install.done
Neale Ranns177bbdc2016-11-15 09:46:51 +000016
Klement Sekera9f9d07b2016-12-12 09:20:50 +010017PAPI_INSTALL_FLAGS=$(PIP_INSTALL_DONE) $(PIP_PATCH_DONE) $(PAPI_INSTALL_DONE)
18
19$(PIP_INSTALL_DONE):
Klement Sekeraf62ae122016-10-11 11:47:09 +020020 @virtualenv $(PYTHON_VENV_PATH)
Klement Sekera778c2762016-11-08 02:00:28 +010021 @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && pip install $(PYTHON_DEPENDS)"
Neale Ranns177bbdc2016-11-15 09:46:51 +000022 @touch $@
23
Klement Sekera9f9d07b2016-12-12 09:20:50 +010024$(PIP_PATCH_DONE): $(PIP_INSTALL_DONE)
Neale Ranns177bbdc2016-11-15 09:46:51 +000025 @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 Sekera9f9d07b2016-12-12 09:20:50 +010032$(PAPI_INSTALL_DONE): $(PIP_PATCH_DONE)
Klement Sekeraf62ae122016-10-11 11:47:09 +020033 @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && cd $(WS_ROOT)/vpp-api/python && python setup.py install"
Neale Ranns177bbdc2016-11-15 09:46:51 +000034 @touch $@
35
Juraj Sloboda0279b292016-11-16 19:50:24 +010036define retest-func
Klement Sekeraf62ae122016-10-11 11:47:09 +020037 @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && python run_tests.py discover -p test_$(TEST)\"*.py\""
Juraj Sloboda0279b292016-11-16 19:50:24 +010038endef
39
Klement Sekera9f9d07b2016-12-12 09:20:50 +010040test: reset verify-python-path $(PAPI_INSTALL_DONE)
Juraj Sloboda0279b292016-11-16 19:50:24 +010041 $(call retest-func)
Klement Sekeraf62ae122016-10-11 11:47:09 +020042
Neale Ranns177bbdc2016-11-15 09:46:51 +000043retest: reset verify-python-path
Juraj Sloboda0279b292016-11-16 19:50:24 +010044 $(call retest-func)
Klement Sekeraf62ae122016-10-11 11:47:09 +020045
Klement Sekera277b89c2016-10-28 13:20:27 +020046.PHONY: wipe doc
Klement Sekeraf62ae122016-10-11 11:47:09 +020047
Neale Ranns177bbdc2016-11-15 09:46:51 +000048reset:
Klement Sekeraf62ae122016-10-11 11:47:09 +020049 @rm -f /dev/shm/vpp-unittest-*
50 @rm -rf /tmp/vpp-unittest-*
51
Neale Ranns177bbdc2016-11-15 09:46:51 +000052wipe: reset
Klement Sekera9f9d07b2016-12-12 09:20:50 +010053 @rm -rf $(PYTHON_VENV_PATH)
54 @rm -f $(PAPI_INSTALL_FLAGS)
Neale Ranns177bbdc2016-11-15 09:46:51 +000055
Klement Sekera277b89c2016-10-28 13:20:27 +020056doc: verify-python-path
Klement Sekeraf62ae122016-10-11 11:47:09 +020057 @virtualenv $(PYTHON_VENV_PATH)
Klement Sekera778c2762016-11-08 02:00:28 +010058 @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && pip install $(PYTHON_DEPENDS) sphinx"
Klement Sekera277b89c2016-10-28 13:20:27 +020059 @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && make -C doc WS_ROOT=$(WS_ROOT) BR=$(BR) NO_VPP_PAPI=1 html"
60
Klement Sekera9f9d07b2016-12-12 09:20:50 +010061.PHONY: wipe-doc
62
Klement Sekera277b89c2016-10-28 13:20:27 +020063wipe-doc:
64 @make -C doc wipe BR=$(BR)
65
Klement Sekera9f9d07b2016-12-12 09:20:50 +010066cov: wipe-cov reset verify-python-path $(PAPI_INSTALL_DONE)
Juraj Sloboda0279b292016-11-16 19:50:24 +010067 @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 Sekera9f9d07b2016-12-12 09:20:50 +010075.PHONY: wipe-cov
76
Juraj Sloboda0279b292016-11-16 19:50:24 +010077wipe-cov: wipe
78 @rm -rf $(BUILD_COV_DIR)
79
Klement Sekera277b89c2016-10-28 13:20:27 +020080help:
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 Sloboda0279b292016-11-16 19:50:24 +010087 @echo " test-wipe - wipe (temporary) files generated by unit tests"
Klement Sekera277b89c2016-10-28 13:20:27 +020088 @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 Sloboda0279b292016-11-16 19:50:24 +0100103 @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 Sekera277b89c2016-10-28 13:20:27 +0200108 @echo ""