blob: 14d95fc060aed1b923d50d5f57260bf8668f0199 [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
Dave Wallace05120fb2023-03-07 22:09:20 -050022ifeq ($(UBUNTU_CODENAME),)
23UBUNTU_CODENAME=$(shell grep '^UBUNTU_CODENAME=' /etc/os-release | cut -f2- -d=)
24endif
25
26ifeq ($(ARCH),)
27ARCH=$(shell dpkg --print-architecture)
28endif
29
Filip Tehlar671cf512023-01-31 10:34:18 +010030list_tests = @(grep -r ') Test' *_test.go | cut -d '*' -f2 | cut -d '(' -f1 | \
31 tr -d ' ' | tr ')' '/' | sed 's/Suite//')
32
33.PHONY: help
34help:
35 @echo "Make targets:"
36 @echo " test - run tests"
37 @echo " build - build test infra"
38 @echo " build-debug - build test infra (vpp debug image)"
39 @echo " build-go - just build golang files"
40 @echo " fixstyle - format .go source files"
41 @echo " list-tests - list all tests"
42 @echo
43 @echo "Make arguments:"
44 @echo " UBUNTU_VERSION - ubuntu version for docker image"
45 @echo " PERSIST=[true|false] - whether clean up topology and dockers after test"
46 @echo " VERBOSE=[true|false] - verbose output"
Florin Corase2415f72023-02-28 14:51:03 -080047 @echo " UNCONFIGURE=[true|false] - unconfigure selected test"
Filip Tehlarec5c40b2023-02-28 18:59:15 +010048 @echo " DEBUG=[true|false] - attach VPP to GDB"
Filip Tehlar671cf512023-01-31 10:34:18 +010049 @echo " TEST=[test-name] - specific test to run"
50 @echo
51 @echo "List of all tests:"
52 $(call list_tests)
53
54.PHONY: list-tests
55list-tests:
56 $(call list_tests)
57
58build-vpp-release:
59 @make -C ../.. build-release
60
61build-vpp-debug:
62 @make -C ../.. build
63
64.PHONY: test
65test: .deps.ok .build.vpp
Maros Ondrejickaaf004dd2023-02-27 16:52:57 +010066 @bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \
Filip Tehlarec5c40b2023-02-28 18:59:15 +010067 --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST)
Filip Tehlar671cf512023-01-31 10:34:18 +010068
69build-go:
Filip Tehlar229f5fc2022-08-09 14:44:47 +000070 go build ./tools/http_server
Filip Tehlar229f5fc2022-08-09 14:44:47 +000071
Filip Tehlar671cf512023-01-31 10:34:18 +010072build: .deps.ok build-vpp-release build-go
Dave Wallace05120fb2023-03-07 22:09:20 -050073 @rm -f .build.vpp
Filip Tehlar671cf512023-01-31 10:34:18 +010074 bash ./script/build.sh release
75 @touch .build.vpp
Filip Tehlar229f5fc2022-08-09 14:44:47 +000076
Filip Tehlar671cf512023-01-31 10:34:18 +010077build-debug: .deps.ok build-vpp-debug build-go
Dave Wallace05120fb2023-03-07 22:09:20 -050078 @rm -f .build.vpp
Filip Tehlar671cf512023-01-31 10:34:18 +010079 bash ./script/build.sh debug
80 @touch .build.vpp
81
Dave Wallaced0df24d2023-04-26 18:03:03 -040082.deps.ok:
83 @sudo make install-deps
84
Filip Tehlar671cf512023-01-31 10:34:18 +010085.PHONY: install-deps
86install-deps:
Dave Wallace05120fb2023-03-07 22:09:20 -050087 @rm -f .deps.ok
Dave Wallacef72bb6f2023-03-08 13:53:32 -050088 @apt-get update \
89 && apt-get install -y apt-transport-https ca-certificates curl software-properties-common \
90 && apt-get install -y golang apache2-utils wrk bridge-utils
91 @if [ ! -f /usr/share/keyrings/docker-archive-keyring.gpg ] ; then \
92 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg; \
93 echo "deb [arch=$(ARCH) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(UBUNTU_CODENAME) stable" \
94 | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null ; \
95 apt-get update; \
96 fi
97 @apt-get install -y docker-ce
Filip Tehlar671cf512023-01-31 10:34:18 +010098 @touch .deps.ok
99
100.PHONY: fixstyle
Filip Tehlarf3ee2b62023-01-09 12:07:09 +0100101fixstyle:
102 @gofmt -w .
Maros Ondrejicka7d7ab102023-02-14 12:56:49 +0100103 @go mod tidy