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 | |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 19 | ifeq ($(DEBUG),) |
| 20 | DEBUG=false |
| 21 | endif |
| 22 | |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 23 | ifeq ($(CPUS),) |
| 24 | CPUS=1 |
| 25 | endif |
| 26 | |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 27 | ifeq ($(PARALLEL),) |
| 28 | PARALLEL=1 |
| 29 | endif |
| 30 | |
Matus Fabian | bbee45c | 2024-04-22 19:47:27 +0200 | [diff] [blame] | 31 | ifeq ($(REPEAT),) |
| 32 | REPEAT=0 |
| 33 | endif |
| 34 | |
Filip Tehlar | 109f3ce | 2023-09-05 15:36:28 +0200 | [diff] [blame] | 35 | ifeq ($(VPPSRC),) |
| 36 | VPPSRC=$(shell pwd)/../.. |
| 37 | endif |
| 38 | |
Dave Wallace | 05120fb | 2023-03-07 22:09:20 -0500 | [diff] [blame] | 39 | ifeq ($(UBUNTU_CODENAME),) |
| 40 | UBUNTU_CODENAME=$(shell grep '^UBUNTU_CODENAME=' /etc/os-release | cut -f2- -d=) |
| 41 | endif |
| 42 | |
| 43 | ifeq ($(ARCH),) |
| 44 | ARCH=$(shell dpkg --print-architecture) |
| 45 | endif |
| 46 | |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 47 | list_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 Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 49 | |
| 50 | .PHONY: help |
| 51 | help: |
| 52 | @echo "Make targets:" |
| 53 | @echo " test - run tests" |
Matus Fabian | 2d1bc4c | 2024-05-09 10:46:58 +0200 | [diff] [blame] | 54 | @echo " test-debug - run tests (vpp debug image)" |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 55 | @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 Tehlar | 31eaea9 | 2023-06-15 10:06:57 +0200 | [diff] [blame] | 61 | @echo "make build arguments:" |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 62 | @echo " UBUNTU_VERSION - ubuntu version for docker image" |
Filip Tehlar | 31eaea9 | 2023-06-15 10:06:57 +0200 | [diff] [blame] | 63 | @echo " HST_EXTENDED_TESTS - build extended tests" |
| 64 | @echo |
| 65 | @echo "make test arguments:" |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 66 | @echo " PERSIST=[true|false] - whether clean up topology and dockers after test" |
| 67 | @echo " VERBOSE=[true|false] - verbose output" |
Florin Coras | e2415f7 | 2023-02-28 14:51:03 -0800 | [diff] [blame] | 68 | @echo " UNCONFIGURE=[true|false] - unconfigure selected test" |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 69 | @echo " DEBUG=[true|false] - attach VPP to GDB" |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 70 | @echo " TEST=[test-name] - specific test to run" |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 71 | @echo " CPUS=[n-cpus] - number of cpus to run with vpp" |
Filip Tehlar | 109f3ce | 2023-09-05 15:36:28 +0200 | [diff] [blame] | 72 | @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] | 73 | @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 Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 75 | @echo |
| 76 | @echo "List of all tests:" |
| 77 | $(call list_tests) |
| 78 | |
| 79 | .PHONY: list-tests |
| 80 | list-tests: |
| 81 | $(call list_tests) |
| 82 | |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 83 | .PHONY: build-vpp-release |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 84 | build-vpp-release: |
| 85 | @make -C ../.. build-release |
| 86 | |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 87 | .PHONY: build-vpp-debug |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 88 | build-vpp-debug: |
| 89 | @make -C ../.. build |
| 90 | |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 91 | .build.ok: build |
| 92 | @touch .build.ok |
| 93 | |
Matus Fabian | 2d1bc4c | 2024-05-09 10:46:58 +0200 | [diff] [blame] | 94 | .build_debug.ok: build-debug |
| 95 | @touch .build.ok |
| 96 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 97 | .PHONY: test |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 98 | test: .deps.ok .build.ok |
Adrian Villin | 688ac5a | 2024-05-10 04:19:35 -0400 | [diff] [blame] | 99 | # '-' ignores the exit status, it is set in compress.sh |
| 100 | # necessary so gmake won't skip executing the bash script |
Adrian Villin | 637edda | 2024-05-06 06:55:34 -0400 | [diff] [blame] | 101 | -bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \ |
Filip Tehlar | 109f3ce | 2023-09-05 15:36:28 +0200 | [diff] [blame] | 102 | --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \ |
Matus Fabian | bbee45c | 2024-04-22 19:47:27 +0200 | [diff] [blame] | 103 | --vppsrc=$(VPPSRC) --parallel=$(PARALLEL) --repeat=$(REPEAT) |
Adrian Villin | 637edda | 2024-05-06 06:55:34 -0400 | [diff] [blame] | 104 | @bash ./script/compress.sh |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 105 | |
Matus Fabian | 2d1bc4c | 2024-05-09 10:46:58 +0200 | [diff] [blame] | 106 | .PHONY: test-debug |
| 107 | test-debug: .deps.ok .build_debug.ok |
Adrian Villin | 688ac5a | 2024-05-10 04:19:35 -0400 | [diff] [blame] | 108 | # '-' 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 Fabian | 2d1bc4c | 2024-05-09 10:46:58 +0200 | [diff] [blame] | 111 | --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \ |
| 112 | --vppsrc=$(VPPSRC) --parallel=$(PARALLEL) --repeat=$(REPEAT) |
Adrian Villin | 688ac5a | 2024-05-10 04:19:35 -0400 | [diff] [blame] | 113 | @bash ./script/compress.sh |
Matus Fabian | 2d1bc4c | 2024-05-09 10:46:58 +0200 | [diff] [blame] | 114 | |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 115 | .PHONY: build-go |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 116 | build-go: |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 117 | go build ./tools/http_server |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 118 | |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 119 | .PHONY: build |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 120 | build: .deps.ok build-vpp-release build-go |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 121 | @rm -f .build.ok |
Filip Tehlar | 31eaea9 | 2023-06-15 10:06:57 +0200 | [diff] [blame] | 122 | bash ./script/build_hst.sh release |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 123 | @touch .build.ok |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 124 | |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 125 | .PHONY: build-debug |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 126 | build-debug: .deps.ok build-vpp-debug build-go |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 127 | @rm -f .build.ok |
Filip Tehlar | 31eaea9 | 2023-06-15 10:06:57 +0200 | [diff] [blame] | 128 | bash ./script/build_hst.sh debug |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 129 | @touch .build.ok |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 130 | |
Dave Wallace | d0df24d | 2023-04-26 18:03:03 -0400 | [diff] [blame] | 131 | .deps.ok: |
| 132 | @sudo make install-deps |
| 133 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 134 | .PHONY: install-deps |
| 135 | install-deps: |
Dave Wallace | 05120fb | 2023-03-07 22:09:20 -0500 | [diff] [blame] | 136 | @rm -f .deps.ok |
Dave Wallace | f72bb6f | 2023-03-08 13:53:32 -0500 | [diff] [blame] | 137 | @apt-get update \ |
| 138 | && 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] | 139 | apache2-utils wrk bridge-utils |
Dave Wallace | f72bb6f | 2023-03-08 13:53:32 -0500 | [diff] [blame] | 140 | @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 Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 146 | @touch .deps.ok |
| 147 | |
| 148 | .PHONY: fixstyle |
Filip Tehlar | f3ee2b6 | 2023-01-09 12:07:09 +0100 | [diff] [blame] | 149 | fixstyle: |
| 150 | @gofmt -w . |
Maros Ondrejicka | 7d7ab10 | 2023-02-14 12:56:49 +0100 | [diff] [blame] | 151 | @go mod tidy |