hs-test: point gdb to vpp source files
[vpp.git] / extras / hs-test / Makefile
1
2 ifeq ($(VERBOSE),)
3 VERBOSE=false
4 endif
5
6 ifeq ($(PERSIST),)
7 PERSIST=false
8 endif
9
10 ifeq ($(UNCONFIGURE),)
11 UNCONFIGURE=false
12 endif
13
14 ifeq ($(TEST),)
15 TEST=all
16 endif
17
18 ifeq ($(DEBUG),)
19 DEBUG=false
20 endif
21
22 ifeq ($(CPUS),)
23 CPUS=1
24 endif
25
26 ifeq ($(VPPSRC),)
27 VPPSRC=$(shell pwd)/../..
28 endif
29
30 ifeq ($(UBUNTU_CODENAME),)
31 UBUNTU_CODENAME=$(shell grep '^UBUNTU_CODENAME=' /etc/os-release | cut -f2- -d=)
32 endif
33
34 ifeq ($(ARCH),)
35 ARCH=$(shell dpkg --print-architecture)
36 endif
37
38 list_tests = @(grep -r ') Test' *_test.go | cut -d '*' -f2 | cut -d '(' -f1 | \
39                 tr -d ' ' | tr ')' '/' | sed 's/Suite//')
40
41 .PHONY: help
42 help:
43         @echo "Make targets:"
44         @echo " test                 - run tests"
45         @echo " build                - build test infra"
46         @echo " build-debug          - build test infra (vpp debug image)"
47         @echo " build-go             - just build golang files"
48         @echo " fixstyle             - format .go source files"
49         @echo " list-tests           - list all tests"
50         @echo
51         @echo "make build arguments:"
52         @echo " UBUNTU_VERSION           - ubuntu version for docker image"
53         @echo " HST_EXTENDED_TESTS       - build extended tests"
54         @echo
55         @echo "make test arguments:"
56         @echo " PERSIST=[true|false]     - whether clean up topology and dockers after test"
57         @echo " VERBOSE=[true|false]     - verbose output"
58         @echo " UNCONFIGURE=[true|false] - unconfigure selected test"
59         @echo " DEBUG=[true|false]       - attach VPP to GDB"
60         @echo " TEST=[test-name]         - specific test to run"
61         @echo " CPUS=[n-cpus]            - number of cpus to run with vpp"
62         @echo " VPPSRC=[path-to-vpp-src] - path to vpp source files (for gdb)"
63         @echo
64         @echo "List of all tests:"
65         $(call list_tests)
66
67 .PHONY: list-tests
68 list-tests:
69         $(call list_tests)
70
71 build-vpp-release:
72         @make -C ../.. build-release
73
74 build-vpp-debug:
75         @make -C ../.. build
76
77 .PHONY: test
78 test: .deps.ok .build.vpp
79         @bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \
80                 --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \
81                 --vppsrc=$(VPPSRC)
82
83 build-go:
84         go build ./tools/http_server
85
86 build: .deps.ok build-vpp-release build-go
87         @rm -f .build.vpp
88         bash ./script/build_hst.sh release
89         @touch .build.vpp
90
91 build-debug: .deps.ok build-vpp-debug build-go
92         @rm -f .build.vpp
93         bash ./script/build_hst.sh debug
94         @touch .build.vpp
95
96 .deps.ok:
97         @sudo make install-deps
98
99 .PHONY: install-deps
100 install-deps:
101         @rm -f .deps.ok
102         @apt-get update \
103                 && apt-get install -y apt-transport-https ca-certificates curl software-properties-common \
104                 && apt-get install -y golang apache2-utils wrk bridge-utils
105         @if [ ! -f /usr/share/keyrings/docker-archive-keyring.gpg ] ; then \
106                 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg; \
107                 echo "deb [arch=$(ARCH) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(UBUNTU_CODENAME) stable" \
108                         | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null ; \
109                 apt-get update; \
110         fi
111         @apt-get install -y docker-ce
112         @touch .deps.ok
113
114 .PHONY: fixstyle
115 fixstyle:
116         @gofmt -w .
117         @go mod tidy