blob: c7fdc4ea65ab6919c07d2e68228aee13691c37ac [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
82.PHONY: install-deps
83install-deps:
Dave Wallace05120fb2023-03-07 22:09:20 -050084 @rm -f .deps.ok
Dave Wallacef72bb6f2023-03-08 13:53:32 -050085 @apt-get update \
86 && apt-get install -y apt-transport-https ca-certificates curl software-properties-common \
87 && apt-get install -y golang apache2-utils wrk bridge-utils
88 @if [ ! -f /usr/share/keyrings/docker-archive-keyring.gpg ] ; then \
89 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg; \
90 echo "deb [arch=$(ARCH) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(UBUNTU_CODENAME) stable" \
91 | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null ; \
92 apt-get update; \
93 fi
94 @apt-get install -y docker-ce
Filip Tehlar671cf512023-01-31 10:34:18 +010095 @touch .deps.ok
96
97.PHONY: fixstyle
Filip Tehlarf3ee2b62023-01-09 12:07:09 +010098fixstyle:
99 @gofmt -w .
Maros Ondrejicka7d7ab102023-02-14 12:56:49 +0100100 @go mod tidy