blob: 7a5fb138397fbcd8576be4ca7003bfc965cc0d4d [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
Dave Wallace05120fb2023-03-07 22:09:20 -050026ifeq ($(UBUNTU_CODENAME),)
27UBUNTU_CODENAME=$(shell grep '^UBUNTU_CODENAME=' /etc/os-release | cut -f2- -d=)
28endif
29
30ifeq ($(ARCH),)
31ARCH=$(shell dpkg --print-architecture)
32endif
33
Filip Tehlar671cf512023-01-31 10:34:18 +010034list_tests = @(grep -r ') Test' *_test.go | cut -d '*' -f2 | cut -d '(' -f1 | \
35 tr -d ' ' | tr ')' '/' | sed 's/Suite//')
36
37.PHONY: help
38help:
39 @echo "Make targets:"
40 @echo " test - run tests"
41 @echo " build - build test infra"
42 @echo " build-debug - build test infra (vpp debug image)"
43 @echo " build-go - just build golang files"
44 @echo " fixstyle - format .go source files"
45 @echo " list-tests - list all tests"
46 @echo
Filip Tehlar31eaea92023-06-15 10:06:57 +020047 @echo "make build arguments:"
Filip Tehlar671cf512023-01-31 10:34:18 +010048 @echo " UBUNTU_VERSION - ubuntu version for docker image"
Filip Tehlar31eaea92023-06-15 10:06:57 +020049 @echo " HST_EXTENDED_TESTS - build extended tests"
50 @echo
51 @echo "make test arguments:"
Filip Tehlar671cf512023-01-31 10:34:18 +010052 @echo " PERSIST=[true|false] - whether clean up topology and dockers after test"
53 @echo " VERBOSE=[true|false] - verbose output"
Florin Corase2415f72023-02-28 14:51:03 -080054 @echo " UNCONFIGURE=[true|false] - unconfigure selected test"
Filip Tehlarec5c40b2023-02-28 18:59:15 +010055 @echo " DEBUG=[true|false] - attach VPP to GDB"
Filip Tehlar671cf512023-01-31 10:34:18 +010056 @echo " TEST=[test-name] - specific test to run"
Filip Tehlar608d0062023-04-28 10:29:47 +020057 @echo " CPUS=[n-cpus] - number of cpus to run with vpp"
Filip Tehlar671cf512023-01-31 10:34:18 +010058 @echo
59 @echo "List of all tests:"
60 $(call list_tests)
61
62.PHONY: list-tests
63list-tests:
64 $(call list_tests)
65
66build-vpp-release:
67 @make -C ../.. build-release
68
69build-vpp-debug:
70 @make -C ../.. build
71
72.PHONY: test
73test: .deps.ok .build.vpp
Maros Ondrejickaaf004dd2023-02-27 16:52:57 +010074 @bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \
Filip Tehlar608d0062023-04-28 10:29:47 +020075 --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS)
Filip Tehlar671cf512023-01-31 10:34:18 +010076
77build-go:
Filip Tehlar229f5fc2022-08-09 14:44:47 +000078 go build ./tools/http_server
Filip Tehlar229f5fc2022-08-09 14:44:47 +000079
Filip Tehlar671cf512023-01-31 10:34:18 +010080build: .deps.ok build-vpp-release build-go
Dave Wallace05120fb2023-03-07 22:09:20 -050081 @rm -f .build.vpp
Filip Tehlar31eaea92023-06-15 10:06:57 +020082 bash ./script/build_hst.sh release
Filip Tehlar671cf512023-01-31 10:34:18 +010083 @touch .build.vpp
Filip Tehlar229f5fc2022-08-09 14:44:47 +000084
Filip Tehlar671cf512023-01-31 10:34:18 +010085build-debug: .deps.ok build-vpp-debug build-go
Dave Wallace05120fb2023-03-07 22:09:20 -050086 @rm -f .build.vpp
Filip Tehlar31eaea92023-06-15 10:06:57 +020087 bash ./script/build_hst.sh debug
Filip Tehlar671cf512023-01-31 10:34:18 +010088 @touch .build.vpp
89
Dave Wallaced0df24d2023-04-26 18:03:03 -040090.deps.ok:
91 @sudo make install-deps
92
Filip Tehlar671cf512023-01-31 10:34:18 +010093.PHONY: install-deps
94install-deps:
Dave Wallace05120fb2023-03-07 22:09:20 -050095 @rm -f .deps.ok
Dave Wallacef72bb6f2023-03-08 13:53:32 -050096 @apt-get update \
97 && apt-get install -y apt-transport-https ca-certificates curl software-properties-common \
98 && apt-get install -y golang apache2-utils wrk bridge-utils
99 @if [ ! -f /usr/share/keyrings/docker-archive-keyring.gpg ] ; then \
100 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg; \
101 echo "deb [arch=$(ARCH) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(UBUNTU_CODENAME) stable" \
102 | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null ; \
103 apt-get update; \
104 fi
105 @apt-get install -y docker-ce
Filip Tehlar671cf512023-01-31 10:34:18 +0100106 @touch .deps.ok
107
108.PHONY: fixstyle
Filip Tehlarf3ee2b62023-01-09 12:07:09 +0100109fixstyle:
110 @gofmt -w .
Maros Ondrejicka7d7ab102023-02-14 12:56:49 +0100111 @go mod tidy