blob: e247bf4416014cc6be40cdea6e973dc107593d15 [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
Filip Tehlarec5c40b2023-02-28 18:59:15 +010019ifeq ($(DEBUG),)
20DEBUG=false
21endif
22
Filip Tehlar608d0062023-04-28 10:29:47 +020023ifeq ($(CPUS),)
24CPUS=1
25endif
26
Adrian Villincee15aa2024-03-14 11:42:55 -040027ifeq ($(PARALLEL),)
28PARALLEL=1
29endif
30
Matus Fabianbbee45c2024-04-22 19:47:27 +020031ifeq ($(REPEAT),)
32REPEAT=0
33endif
34
Filip Tehlar109f3ce2023-09-05 15:36:28 +020035ifeq ($(VPPSRC),)
36VPPSRC=$(shell pwd)/../..
37endif
38
Dave Wallace05120fb2023-03-07 22:09:20 -050039ifeq ($(UBUNTU_CODENAME),)
40UBUNTU_CODENAME=$(shell grep '^UBUNTU_CODENAME=' /etc/os-release | cut -f2- -d=)
41endif
42
43ifeq ($(ARCH),)
44ARCH=$(shell dpkg --print-architecture)
45endif
46
Adrian Villincee15aa2024-03-14 11:42:55 -040047list_tests = @go run github.com/onsi/ginkgo/v2/ginkgo --dry-run -v --no-color --seed=2 | head -n -1 | grep 'Test' | \
48 sed 's/^/* /; s/\(Suite\) /\1\//g'
Filip Tehlar671cf512023-01-31 10:34:18 +010049
50.PHONY: help
51help:
52 @echo "Make targets:"
53 @echo " test - run tests"
Matus Fabian2d1bc4c2024-05-09 10:46:58 +020054 @echo " test-debug - run tests (vpp debug image)"
Filip Tehlar671cf512023-01-31 10:34:18 +010055 @echo " build - build test infra"
56 @echo " build-debug - build test infra (vpp debug image)"
57 @echo " build-go - just build golang files"
58 @echo " fixstyle - format .go source files"
59 @echo " list-tests - list all tests"
60 @echo
Filip Tehlar31eaea92023-06-15 10:06:57 +020061 @echo "make build arguments:"
Filip Tehlar671cf512023-01-31 10:34:18 +010062 @echo " UBUNTU_VERSION - ubuntu version for docker image"
Filip Tehlar31eaea92023-06-15 10:06:57 +020063 @echo " HST_EXTENDED_TESTS - build extended tests"
64 @echo
65 @echo "make test arguments:"
Filip Tehlar671cf512023-01-31 10:34:18 +010066 @echo " PERSIST=[true|false] - whether clean up topology and dockers after test"
67 @echo " VERBOSE=[true|false] - verbose output"
Florin Corase2415f72023-02-28 14:51:03 -080068 @echo " UNCONFIGURE=[true|false] - unconfigure selected test"
Filip Tehlarec5c40b2023-02-28 18:59:15 +010069 @echo " DEBUG=[true|false] - attach VPP to GDB"
Filip Tehlar671cf512023-01-31 10:34:18 +010070 @echo " TEST=[test-name] - specific test to run"
Filip Tehlar608d0062023-04-28 10:29:47 +020071 @echo " CPUS=[n-cpus] - number of cpus to run with vpp"
Filip Tehlar109f3ce2023-09-05 15:36:28 +020072 @echo " VPPSRC=[path-to-vpp-src] - path to vpp source files (for gdb)"
Matus Fabianbbee45c2024-04-22 19:47:27 +020073 @echo " PARALLEL=[n-cpus] - number of test processes to spawn to run in parallel"
74 @echo " REPEAT=[n] - repeat tests up to N times or until a failure occurs"
Filip Tehlar671cf512023-01-31 10:34:18 +010075 @echo
76 @echo "List of all tests:"
77 $(call list_tests)
78
79.PHONY: list-tests
80list-tests:
81 $(call list_tests)
82
Dave Wallace83b12bf2024-04-25 16:21:37 -040083.PHONY: build-vpp-release
Filip Tehlar671cf512023-01-31 10:34:18 +010084build-vpp-release:
85 @make -C ../.. build-release
86
Dave Wallace83b12bf2024-04-25 16:21:37 -040087.PHONY: build-vpp-debug
Filip Tehlar671cf512023-01-31 10:34:18 +010088build-vpp-debug:
89 @make -C ../.. build
90
Dave Wallace83b12bf2024-04-25 16:21:37 -040091.build.ok: build
92 @touch .build.ok
93
Matus Fabian2d1bc4c2024-05-09 10:46:58 +020094.build_debug.ok: build-debug
95 @touch .build.ok
96
Filip Tehlar671cf512023-01-31 10:34:18 +010097.PHONY: test
Dave Wallace83b12bf2024-04-25 16:21:37 -040098test: .deps.ok .build.ok
Adrian Villin688ac5a2024-05-10 04:19:35 -040099 # '-' ignores the exit status, it is set in compress.sh
100 # necessary so gmake won't skip executing the bash script
Adrian Villin637edda2024-05-06 06:55:34 -0400101 -bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \
Filip Tehlar109f3ce2023-09-05 15:36:28 +0200102 --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \
Matus Fabianbbee45c2024-04-22 19:47:27 +0200103 --vppsrc=$(VPPSRC) --parallel=$(PARALLEL) --repeat=$(REPEAT)
Adrian Villin637edda2024-05-06 06:55:34 -0400104 @bash ./script/compress.sh
Filip Tehlar671cf512023-01-31 10:34:18 +0100105
Matus Fabian2d1bc4c2024-05-09 10:46:58 +0200106.PHONY: test-debug
107test-debug: .deps.ok .build_debug.ok
Adrian Villin688ac5a2024-05-10 04:19:35 -0400108 # '-' ignores the exit status, it is set in compress.sh
109 # necessary so gmake won't skip executing the bash script
110 -bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \
Matus Fabian2d1bc4c2024-05-09 10:46:58 +0200111 --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \
112 --vppsrc=$(VPPSRC) --parallel=$(PARALLEL) --repeat=$(REPEAT)
Adrian Villin688ac5a2024-05-10 04:19:35 -0400113 @bash ./script/compress.sh
Matus Fabian2d1bc4c2024-05-09 10:46:58 +0200114
Dave Wallace83b12bf2024-04-25 16:21:37 -0400115.PHONY: build-go
Filip Tehlar671cf512023-01-31 10:34:18 +0100116build-go:
Filip Tehlar229f5fc2022-08-09 14:44:47 +0000117 go build ./tools/http_server
Filip Tehlar229f5fc2022-08-09 14:44:47 +0000118
Dave Wallace83b12bf2024-04-25 16:21:37 -0400119.PHONY: build
Filip Tehlar671cf512023-01-31 10:34:18 +0100120build: .deps.ok build-vpp-release build-go
Dave Wallace83b12bf2024-04-25 16:21:37 -0400121 @rm -f .build.ok
Filip Tehlar31eaea92023-06-15 10:06:57 +0200122 bash ./script/build_hst.sh release
Dave Wallace83b12bf2024-04-25 16:21:37 -0400123 @touch .build.ok
Filip Tehlar229f5fc2022-08-09 14:44:47 +0000124
Dave Wallace83b12bf2024-04-25 16:21:37 -0400125.PHONY: build-debug
Filip Tehlar671cf512023-01-31 10:34:18 +0100126build-debug: .deps.ok build-vpp-debug build-go
Dave Wallace83b12bf2024-04-25 16:21:37 -0400127 @rm -f .build.ok
Filip Tehlar31eaea92023-06-15 10:06:57 +0200128 bash ./script/build_hst.sh debug
Dave Wallace83b12bf2024-04-25 16:21:37 -0400129 @touch .build.ok
Filip Tehlar671cf512023-01-31 10:34:18 +0100130
Dave Wallaced0df24d2023-04-26 18:03:03 -0400131.deps.ok:
132 @sudo make install-deps
133
Filip Tehlar671cf512023-01-31 10:34:18 +0100134.PHONY: install-deps
135install-deps:
Dave Wallace05120fb2023-03-07 22:09:20 -0500136 @rm -f .deps.ok
Dave Wallacef72bb6f2023-03-08 13:53:32 -0500137 @apt-get update \
138 && apt-get install -y apt-transport-https ca-certificates curl software-properties-common \
Dave Wallace83b12bf2024-04-25 16:21:37 -0400139 apache2-utils wrk bridge-utils
Dave Wallacef72bb6f2023-03-08 13:53:32 -0500140 @if [ ! -f /usr/share/keyrings/docker-archive-keyring.gpg ] ; then \
141 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg; \
142 echo "deb [arch=$(ARCH) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(UBUNTU_CODENAME) stable" \
143 | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null ; \
144 apt-get update; \
145 fi
Filip Tehlar671cf512023-01-31 10:34:18 +0100146 @touch .deps.ok
147
148.PHONY: fixstyle
Filip Tehlarf3ee2b62023-01-09 12:07:09 +0100149fixstyle:
150 @gofmt -w .
Maros Ondrejicka7d7ab102023-02-14 12:56:49 +0100151 @go mod tidy