tests: add vpp test dirs to PYTHONPATH
- Required to relocate test infra modules to be co-located in feature test directory. - Remove/regenerate build-root/build-test/src/ soft links when running make test to allow re-running 'make test' after moving source files. - Suppress annoying 'ls' error message when gathering test source files caused by 'c' test application directory being named 'test'. - Use PYTHONPYCACHEPREFIX to generate all compiled source under build-root/build-test. This only works for python 3.8 or greater, but existing 'make test-wipe' target cleans up in-situ __pycache__ directories for older python versions. Type: fix Change-Id: If3c3ff0c58fb26a17395babc34783e06b1dd84e7 Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
This commit is contained in:

committed by
Andrew Yourtchenko

parent
da282b5d08
commit
fd243741e0
@@ -20,7 +20,7 @@ FAILED_DIR=/tmp/vpp-failed-unittests/
|
||||
PLUGIN_TEST_DIRS=$(shell find $(PLUGIN_SRC_DIR) -type d -name test -exec echo -n " -d {}" \;)
|
||||
CORE_TEST_DIRS=$(shell find $(WS_ROOT)/src -not \( -path $(INTERN_PLUGIN_SRC_DIR) -prune \) -type d -name test -exec echo -n " -d {}" \;)
|
||||
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; done)
|
||||
VPP_TEST_SRC=$(shell for dir in $(VPP_TEST_DIRS) ; do ls $$dir/*.py 2>/dev/null; done)
|
||||
|
||||
.PHONY: verify-no-running-vpp
|
||||
|
||||
@@ -98,6 +98,11 @@ else
|
||||
PYTHON_INTERP=$(PYTHON)
|
||||
endif
|
||||
|
||||
empty:=
|
||||
space:= $(empty) $(empty)
|
||||
export PYTHONPATH=$(subst $(space),:,$(VPP_TEST_DIRS))
|
||||
export PYTHONPYCACHEPREFIX=$(TEST_BR)/pycache
|
||||
|
||||
PYTHON_VERSION=$(shell $(PYTHON_INTERP) -c 'import sys; print(sys.version_info.major)')
|
||||
PIP_VERSION=20.1.1
|
||||
# Keep in sync with requirements.txt
|
||||
@@ -177,7 +182,7 @@ SANITY_IMPORT_VPP_PAPI_CMD=true
|
||||
SANITY_RUN_VPP_CMD=true
|
||||
else
|
||||
SANITY_IMPORT_VPP_PAPI_CMD=source $(VENV_PATH)/bin/activate && $(PYTHON_INTERP) $(BUILD_TEST_SRC)/sanity_import_vpp_papi.py
|
||||
SANITY_RUN_VPP_CMD=source $(VENV_PATH)/bin/activate && PYTHONPATH=$(BUILD_TEST_SRC) $(PYTHON_INTERP) $(BUILD_TEST_SRC)/sanity_run_vpp.py
|
||||
SANITY_RUN_VPP_CMD=source $(VENV_PATH)/bin/activate && $(PYTHON_INTERP) $(BUILD_TEST_SRC)/sanity_run_vpp.py
|
||||
endif
|
||||
|
||||
ifndef TEST_JOBS
|
||||
@@ -217,6 +222,7 @@ ext-test-apps:
|
||||
make -C ext test-apps
|
||||
|
||||
$(BUILD_TEST_SRC): verify-env
|
||||
@rm -rf $@
|
||||
@mkdir -p $@
|
||||
@for file in $(VPP_TEST_SRC); do if [ ! -L $$file ] && [ ! -e $(BUILD_TEST_SRC)/$$(basename $$file) ] ; then ln -s $$file $(BUILD_TEST_SRC) ; fi ; done
|
||||
|
||||
@@ -238,10 +244,10 @@ retest: verify-env sanity $(FAILED_DIR)
|
||||
shell: test-dep
|
||||
@echo "source $(VENV_PATH)/bin/activate;\
|
||||
cd $(BUILD_TEST_SRC);\
|
||||
export PYTHONPATH=$(BUILD_TEST_SRC);\
|
||||
export PYTHONPATH=$(PYTHONPATH);\
|
||||
export RND_SEED=$(RND_SEED);\
|
||||
echo '***';\
|
||||
echo PYTHONPATH=$(BUILD_TEST_SRC);\
|
||||
echo PYTHONPATH=$(PYTHONPATH);\
|
||||
echo RND_SEED=$(RND_SEED);\
|
||||
echo VPP_BUILD_DIR=$(VPP_BUILD_DIR);\
|
||||
echo VPP_BIN=$(VPP_BIN);\
|
||||
|
Reference in New Issue
Block a user