blob: 3d7673a7267dbc558f9cf954188e8e32553a510b [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
47 @echo "Make arguments:"
48 @echo " UBUNTU_VERSION - ubuntu version for docker image"
49 @echo " PERSIST=[true|false] - whether clean up topology and dockers after test"
50 @echo " VERBOSE=[true|false] - verbose output"
Florin Corase2415f72023-02-28 14:51:03 -080051 @echo " UNCONFIGURE=[true|false] - unconfigure selected test"
Filip Tehlarec5c40b2023-02-28 18:59:15 +010052 @echo " DEBUG=[true|false] - attach VPP to GDB"
Filip Tehlar671cf512023-01-31 10:34:18 +010053 @echo " TEST=[test-name] - specific test to run"
Filip Tehlar608d0062023-04-28 10:29:47 +020054 @echo " CPUS=[n-cpus] - number of cpus to run with vpp"
Filip Tehlar671cf512023-01-31 10:34:18 +010055 @echo
56 @echo "List of all tests:"
57 $(call list_tests)
58
59.PHONY: list-tests
60list-tests:
61 $(call list_tests)
62
63build-vpp-release:
64 @make -C ../.. build-release
65
66build-vpp-debug:
67 @make -C ../.. build
68
69.PHONY: test
70test: .deps.ok .build.vpp
Maros Ondrejickaaf004dd2023-02-27 16:52:57 +010071 @bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \
Filip Tehlar608d0062023-04-28 10:29:47 +020072 --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS)
Filip Tehlar671cf512023-01-31 10:34:18 +010073
74build-go:
Filip Tehlar229f5fc2022-08-09 14:44:47 +000075 go build ./tools/http_server
Filip Tehlar229f5fc2022-08-09 14:44:47 +000076
Filip Tehlar671cf512023-01-31 10:34:18 +010077build: .deps.ok build-vpp-release 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 release
80 @touch .build.vpp
Filip Tehlar229f5fc2022-08-09 14:44:47 +000081
Filip Tehlar671cf512023-01-31 10:34:18 +010082build-debug: .deps.ok build-vpp-debug build-go
Dave Wallace05120fb2023-03-07 22:09:20 -050083 @rm -f .build.vpp
Filip Tehlar671cf512023-01-31 10:34:18 +010084 bash ./script/build.sh debug
85 @touch .build.vpp
86
Dave Wallaced0df24d2023-04-26 18:03:03 -040087.deps.ok:
88 @sudo make install-deps
89
Filip Tehlar671cf512023-01-31 10:34:18 +010090.PHONY: install-deps
91install-deps:
Dave Wallace05120fb2023-03-07 22:09:20 -050092 @rm -f .deps.ok
Dave Wallacef72bb6f2023-03-08 13:53:32 -050093 @apt-get update \
94 && apt-get install -y apt-transport-https ca-certificates curl software-properties-common \
95 && apt-get install -y golang apache2-utils wrk bridge-utils
96 @if [ ! -f /usr/share/keyrings/docker-archive-keyring.gpg ] ; then \
97 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg; \
98 echo "deb [arch=$(ARCH) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(UBUNTU_CODENAME) stable" \
99 | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null ; \
100 apt-get update; \
101 fi
102 @apt-get install -y docker-ce
Filip Tehlar671cf512023-01-31 10:34:18 +0100103 @touch .deps.ok
104
105.PHONY: fixstyle
Filip Tehlarf3ee2b62023-01-09 12:07:09 +0100106fixstyle:
107 @gofmt -w .
Maros Ondrejicka7d7ab102023-02-14 12:56:49 +0100108 @go mod tidy