aboutsummaryrefslogtreecommitdiffstats
path: root/test/Makefile
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2021-03-16 12:52:12 +0100
committerOle Tr�an <otroan@employees.org>2021-04-12 10:11:36 +0000
commite263685ac82454c39eee6e2a2146dd1e02d61de8 (patch)
tree54110ae98ed5618a057859019d518ed35e76423a /test/Makefile
parent3ff6ffce032544b4ffc3e42b5e069243681ae751 (diff)
tests: support attaching to existing vpp
Introduce a new option DEBUG=attach to run a test against existing already running vpp. A new target 'make test-start-gdb' will spawn VPP in gdb for this purpose. Customization options explained in test-help. Type: improvement Change-Id: Ia160a85b33da3b2df292d44bb95729af9dd9da96 Signed-off-by: Klement Sekera <ksekera@cisco.com>
Diffstat (limited to 'test/Makefile')
-rw-r--r--test/Makefile53
1 files changed, 28 insertions, 25 deletions
diff --git a/test/Makefile b/test/Makefile
index d4d74bb62b4..dc6aa096dd0 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -22,14 +22,7 @@ CORE_TEST_DIRS=$(shell find $(WS_ROOT)/src -not \( -path $(INTERN_PLUGIN_SRC_DIR
VPP_TEST_DIRS=$(shell ls -d $(TEST_DIR)$(PLUGIN_TEST_DIRS)$(CORE_TEST_DIRS) $(EXTERN_TESTS))
VPP_TEST_SRC=$(shell for dir in $(VPP_TEST_DIRS) ; do ls $$dir/*.py 2>/dev/null; done)
-.PHONY: verify-no-running-vpp
-
-ifdef VPP_ZOMBIE_NOCHECK
-VPP_PIDS=
-else
-VPP_PIDS=$(shell pgrep -d, -x vpp_main)
-endif
-
+FORCE_NO_WIPE=0
ifeq ($(DEBUG),gdb)
FORCE_FOREGROUND=1
else ifeq ($(DEBUG),gdbserver)
@@ -40,6 +33,9 @@ else ifeq ($(DEBUG),gdbserver-all)
FORCE_FOREGROUND=1
else ifeq ($(DEBUG),core)
FORCE_FOREGROUND=1
+else ifeq ($(DEBUG),attach)
+FORCE_FOREGROUND=1
+FORCE_NO_WIPE=1
else ifeq ($(STEP),yes)
FORCE_FOREGROUND=1
else ifeq ($(STEP),y)
@@ -63,16 +59,6 @@ PYTHON_PROFILE_OPTS=-m cProfile $(PROFILE_OUTPUT_OPTS) -s $(PROFILE_SORT_BY)
FORCE_FOREGROUND=1
endif
-verify-no-running-vpp:
- @if [ "$(VPP_PIDS)" != "" ]; then \
- echo; \
- echo "*** Existing vpp processes detected (PID(s): $(VPP_PIDS)). Running tests under these conditions is not supported. ***"; \
- echo; \
- ps -fp $(VPP_PIDS);\
- echo; \
- false; \
- fi
-
UNITTEST_EXTRA_OPTS=
UNITTEST_FAILFAST_OPTS=
@@ -172,7 +158,7 @@ PLUGIN_SRC_DIR=$(INTERN_PLUGIN_SRC_DIR)
endif
define retest-func
-@env FORCE_FOREGROUND=$(FORCE_FOREGROUND) FAILED_DIR=$(FAILED_DIR) VENV_PATH=$(VENV_PATH) scripts/setsid_wrapper.sh $(FORCE_FOREGROUND) $(VENV_PATH)/bin/activate $(PYTHON_INTERP) $(PYTHON_PROFILE_OPTS) $(BUILD_TEST_SRC)/run_tests.py -d $(BUILD_TEST_SRC) $(UNITTEST_EXTRA_OPTS) || env FAILED_DIR=$(FAILED_DIR) COMPRESS_FAILED_TEST_LOGS=$(COMPRESS_FAILED_TEST_LOGS) scripts/compress_failed.sh
+@env VPP_IN_GDB=$(VPP_IN_GDB) FORCE_FOREGROUND=$(FORCE_FOREGROUND) FAILED_DIR=$(FAILED_DIR) VENV_PATH=$(VENV_PATH) scripts/setsid_wrapper.sh $(FORCE_FOREGROUND) $(VENV_PATH)/bin/activate $(PYTHON_INTERP) $(PYTHON_PROFILE_OPTS) $(BUILD_TEST_SRC)/run_tests.py -d $(BUILD_TEST_SRC) $(UNITTEST_EXTRA_OPTS) || env FAILED_DIR=$(FAILED_DIR) COMPRESS_FAILED_TEST_LOGS=$(COMPRESS_FAILED_TEST_LOGS) scripts/compress_failed.sh
endef
.PHONY: sanity
@@ -197,7 +183,7 @@ else
PARALLEL_ILLEGAL=1
endif
-sanity: test-dep verify-no-running-vpp
+sanity: test-dep
@bash -c "test $(PARALLEL_ILLEGAL) -eq 0 ||\
(echo \"*******************************************************************\" &&\
echo \"* Sanity check failed, TEST_JOBS is not 1 or 'auto' and DEBUG, STEP or PROFILE is set\" &&\
@@ -264,7 +250,7 @@ shell: test-dep
.PHONY: reset
reset:
@rm -f /dev/shm/vpp-unittest-*
- @rm -rf /tmp/vpp-unittest-*
+ @if [ $(FORCE_NO_WIPE) -eq "0" ] ; then rm -rf /tmp/vpp-unittest-*; fi
@rm -f /tmp/api_post_mortem.*
@rm -rf $(FAILED_DIR)
@@ -333,6 +319,12 @@ checkstyle-diff: $(BUILD_TEST_SRC) $(PIP_INSTALL_DONE)
@echo "* Test framework PEP8 compliance check passed (checked changed files)"
@echo "*********************************************************************"
+.PHONY: start-gdb
+start-gdb: sanity
+ $(eval VPP_IN_GDB=1)
+ $(eval FORCE_FOREGROUND=1)
+ $(call retest-func)
+
.PHONY: checkstyle
checkstyle: $(BUILD_TEST_SRC) $(PIP_INSTALL_DONE)
@bash -c "source $(VENV_PATH)/bin/activate &&\
@@ -361,7 +353,6 @@ help:
@echo " retest-all-debug - run functional and extended tests (debug build)"
@echo " test-cov - generate code coverage report for test framework"
@echo " test-gcov - build and run functional tests (gcov build)"
-
@echo " test-wipe - wipe (temporary) files generated by unit tests"
@echo " test-wipe-cov - wipe code coverage report for test framework"
@echo " test-wipe-doc - wipe documentation for test framework"
@@ -369,8 +360,8 @@ help:
@echo " test-wipe-all - wipe (temporary) files generated by unit tests, docs, and coverage"
@echo " test-shell - enter shell with test environment"
@echo " test-shell-debug - enter shell with test environment (debug build)"
- @echo " test-checkstyle - check PEP8 compliance for test framework"
- @echo " test-refresh-deps - refresh the Python dependencies for the tests"
+ @echo " test-checkstyle - check PEP8 compliance for test framework"
+ @echo " test-refresh-deps - refresh the Python dependencies for the tests"
@echo ""
@echo "Arguments controlling test runs:"
@echo " V=[0|1|2] - set test verbosity level"
@@ -387,6 +378,8 @@ help:
@echo " and tearing down a testcase"
@echo " DEBUG=gdbserver - run gdb inside a gdb server, otherwise"
@echo " same as above"
+ @echo " DEBUG=attach - attach test case to already running vpp in gdb (see test-start-vpp-in-gdb)"
+ @echo ""
@echo " STEP=[yes|no] - ease debugging by stepping through a testcase"
@echo " SANITY=[yes|no] - perform sanity import of vpp-api/sanity vpp run before running tests (default: yes)"
@echo " EXTENDED_TESTS=[1|y] - used by '[re]test-all' & '[re]test-all-debug' to run extended tests"
@@ -404,7 +397,6 @@ help:
@echo " e.g. VARIANT=skx test the skx march variants"
@echo " e.g. VARIANT=icl test the icl march variants"
@echo ""
- @echo " VPP_ZOMBIE_NOCHECK=1 - skip checking for vpp (zombie) processes (CAUTION)"
@echo " COREDUMP_SIZE=<size> - pass <size> as unix { coredump-size <size> } argument to vpp"
@echo " e.g. COREDUMP_SIZE=4g"
@echo " COREDUMP_SIZE=unlimited"
@@ -423,6 +415,17 @@ help:
@echo ""
@echo " RND_SEED=seed - Seed RND with given seed"
@echo ""
+ @echo "Starting VPP in GDB for use with DEBUG=attach:"
+ @echo ""
+ @echo " test-start-vpp-in-gdb - start VPP in gdb (release)"
+ @echo " test-start-vpp-debug-in-gdb - start VPP in gdb (debug)"
+ @echo ""
+ @echo "Arguments controlling VPP in GDB runs:"
+ @echo " "
+ @echo " VPP_IN_GDB_TMP_DIR - specify directory to run VPP IN (default: /tmp/unittest-attach-gdb)"
+ @echo " VPP_IN_GDB_NO_RMDIR=0 - don't remove existing tmp dir but fail instead"
+ @echo " VPP_IN_GDB_CMDLINE=1 - add 'interactive' to VPP arguments to run with command line"
+ @echo ""
@echo "Creating test documentation"
@echo " test-doc - generate documentation for test framework"
@echo " test-wipe-doc - wipe documentation for test framework"