From c160ae0dca8cde1b4690b0eea3b972cbff3f4128 Mon Sep 17 00:00:00 2001 From: Klement Sekera Date: Thu, 9 Mar 2017 08:20:13 +0100 Subject: make test: automatic sanity check Check if vpp_papi is importable before running the tests to avoid confusing python crashes. Change-Id: I6adf406e353bf381d590f2ef988a1ea79b95cf37 Signed-off-by: Klement Sekera --- test/Makefile | 16 ++++++++++++++-- test/sanity_import_vpp_papi.py | 4 ++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 test/sanity_import_vpp_papi.py diff --git a/test/Makefile b/test/Makefile index 02149803667..8594633ba8e 100644 --- a/test/Makefile +++ b/test/Makefile @@ -62,10 +62,22 @@ define retest-func @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && python run_tests.py discover $(UNITTEST_EXTRA_OPTS) -p test_\"*.py\"" endef -test: verify-python-path verify-no-running-vpp reset $(PAPI_INSTALL_DONE) +.PHONY: sanity + +sanity: verify-no-running-vpp + @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && python sanity_import_vpp_papi.py ||\ + (echo \"*******************************************************************\" &&\ + echo \"* Sanity check failed, cannot import vpp_papi\" &&\ + echo \"* to debug: \" &&\ + echo \"* 1. enter test shell: make test-shell\" &&\ + echo \"* 2. execute debugger: gdb python -ex 'run sanity_import_vpp_papi.py'\" &&\ + echo \"*******************************************************************\" &&\ + false)" + +test: verify-python-path $(PAPI_INSTALL_DONE) sanity reset $(call retest-func) -retest: verify-python-path verify-no-running-vpp reset +retest: verify-python-path sanity reset $(call retest-func) shell: verify-python-path $(PAPI_INSTALL_DONE) diff --git a/test/sanity_import_vpp_papi.py b/test/sanity_import_vpp_papi.py new file mode 100644 index 00000000000..535e00c9967 --- /dev/null +++ b/test/sanity_import_vpp_papi.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python + +""" sanity check script """ +import vpp_papi -- cgit 1.2.3-korg