Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 1 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 2 | ifeq ($(VERBOSE),) |
| 3 | VERBOSE=false |
| 4 | endif |
Maros Ondrejicka | 2ddb2fd | 2023-02-15 17:44:46 +0100 | [diff] [blame] | 5 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 6 | ifeq ($(PERSIST),) |
| 7 | PERSIST=false |
| 8 | endif |
| 9 | |
Maros Ondrejicka | af004dd | 2023-02-27 16:52:57 +0100 | [diff] [blame] | 10 | ifeq ($(UNCONFIGURE),) |
| 11 | UNCONFIGURE=false |
| 12 | endif |
| 13 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 14 | ifeq ($(TEST),) |
| 15 | TEST=all |
| 16 | endif |
| 17 | |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 18 | ifeq ($(DEBUG),) |
| 19 | DEBUG=false |
| 20 | endif |
| 21 | |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 22 | ifeq ($(CPUS),) |
| 23 | CPUS=1 |
| 24 | endif |
| 25 | |
Filip Tehlar | 109f3ce | 2023-09-05 15:36:28 +0200 | [diff] [blame] | 26 | ifeq ($(VPPSRC),) |
| 27 | VPPSRC=$(shell pwd)/../.. |
| 28 | endif |
| 29 | |
Dave Wallace | 05120fb | 2023-03-07 22:09:20 -0500 | [diff] [blame] | 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 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 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 |
Filip Tehlar | 31eaea9 | 2023-06-15 10:06:57 +0200 | [diff] [blame] | 51 | @echo "make build arguments:" |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 52 | @echo " UBUNTU_VERSION - ubuntu version for docker image" |
Filip Tehlar | 31eaea9 | 2023-06-15 10:06:57 +0200 | [diff] [blame] | 53 | @echo " HST_EXTENDED_TESTS - build extended tests" |
| 54 | @echo |
| 55 | @echo "make test arguments:" |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 56 | @echo " PERSIST=[true|false] - whether clean up topology and dockers after test" |
| 57 | @echo " VERBOSE=[true|false] - verbose output" |
Florin Coras | e2415f7 | 2023-02-28 14:51:03 -0800 | [diff] [blame] | 58 | @echo " UNCONFIGURE=[true|false] - unconfigure selected test" |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 59 | @echo " DEBUG=[true|false] - attach VPP to GDB" |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 60 | @echo " TEST=[test-name] - specific test to run" |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 61 | @echo " CPUS=[n-cpus] - number of cpus to run with vpp" |
Filip Tehlar | 109f3ce | 2023-09-05 15:36:28 +0200 | [diff] [blame] | 62 | @echo " VPPSRC=[path-to-vpp-src] - path to vpp source files (for gdb)" |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 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 |
Maros Ondrejicka | af004dd | 2023-02-27 16:52:57 +0100 | [diff] [blame] | 79 | @bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \ |
Filip Tehlar | 109f3ce | 2023-09-05 15:36:28 +0200 | [diff] [blame] | 80 | --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \ |
| 81 | --vppsrc=$(VPPSRC) |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 82 | |
| 83 | build-go: |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 84 | go build ./tools/http_server |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 85 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 86 | build: .deps.ok build-vpp-release build-go |
Dave Wallace | 05120fb | 2023-03-07 22:09:20 -0500 | [diff] [blame] | 87 | @rm -f .build.vpp |
Filip Tehlar | 31eaea9 | 2023-06-15 10:06:57 +0200 | [diff] [blame] | 88 | bash ./script/build_hst.sh release |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 89 | @touch .build.vpp |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 90 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 91 | build-debug: .deps.ok build-vpp-debug build-go |
Dave Wallace | 05120fb | 2023-03-07 22:09:20 -0500 | [diff] [blame] | 92 | @rm -f .build.vpp |
Filip Tehlar | 31eaea9 | 2023-06-15 10:06:57 +0200 | [diff] [blame] | 93 | bash ./script/build_hst.sh debug |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 94 | @touch .build.vpp |
| 95 | |
Dave Wallace | d0df24d | 2023-04-26 18:03:03 -0400 | [diff] [blame] | 96 | .deps.ok: |
| 97 | @sudo make install-deps |
| 98 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 99 | .PHONY: install-deps |
| 100 | install-deps: |
Dave Wallace | 05120fb | 2023-03-07 22:09:20 -0500 | [diff] [blame] | 101 | @rm -f .deps.ok |
Dave Wallace | f72bb6f | 2023-03-08 13:53:32 -0500 | [diff] [blame] | 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 |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 112 | @touch .deps.ok |
| 113 | |
| 114 | .PHONY: fixstyle |
Filip Tehlar | f3ee2b6 | 2023-01-09 12:07:09 +0100 | [diff] [blame] | 115 | fixstyle: |
| 116 | @gofmt -w . |
Maros Ondrejicka | 7d7ab10 | 2023-02-14 12:56:49 +0100 | [diff] [blame] | 117 | @go mod tidy |