blob: d459d9d916cf671adb17b81577666cbaab087fab [file] [log] [blame]
Adrian Villin688ac5a2024-05-10 04:19:35 -04001export HS_ROOT=$(CURDIR)
Filip Tehlar229f5fc2022-08-09 14:44:47 +00002
Filip Tehlar671cf512023-01-31 10:34:18 +01003ifeq ($(VERBOSE),)
4VERBOSE=false
5endif
Maros Ondrejicka2ddb2fd2023-02-15 17:44:46 +01006
Filip Tehlar671cf512023-01-31 10:34:18 +01007ifeq ($(PERSIST),)
8PERSIST=false
9endif
10
Maros Ondrejickaaf004dd2023-02-27 16:52:57 +010011ifeq ($(UNCONFIGURE),)
12UNCONFIGURE=false
13endif
14
Filip Tehlar671cf512023-01-31 10:34:18 +010015ifeq ($(TEST),)
16TEST=all
17endif
18
adrianvillin85121452024-01-11 11:59:47 +010019ifeq ($(TEST-HS),)
20TEST-HS=all
21endif
22
Filip Tehlarec5c40b2023-02-28 18:59:15 +010023ifeq ($(DEBUG),)
24DEBUG=false
25endif
26
Filip Tehlar608d0062023-04-28 10:29:47 +020027ifeq ($(CPUS),)
28CPUS=1
29endif
30
Adrian Villincee15aa2024-03-14 11:42:55 -040031ifeq ($(PARALLEL),)
32PARALLEL=1
33endif
34
Matus Fabianbbee45c2024-04-22 19:47:27 +020035ifeq ($(REPEAT),)
36REPEAT=0
37endif
38
Filip Tehlar109f3ce2023-09-05 15:36:28 +020039ifeq ($(VPPSRC),)
40VPPSRC=$(shell pwd)/../..
41endif
42
Dave Wallace05120fb2023-03-07 22:09:20 -050043ifeq ($(UBUNTU_CODENAME),)
44UBUNTU_CODENAME=$(shell grep '^UBUNTU_CODENAME=' /etc/os-release | cut -f2- -d=)
45endif
46
47ifeq ($(ARCH),)
48ARCH=$(shell dpkg --print-architecture)
49endif
50
Adrian Villincee15aa2024-03-14 11:42:55 -040051list_tests = @go run github.com/onsi/ginkgo/v2/ginkgo --dry-run -v --no-color --seed=2 | head -n -1 | grep 'Test' | \
52 sed 's/^/* /; s/\(Suite\) /\1\//g'
Filip Tehlar671cf512023-01-31 10:34:18 +010053
54.PHONY: help
55help:
56 @echo "Make targets:"
57 @echo " test - run tests"
Matus Fabian2d1bc4c2024-05-09 10:46:58 +020058 @echo " test-debug - run tests (vpp debug image)"
Filip Tehlar671cf512023-01-31 10:34:18 +010059 @echo " build - build test infra"
adrianvillin85121452024-01-11 11:59:47 +010060 @echo " build-cov - coverage build of VPP and Docker images"
Filip Tehlar671cf512023-01-31 10:34:18 +010061 @echo " build-debug - build test infra (vpp debug image)"
62 @echo " build-go - just build golang files"
63 @echo " fixstyle - format .go source files"
64 @echo " list-tests - list all tests"
65 @echo
Filip Tehlar31eaea92023-06-15 10:06:57 +020066 @echo "make build arguments:"
Filip Tehlar671cf512023-01-31 10:34:18 +010067 @echo " UBUNTU_VERSION - ubuntu version for docker image"
Filip Tehlar31eaea92023-06-15 10:06:57 +020068 @echo " HST_EXTENDED_TESTS - build extended tests"
69 @echo
70 @echo "make test arguments:"
Filip Tehlar671cf512023-01-31 10:34:18 +010071 @echo " PERSIST=[true|false] - whether clean up topology and dockers after test"
72 @echo " VERBOSE=[true|false] - verbose output"
Florin Corase2415f72023-02-28 14:51:03 -080073 @echo " UNCONFIGURE=[true|false] - unconfigure selected test"
Filip Tehlarec5c40b2023-02-28 18:59:15 +010074 @echo " DEBUG=[true|false] - attach VPP to GDB"
Filip Tehlar671cf512023-01-31 10:34:18 +010075 @echo " TEST=[test-name] - specific test to run"
Adrian Villinb9464cd2024-05-27 09:52:59 -040076 @echo " CPUS=[n-cpus] - number of cpus to allocate to VPP and containers"
Filip Tehlar109f3ce2023-09-05 15:36:28 +020077 @echo " VPPSRC=[path-to-vpp-src] - path to vpp source files (for gdb)"
Matus Fabianbbee45c2024-04-22 19:47:27 +020078 @echo " PARALLEL=[n-cpus] - number of test processes to spawn to run in parallel"
79 @echo " REPEAT=[n] - repeat tests up to N times or until a failure occurs"
Filip Tehlar671cf512023-01-31 10:34:18 +010080 @echo
81 @echo "List of all tests:"
82 $(call list_tests)
83
84.PHONY: list-tests
85list-tests:
86 $(call list_tests)
87
Dave Wallace83b12bf2024-04-25 16:21:37 -040088.PHONY: build-vpp-release
Filip Tehlar671cf512023-01-31 10:34:18 +010089build-vpp-release:
Renato Botelho do Couto893daca2024-06-05 18:11:46 +000090 @$(MAKE) -C ../.. build-release
Filip Tehlar671cf512023-01-31 10:34:18 +010091
Dave Wallace83b12bf2024-04-25 16:21:37 -040092.PHONY: build-vpp-debug
Filip Tehlar671cf512023-01-31 10:34:18 +010093build-vpp-debug:
Renato Botelho do Couto893daca2024-06-05 18:11:46 +000094 @$(MAKE) -C ../.. build
Filip Tehlar671cf512023-01-31 10:34:18 +010095
adrianvillin85121452024-01-11 11:59:47 +010096.PHONY: build-vpp-gcov
97build-vpp-gcov:
Renato Botelho do Couto893daca2024-06-05 18:11:46 +000098 @$(MAKE) -C ../.. build-vpp-gcov
adrianvillin85121452024-01-11 11:59:47 +010099
Dave Wallace83b12bf2024-04-25 16:21:37 -0400100.build.ok: build
101 @touch .build.ok
102
Adrian Villinf4972f92024-06-04 08:59:58 -0400103.build.cov.ok: build-vpp-gcov
104 @touch .build.cov.ok
105
Matus Fabian2d1bc4c2024-05-09 10:46:58 +0200106.build_debug.ok: build-debug
107 @touch .build.ok
108
Filip Tehlar671cf512023-01-31 10:34:18 +0100109.PHONY: test
Dave Wallace83b12bf2024-04-25 16:21:37 -0400110test: .deps.ok .build.ok
Adrian Villin688ac5a2024-05-10 04:19:35 -0400111 # '-' ignores the exit status, it is set in compress.sh
112 # necessary so gmake won't skip executing the bash script
Adrian Villin637edda2024-05-06 06:55:34 -0400113 -bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \
Filip Tehlar109f3ce2023-09-05 15:36:28 +0200114 --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \
Matus Fabianbbee45c2024-04-22 19:47:27 +0200115 --vppsrc=$(VPPSRC) --parallel=$(PARALLEL) --repeat=$(REPEAT)
Adrian Villin637edda2024-05-06 06:55:34 -0400116 @bash ./script/compress.sh
Filip Tehlar671cf512023-01-31 10:34:18 +0100117
Matus Fabian2d1bc4c2024-05-09 10:46:58 +0200118.PHONY: test-debug
119test-debug: .deps.ok .build_debug.ok
Adrian Villin688ac5a2024-05-10 04:19:35 -0400120 # '-' ignores the exit status, it is set in compress.sh
121 # necessary so gmake won't skip executing the bash script
122 -bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \
Matus Fabian2d1bc4c2024-05-09 10:46:58 +0200123 --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \
124 --vppsrc=$(VPPSRC) --parallel=$(PARALLEL) --repeat=$(REPEAT)
Adrian Villin688ac5a2024-05-10 04:19:35 -0400125 @bash ./script/compress.sh
Matus Fabian2d1bc4c2024-05-09 10:46:58 +0200126
adrianvillin85121452024-01-11 11:59:47 +0100127.PHONY: test-cov
Adrian Villinf4972f92024-06-04 08:59:58 -0400128test-cov: .deps.ok .build.cov.ok
adrianvillin85121452024-01-11 11:59:47 +0100129 -bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \
130 --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST-HS) --cpus=$(CPUS) \
131 --vppsrc=$(VPPSRC)
Renato Botelho do Couto893daca2024-06-05 18:11:46 +0000132 @$(MAKE) -C ../.. test-cov-post HS_TEST=1
adrianvillin85121452024-01-11 11:59:47 +0100133 @bash ./script/compress.sh
134
Dave Wallace83b12bf2024-04-25 16:21:37 -0400135.PHONY: build-go
Filip Tehlar671cf512023-01-31 10:34:18 +0100136build-go:
Filip Tehlar229f5fc2022-08-09 14:44:47 +0000137 go build ./tools/http_server
Filip Tehlar229f5fc2022-08-09 14:44:47 +0000138
Dave Wallace83b12bf2024-04-25 16:21:37 -0400139.PHONY: build
Filip Tehlar671cf512023-01-31 10:34:18 +0100140build: .deps.ok build-vpp-release build-go
Dave Wallace83b12bf2024-04-25 16:21:37 -0400141 @rm -f .build.ok
Filip Tehlar31eaea92023-06-15 10:06:57 +0200142 bash ./script/build_hst.sh release
Dave Wallace83b12bf2024-04-25 16:21:37 -0400143 @touch .build.ok
Filip Tehlar229f5fc2022-08-09 14:44:47 +0000144
adrianvillin85121452024-01-11 11:59:47 +0100145.PHONY: build-cov
146build-cov: .deps.ok build-vpp-gcov build-go
Adrian Villinf4972f92024-06-04 08:59:58 -0400147 @rm -f .build.cov.ok
adrianvillin85121452024-01-11 11:59:47 +0100148 bash ./script/build_hst.sh gcov
Adrian Villinf4972f92024-06-04 08:59:58 -0400149 @touch .build.cov.ok
adrianvillin85121452024-01-11 11:59:47 +0100150
Dave Wallace83b12bf2024-04-25 16:21:37 -0400151.PHONY: build-debug
Filip Tehlar671cf512023-01-31 10:34:18 +0100152build-debug: .deps.ok build-vpp-debug build-go
Dave Wallace83b12bf2024-04-25 16:21:37 -0400153 @rm -f .build.ok
Filip Tehlar31eaea92023-06-15 10:06:57 +0200154 bash ./script/build_hst.sh debug
Dave Wallace83b12bf2024-04-25 16:21:37 -0400155 @touch .build.ok
Filip Tehlar671cf512023-01-31 10:34:18 +0100156
Dave Wallaced0df24d2023-04-26 18:03:03 -0400157.deps.ok:
Renato Botelho do Couto893daca2024-06-05 18:11:46 +0000158 @sudo $(MAKE) install-deps
Dave Wallaced0df24d2023-04-26 18:03:03 -0400159
Filip Tehlar671cf512023-01-31 10:34:18 +0100160.PHONY: install-deps
161install-deps:
Dave Wallace05120fb2023-03-07 22:09:20 -0500162 @rm -f .deps.ok
Dave Wallacef72bb6f2023-03-08 13:53:32 -0500163 @apt-get update \
164 && apt-get install -y apt-transport-https ca-certificates curl software-properties-common \
Dave Wallace83b12bf2024-04-25 16:21:37 -0400165 apache2-utils wrk bridge-utils
Dave Wallacef72bb6f2023-03-08 13:53:32 -0500166 @if [ ! -f /usr/share/keyrings/docker-archive-keyring.gpg ] ; then \
167 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg; \
168 echo "deb [arch=$(ARCH) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(UBUNTU_CODENAME) stable" \
169 | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null ; \
170 apt-get update; \
171 fi
Filip Tehlar671cf512023-01-31 10:34:18 +0100172 @touch .deps.ok
173
174.PHONY: fixstyle
Filip Tehlarf3ee2b62023-01-09 12:07:09 +0100175fixstyle:
176 @gofmt -w .
Maros Ondrejicka7d7ab102023-02-14 12:56:49 +0100177 @go mod tidy