refactor test framework

Change-Id: I31da3b1857b6399f9899276a2d99cdd19436296c
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Signed-off-by: Matej Klotton <mklotton@cisco.com>
Signed-off-by: Jan Gelety <jgelety@cisco.com>
Signed-off-by: Juraj Sloboda <jsloboda@cisco.com>
diff --git a/Makefile b/Makefile
index 93277be..54b0f29 100644
--- a/Makefile
+++ b/Makefile
@@ -188,37 +188,36 @@
 build-vpp-api: $(BR)/.bootstrap.ok
 	$(call make,$(PLATFORM)_debug,vpp-api-install)
 
+PYTHON_PATH=$(BR)/python
+
 define test
-	@make -C test \
-	  VPP_TEST_BIN=$(BR)/install-$(1)-native/vpp/bin/vpp \
-	  VPP_TEST_API_TEST_BIN=$(BR)/install-$(1)-native/vpp-api-test/bin/vpp_api_test \
-	  VPP_TEST_PLUGIN_PATH=$(BR)/install-$(1)-native/plugins/lib64/vpp_plugins \
-	  V=$(V) TEST=$(TEST)
+	$(if $(filter-out $(3),retest),make -C $(BR) PLATFORM=$(1) TAG=$(2) vpp-api-install plugins-install vpp-install vpp-api-test-install,)
+	make -C test \
+	  VPP_TEST_BIN=$(BR)/install-$(2)-native/vpp/bin/vpp \
+	  VPP_TEST_API_TEST_BIN=$(BR)/install-$(2)-native/vpp-api-test/bin/vpp_api_test \
+	  VPP_TEST_PLUGIN_PATH=$(BR)/install-$(2)-native/plugins/lib64/vpp_plugins \
+	  LD_LIBRARY_PATH=$(BR)/install-$(2)-native/vpp-api/lib64/ \
+	  WS_ROOT=$(WS_ROOT) I=$(I) V=$(V) TEST=$(TEST) PYTHON_PATH=$(PYTHON_PATH) $(3)
 endef
 
 test: bootstrap
-ifeq ($(OS_ID),ubuntu)
-	@if ! (dpkg -l python-dev python-scapy &> /dev/null); then \
-	  sudo -E apt-get $(CONFIRM) $(FORCE) install python-dev python-scapy; \
-	fi
-endif
-	@make -C $(BR) PLATFORM=vpp_lite TAG=vpp_lite vpp-api-install plugins-install vpp-install vpp-api-test-install
-	$(call test,vpp_lite)
+	$(call test,vpp_lite,vpp_lite,test)
 
 test-debug: bootstrap
-ifeq ($(OS_ID),ubuntu)
-	@if ! (dpkg -l python-dev python-scapy &> /dev/null); then \
-	  sudo -E apt-get $(CONFIRM) $(FORCE) install python-dev python-scapy; \
-	fi
-endif
-	@make -C $(BR) PLATFORM=vpp_lite TAG=vpp_lite_debug vpp-api-install plugins-install vpp-install vpp-api-test-install
-	$(call test,vpp_lite_debug)
+	$(call test,vpp_lite,vpp_lite_debug,test)
+
+test-doc:
+	make -C $(BR) PLATFORM=vpp_lite TAG=vpp_lite vpp-api-install plugins-install vpp-install vpp-api-test-install
+	make -C test PYTHON_PATH=$(PYTHON_PATH) LD_LIBRARY_PATH=$(BR)/install-vpp_lite-native/vpp-api/lib64/ doc
+
+test-clean:
+	make -C test clean
 
 retest:
-	$(call test,vpp_lite)
+	$(call test,vpp_lite,vpp_lite,retest)
 
 retest-debug:
-	$(call test,vpp_lite_debug)
+	$(call test,vpp_lite,vpp_lite_debug,retest)
 
 STARTUP_DIR ?= $(PWD)
 ifeq ("$(wildcard $(STARTUP_CONF))","")