Adrian Villin | 688ac5a | 2024-05-10 04:19:35 -0400 | [diff] [blame] | 1 | export HS_ROOT=$(CURDIR) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 2 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 3 | ifeq ($(VERBOSE),) |
| 4 | VERBOSE=false |
| 5 | endif |
Maros Ondrejicka | 2ddb2fd | 2023-02-15 17:44:46 +0100 | [diff] [blame] | 6 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 7 | ifeq ($(PERSIST),) |
| 8 | PERSIST=false |
| 9 | endif |
| 10 | |
Maros Ondrejicka | af004dd | 2023-02-27 16:52:57 +0100 | [diff] [blame] | 11 | ifeq ($(UNCONFIGURE),) |
| 12 | UNCONFIGURE=false |
| 13 | endif |
| 14 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 15 | ifeq ($(TEST),) |
| 16 | TEST=all |
| 17 | endif |
| 18 | |
adrianvillin | 8512145 | 2024-01-11 11:59:47 +0100 | [diff] [blame] | 19 | ifeq ($(TEST-HS),) |
| 20 | TEST-HS=all |
| 21 | endif |
| 22 | |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 23 | ifeq ($(DEBUG),) |
| 24 | DEBUG=false |
| 25 | endif |
| 26 | |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 27 | ifeq ($(CPUS),) |
| 28 | CPUS=1 |
| 29 | endif |
| 30 | |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 31 | ifeq ($(PARALLEL),) |
| 32 | PARALLEL=1 |
| 33 | endif |
| 34 | |
Matus Fabian | bbee45c | 2024-04-22 19:47:27 +0200 | [diff] [blame] | 35 | ifeq ($(REPEAT),) |
| 36 | REPEAT=0 |
| 37 | endif |
| 38 | |
Filip Tehlar | 109f3ce | 2023-09-05 15:36:28 +0200 | [diff] [blame] | 39 | ifeq ($(VPPSRC),) |
| 40 | VPPSRC=$(shell pwd)/../.. |
| 41 | endif |
| 42 | |
Dave Wallace | 05120fb | 2023-03-07 22:09:20 -0500 | [diff] [blame] | 43 | ifeq ($(UBUNTU_CODENAME),) |
| 44 | UBUNTU_CODENAME=$(shell grep '^UBUNTU_CODENAME=' /etc/os-release | cut -f2- -d=) |
| 45 | endif |
| 46 | |
| 47 | ifeq ($(ARCH),) |
| 48 | ARCH=$(shell dpkg --print-architecture) |
| 49 | endif |
| 50 | |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 51 | list_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 Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 53 | |
| 54 | .PHONY: help |
| 55 | help: |
| 56 | @echo "Make targets:" |
| 57 | @echo " test - run tests" |
Matus Fabian | 2d1bc4c | 2024-05-09 10:46:58 +0200 | [diff] [blame] | 58 | @echo " test-debug - run tests (vpp debug image)" |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 59 | @echo " build - build test infra" |
adrianvillin | 8512145 | 2024-01-11 11:59:47 +0100 | [diff] [blame] | 60 | @echo " build-cov - coverage build of VPP and Docker images" |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 61 | @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 Tehlar | 31eaea9 | 2023-06-15 10:06:57 +0200 | [diff] [blame] | 66 | @echo "make build arguments:" |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 67 | @echo " UBUNTU_VERSION - ubuntu version for docker image" |
Filip Tehlar | 31eaea9 | 2023-06-15 10:06:57 +0200 | [diff] [blame] | 68 | @echo " HST_EXTENDED_TESTS - build extended tests" |
| 69 | @echo |
| 70 | @echo "make test arguments:" |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 71 | @echo " PERSIST=[true|false] - whether clean up topology and dockers after test" |
| 72 | @echo " VERBOSE=[true|false] - verbose output" |
Florin Coras | e2415f7 | 2023-02-28 14:51:03 -0800 | [diff] [blame] | 73 | @echo " UNCONFIGURE=[true|false] - unconfigure selected test" |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 74 | @echo " DEBUG=[true|false] - attach VPP to GDB" |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 75 | @echo " TEST=[test-name] - specific test to run" |
Adrian Villin | b9464cd | 2024-05-27 09:52:59 -0400 | [diff] [blame] | 76 | @echo " CPUS=[n-cpus] - number of cpus to allocate to VPP and containers" |
Filip Tehlar | 109f3ce | 2023-09-05 15:36:28 +0200 | [diff] [blame] | 77 | @echo " VPPSRC=[path-to-vpp-src] - path to vpp source files (for gdb)" |
Matus Fabian | bbee45c | 2024-04-22 19:47:27 +0200 | [diff] [blame] | 78 | @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 Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 80 | @echo |
| 81 | @echo "List of all tests:" |
| 82 | $(call list_tests) |
| 83 | |
| 84 | .PHONY: list-tests |
| 85 | list-tests: |
| 86 | $(call list_tests) |
| 87 | |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 88 | .PHONY: build-vpp-release |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 89 | build-vpp-release: |
Renato Botelho do Couto | 893daca | 2024-06-05 18:11:46 +0000 | [diff] [blame] | 90 | @$(MAKE) -C ../.. build-release |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 91 | |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 92 | .PHONY: build-vpp-debug |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 93 | build-vpp-debug: |
Renato Botelho do Couto | 893daca | 2024-06-05 18:11:46 +0000 | [diff] [blame] | 94 | @$(MAKE) -C ../.. build |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 95 | |
adrianvillin | 8512145 | 2024-01-11 11:59:47 +0100 | [diff] [blame] | 96 | .PHONY: build-vpp-gcov |
| 97 | build-vpp-gcov: |
Renato Botelho do Couto | 893daca | 2024-06-05 18:11:46 +0000 | [diff] [blame] | 98 | @$(MAKE) -C ../.. build-vpp-gcov |
adrianvillin | 8512145 | 2024-01-11 11:59:47 +0100 | [diff] [blame] | 99 | |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 100 | .build.ok: build |
| 101 | @touch .build.ok |
| 102 | |
Adrian Villin | f4972f9 | 2024-06-04 08:59:58 -0400 | [diff] [blame] | 103 | .build.cov.ok: build-vpp-gcov |
| 104 | @touch .build.cov.ok |
| 105 | |
Matus Fabian | 2d1bc4c | 2024-05-09 10:46:58 +0200 | [diff] [blame] | 106 | .build_debug.ok: build-debug |
| 107 | @touch .build.ok |
| 108 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 109 | .PHONY: test |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 110 | test: .deps.ok .build.ok |
Adrian Villin | 688ac5a | 2024-05-10 04:19:35 -0400 | [diff] [blame] | 111 | # '-' ignores the exit status, it is set in compress.sh |
| 112 | # necessary so gmake won't skip executing the bash script |
Adrian Villin | 637edda | 2024-05-06 06:55:34 -0400 | [diff] [blame] | 113 | -bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \ |
Filip Tehlar | 109f3ce | 2023-09-05 15:36:28 +0200 | [diff] [blame] | 114 | --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \ |
Matus Fabian | bbee45c | 2024-04-22 19:47:27 +0200 | [diff] [blame] | 115 | --vppsrc=$(VPPSRC) --parallel=$(PARALLEL) --repeat=$(REPEAT) |
Adrian Villin | 637edda | 2024-05-06 06:55:34 -0400 | [diff] [blame] | 116 | @bash ./script/compress.sh |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 117 | |
Matus Fabian | 2d1bc4c | 2024-05-09 10:46:58 +0200 | [diff] [blame] | 118 | .PHONY: test-debug |
| 119 | test-debug: .deps.ok .build_debug.ok |
Adrian Villin | 688ac5a | 2024-05-10 04:19:35 -0400 | [diff] [blame] | 120 | # '-' 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 Fabian | 2d1bc4c | 2024-05-09 10:46:58 +0200 | [diff] [blame] | 123 | --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \ |
| 124 | --vppsrc=$(VPPSRC) --parallel=$(PARALLEL) --repeat=$(REPEAT) |
Adrian Villin | 688ac5a | 2024-05-10 04:19:35 -0400 | [diff] [blame] | 125 | @bash ./script/compress.sh |
Matus Fabian | 2d1bc4c | 2024-05-09 10:46:58 +0200 | [diff] [blame] | 126 | |
adrianvillin | 8512145 | 2024-01-11 11:59:47 +0100 | [diff] [blame] | 127 | .PHONY: test-cov |
Adrian Villin | f4972f9 | 2024-06-04 08:59:58 -0400 | [diff] [blame] | 128 | test-cov: .deps.ok .build.cov.ok |
adrianvillin | 8512145 | 2024-01-11 11:59:47 +0100 | [diff] [blame] | 129 | -bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \ |
| 130 | --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST-HS) --cpus=$(CPUS) \ |
| 131 | --vppsrc=$(VPPSRC) |
Renato Botelho do Couto | 893daca | 2024-06-05 18:11:46 +0000 | [diff] [blame] | 132 | @$(MAKE) -C ../.. test-cov-post HS_TEST=1 |
adrianvillin | 8512145 | 2024-01-11 11:59:47 +0100 | [diff] [blame] | 133 | @bash ./script/compress.sh |
| 134 | |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 135 | .PHONY: build-go |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 136 | build-go: |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 137 | go build ./tools/http_server |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 138 | |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 139 | .PHONY: build |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 140 | build: .deps.ok build-vpp-release build-go |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 141 | @rm -f .build.ok |
Filip Tehlar | 31eaea9 | 2023-06-15 10:06:57 +0200 | [diff] [blame] | 142 | bash ./script/build_hst.sh release |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 143 | @touch .build.ok |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 144 | |
adrianvillin | 8512145 | 2024-01-11 11:59:47 +0100 | [diff] [blame] | 145 | .PHONY: build-cov |
| 146 | build-cov: .deps.ok build-vpp-gcov build-go |
Adrian Villin | f4972f9 | 2024-06-04 08:59:58 -0400 | [diff] [blame] | 147 | @rm -f .build.cov.ok |
adrianvillin | 8512145 | 2024-01-11 11:59:47 +0100 | [diff] [blame] | 148 | bash ./script/build_hst.sh gcov |
Adrian Villin | f4972f9 | 2024-06-04 08:59:58 -0400 | [diff] [blame] | 149 | @touch .build.cov.ok |
adrianvillin | 8512145 | 2024-01-11 11:59:47 +0100 | [diff] [blame] | 150 | |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 151 | .PHONY: build-debug |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 152 | build-debug: .deps.ok build-vpp-debug build-go |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 153 | @rm -f .build.ok |
Filip Tehlar | 31eaea9 | 2023-06-15 10:06:57 +0200 | [diff] [blame] | 154 | bash ./script/build_hst.sh debug |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 155 | @touch .build.ok |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 156 | |
Dave Wallace | d0df24d | 2023-04-26 18:03:03 -0400 | [diff] [blame] | 157 | .deps.ok: |
Renato Botelho do Couto | 893daca | 2024-06-05 18:11:46 +0000 | [diff] [blame] | 158 | @sudo $(MAKE) install-deps |
Dave Wallace | d0df24d | 2023-04-26 18:03:03 -0400 | [diff] [blame] | 159 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 160 | .PHONY: install-deps |
| 161 | install-deps: |
Dave Wallace | 05120fb | 2023-03-07 22:09:20 -0500 | [diff] [blame] | 162 | @rm -f .deps.ok |
Dave Wallace | f72bb6f | 2023-03-08 13:53:32 -0500 | [diff] [blame] | 163 | @apt-get update \ |
| 164 | && apt-get install -y apt-transport-https ca-certificates curl software-properties-common \ |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 165 | apache2-utils wrk bridge-utils |
Dave Wallace | f72bb6f | 2023-03-08 13:53:32 -0500 | [diff] [blame] | 166 | @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 Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 172 | @touch .deps.ok |
| 173 | |
| 174 | .PHONY: fixstyle |
Filip Tehlar | f3ee2b6 | 2023-01-09 12:07:09 +0100 | [diff] [blame] | 175 | fixstyle: |
| 176 | @gofmt -w . |
Maros Ondrejicka | 7d7ab10 | 2023-02-14 12:56:49 +0100 | [diff] [blame] | 177 | @go mod tidy |