hs-test: point gdb to vpp source files
[vpp.git] / extras / hs-test / Makefile
index 7460026..f0ec755 100644 (file)
@@ -7,10 +7,34 @@ ifeq ($(PERSIST),)
 PERSIST=false
 endif
 
+ifeq ($(UNCONFIGURE),)
+UNCONFIGURE=false
+endif
+
 ifeq ($(TEST),)
 TEST=all
 endif
 
+ifeq ($(DEBUG),)
+DEBUG=false
+endif
+
+ifeq ($(CPUS),)
+CPUS=1
+endif
+
+ifeq ($(VPPSRC),)
+VPPSRC=$(shell pwd)/../..
+endif
+
+ifeq ($(UBUNTU_CODENAME),)
+UBUNTU_CODENAME=$(shell grep '^UBUNTU_CODENAME=' /etc/os-release | cut -f2- -d=)
+endif
+
+ifeq ($(ARCH),)
+ARCH=$(shell dpkg --print-architecture)
+endif
+
 list_tests = @(grep -r ') Test' *_test.go | cut -d '*' -f2 | cut -d '(' -f1 | \
                tr -d ' ' | tr ')' '/' | sed 's/Suite//')
 
@@ -24,11 +48,18 @@ help:
        @echo " fixstyle             - format .go source files"
        @echo " list-tests           - list all tests"
        @echo
-       @echo "Make arguments:"
+       @echo "make build arguments:"
        @echo " UBUNTU_VERSION           - ubuntu version for docker image"
+       @echo " HST_EXTENDED_TESTS       - build extended tests"
+       @echo
+       @echo "make test arguments:"
        @echo " PERSIST=[true|false]     - whether clean up topology and dockers after test"
        @echo " VERBOSE=[true|false]     - verbose output"
+       @echo " UNCONFIGURE=[true|false] - unconfigure selected test"
+       @echo " DEBUG=[true|false]       - attach VPP to GDB"
        @echo " TEST=[test-name]         - specific test to run"
+       @echo " CPUS=[n-cpus]            - number of cpus to run with vpp"
+       @echo " VPPSRC=[path-to-vpp-src] - path to vpp source files (for gdb)"
        @echo
        @echo "List of all tests:"
        $(call list_tests)
@@ -45,29 +76,42 @@ build-vpp-debug:
 
 .PHONY: test
 test: .deps.ok .build.vpp
-       @bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) --test=$(TEST)
+       @bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \
+               --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \
+               --vppsrc=$(VPPSRC)
 
 build-go:
        go build ./tools/http_server
 
 build: .deps.ok build-vpp-release build-go
-       @rm .build.vpp || exit 0
-       bash ./script/build.sh release
+       @rm -f .build.vpp
+       bash ./script/build_hst.sh release
        @touch .build.vpp
 
 build-debug: .deps.ok build-vpp-debug build-go
-       @rm .build.vpp || exit 0
-       bash ./script/build.sh debug
+       @rm -f .build.vpp
+       bash ./script/build_hst.sh debug
        @touch .build.vpp
 
+.deps.ok:
+       @sudo make install-deps
+
 .PHONY: install-deps
 install-deps:
-       @rm .deps.ok || exit 0
-       @apt update -y && apt install -y golang docker-ce apache2-utils wrk bridge-utils
+       @rm -f .deps.ok
+       @apt-get update \
+               && apt-get install -y apt-transport-https ca-certificates curl software-properties-common \
+               && apt-get install -y golang apache2-utils wrk bridge-utils
+       @if [ ! -f /usr/share/keyrings/docker-archive-keyring.gpg ] ; then \
+               curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg; \
+               echo "deb [arch=$(ARCH) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(UBUNTU_CODENAME) stable" \
+                       | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null ; \
+               apt-get update; \
+       fi
+       @apt-get install -y docker-ce
        @touch .deps.ok
 
 .PHONY: fixstyle
 fixstyle:
        @gofmt -w .
        @go mod tidy
-