blob: 9c4d3454b58f836b58b018750df9a4a9bdea6fdf [file] [log] [blame]
Filip Tehlar229f5fc2022-08-09 14:44:47 +00001
Filip Tehlar671cf512023-01-31 10:34:18 +01002ifeq ($(VERBOSE),)
3VERBOSE=false
4endif
Maros Ondrejicka2ddb2fd2023-02-15 17:44:46 +01005
Filip Tehlar671cf512023-01-31 10:34:18 +01006ifeq ($(PERSIST),)
7PERSIST=false
8endif
9
Maros Ondrejickaaf004dd2023-02-27 16:52:57 +010010ifeq ($(UNCONFIGURE),)
11UNCONFIGURE=false
12endif
13
Filip Tehlar671cf512023-01-31 10:34:18 +010014ifeq ($(TEST),)
15TEST=all
16endif
17
Filip Tehlarec5c40b2023-02-28 18:59:15 +010018ifeq ($(DEBUG),)
19DEBUG=false
20endif
21
Filip Tehlar608d0062023-04-28 10:29:47 +020022ifeq ($(CPUS),)
23CPUS=1
24endif
25
Adrian Villincee15aa2024-03-14 11:42:55 -040026ifeq ($(PARALLEL),)
27PARALLEL=1
28endif
29
Filip Tehlar109f3ce2023-09-05 15:36:28 +020030ifeq ($(VPPSRC),)
31VPPSRC=$(shell pwd)/../..
32endif
33
Dave Wallace05120fb2023-03-07 22:09:20 -050034ifeq ($(UBUNTU_CODENAME),)
35UBUNTU_CODENAME=$(shell grep '^UBUNTU_CODENAME=' /etc/os-release | cut -f2- -d=)
36endif
37
38ifeq ($(ARCH),)
39ARCH=$(shell dpkg --print-architecture)
40endif
41
Adrian Villincee15aa2024-03-14 11:42:55 -040042list_tests = @go run github.com/onsi/ginkgo/v2/ginkgo --dry-run -v --no-color --seed=2 | head -n -1 | grep 'Test' | \
43 sed 's/^/* /; s/\(Suite\) /\1\//g'
Filip Tehlar671cf512023-01-31 10:34:18 +010044
45.PHONY: help
46help:
47 @echo "Make targets:"
48 @echo " test - run tests"
49 @echo " build - build test infra"
50 @echo " build-debug - build test infra (vpp debug image)"
51 @echo " build-go - just build golang files"
52 @echo " fixstyle - format .go source files"
53 @echo " list-tests - list all tests"
54 @echo
Filip Tehlar31eaea92023-06-15 10:06:57 +020055 @echo "make build arguments:"
Filip Tehlar671cf512023-01-31 10:34:18 +010056 @echo " UBUNTU_VERSION - ubuntu version for docker image"
Filip Tehlar31eaea92023-06-15 10:06:57 +020057 @echo " HST_EXTENDED_TESTS - build extended tests"
58 @echo
59 @echo "make test arguments:"
Filip Tehlar671cf512023-01-31 10:34:18 +010060 @echo " PERSIST=[true|false] - whether clean up topology and dockers after test"
61 @echo " VERBOSE=[true|false] - verbose output"
Florin Corase2415f72023-02-28 14:51:03 -080062 @echo " UNCONFIGURE=[true|false] - unconfigure selected test"
Filip Tehlarec5c40b2023-02-28 18:59:15 +010063 @echo " DEBUG=[true|false] - attach VPP to GDB"
Filip Tehlar671cf512023-01-31 10:34:18 +010064 @echo " TEST=[test-name] - specific test to run"
Filip Tehlar608d0062023-04-28 10:29:47 +020065 @echo " CPUS=[n-cpus] - number of cpus to run with vpp"
Filip Tehlar109f3ce2023-09-05 15:36:28 +020066 @echo " VPPSRC=[path-to-vpp-src] - path to vpp source files (for gdb)"
Adrian Villincee15aa2024-03-14 11:42:55 -040067 @echo " PARALLEL=[n-cpus]" - number of test processes to spawn to run in parallel
Filip Tehlar671cf512023-01-31 10:34:18 +010068 @echo
69 @echo "List of all tests:"
70 $(call list_tests)
71
72.PHONY: list-tests
73list-tests:
74 $(call list_tests)
75
76build-vpp-release:
77 @make -C ../.. build-release
78
79build-vpp-debug:
80 @make -C ../.. build
81
82.PHONY: test
83test: .deps.ok .build.vpp
Maros Ondrejickaaf004dd2023-02-27 16:52:57 +010084 @bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \
Filip Tehlar109f3ce2023-09-05 15:36:28 +020085 --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \
Adrian Villincee15aa2024-03-14 11:42:55 -040086 --vppsrc=$(VPPSRC) --parallel=$(PARALLEL)
Filip Tehlar671cf512023-01-31 10:34:18 +010087
88build-go:
Filip Tehlar229f5fc2022-08-09 14:44:47 +000089 go build ./tools/http_server
Filip Tehlar229f5fc2022-08-09 14:44:47 +000090
Filip Tehlar671cf512023-01-31 10:34:18 +010091build: .deps.ok build-vpp-release build-go
Dave Wallace05120fb2023-03-07 22:09:20 -050092 @rm -f .build.vpp
Filip Tehlar31eaea92023-06-15 10:06:57 +020093 bash ./script/build_hst.sh release
Filip Tehlar671cf512023-01-31 10:34:18 +010094 @touch .build.vpp
Filip Tehlar229f5fc2022-08-09 14:44:47 +000095
Filip Tehlar671cf512023-01-31 10:34:18 +010096build-debug: .deps.ok build-vpp-debug build-go
Dave Wallace05120fb2023-03-07 22:09:20 -050097 @rm -f .build.vpp
Filip Tehlar31eaea92023-06-15 10:06:57 +020098 bash ./script/build_hst.sh debug
Filip Tehlar671cf512023-01-31 10:34:18 +010099 @touch .build.vpp
100
Dave Wallaced0df24d2023-04-26 18:03:03 -0400101.deps.ok:
102 @sudo make install-deps
103
Filip Tehlar671cf512023-01-31 10:34:18 +0100104.PHONY: install-deps
105install-deps:
Dave Wallace05120fb2023-03-07 22:09:20 -0500106 @rm -f .deps.ok
Dave Wallacef72bb6f2023-03-08 13:53:32 -0500107 @apt-get update \
108 && apt-get install -y apt-transport-https ca-certificates curl software-properties-common \
109 && apt-get install -y golang apache2-utils wrk bridge-utils
110 @if [ ! -f /usr/share/keyrings/docker-archive-keyring.gpg ] ; then \
111 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg; \
112 echo "deb [arch=$(ARCH) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(UBUNTU_CODENAME) stable" \
113 | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null ; \
114 apt-get update; \
115 fi
116 @apt-get install -y docker-ce
Filip Tehlar671cf512023-01-31 10:34:18 +0100117 @touch .deps.ok
118
119.PHONY: fixstyle
Filip Tehlarf3ee2b62023-01-09 12:07:09 +0100120fixstyle:
121 @gofmt -w .
Maros Ondrejicka7d7ab102023-02-14 12:56:49 +0100122 @go mod tidy