blob: 7561a009678400de481106b7200971f4b1154e9e [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
10SCAPY_SOURCE=$(WS_ROOT)/build-root/python/virtualenv/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
Neale Ranns177bbdc2016-11-15 09:46:51 +000013
14.pip-install.ok:
Klement Sekeraf62ae122016-10-11 11:47:09 +020015 @virtualenv $(PYTHON_VENV_PATH)
Klement Sekera778c2762016-11-08 02:00:28 +010016 @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && pip install $(PYTHON_DEPENDS)"
Neale Ranns177bbdc2016-11-15 09:46:51 +000017 @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 Sekeraf62ae122016-10-11 11:47:09 +020028 @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 +000029 @touch $@
30
31PHONIES=.install.ok .pip-patch.ok .pip-install.ok
32.PHONY: $(PHONIES)
33
Juraj Sloboda0279b292016-11-16 19:50:24 +010034define retest-func
Klement Sekeraf62ae122016-10-11 11:47:09 +020035 @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && python run_tests.py discover -p test_$(TEST)\"*.py\""
Juraj Sloboda0279b292016-11-16 19:50:24 +010036endef
37
38test: reset verify-python-path .install.ok
39 $(call retest-func)
Klement Sekeraf62ae122016-10-11 11:47:09 +020040
Neale Ranns177bbdc2016-11-15 09:46:51 +000041retest: reset verify-python-path
Juraj Sloboda0279b292016-11-16 19:50:24 +010042 $(call retest-func)
Klement Sekeraf62ae122016-10-11 11:47:09 +020043
Klement Sekera277b89c2016-10-28 13:20:27 +020044.PHONY: wipe doc
Klement Sekeraf62ae122016-10-11 11:47:09 +020045
Neale Ranns177bbdc2016-11-15 09:46:51 +000046reset:
Klement Sekeraf62ae122016-10-11 11:47:09 +020047 @rm -f /dev/shm/vpp-unittest-*
48 @rm -rf /tmp/vpp-unittest-*
49
Neale Ranns177bbdc2016-11-15 09:46:51 +000050wipe: reset
51 @rm -f $(PHONIES)
52
Klement Sekera277b89c2016-10-28 13:20:27 +020053doc: verify-python-path
Klement Sekeraf62ae122016-10-11 11:47:09 +020054 @virtualenv $(PYTHON_VENV_PATH)
Klement Sekera778c2762016-11-08 02:00:28 +010055 @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && pip install $(PYTHON_DEPENDS) sphinx"
Klement Sekera277b89c2016-10-28 13:20:27 +020056 @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && make -C doc WS_ROOT=$(WS_ROOT) BR=$(BR) NO_VPP_PAPI=1 html"
57
58wipe-doc:
59 @make -C doc wipe BR=$(BR)
60
Juraj Sloboda0279b292016-11-16 19:50:24 +010061cov: 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
70wipe-cov: wipe
71 @rm -rf $(BUILD_COV_DIR)
72
Klement Sekera277b89c2016-10-28 13:20:27 +020073help:
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 Sloboda0279b292016-11-16 19:50:24 +010080 @echo " test-wipe - wipe (temporary) files generated by unit tests"
Klement Sekera277b89c2016-10-28 13:20:27 +020081 @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 Sloboda0279b292016-11-16 19:50:24 +010096 @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 Sekera277b89c2016-10-28 13:20:27 +0200101 @echo ""