blob: f0ec755afb2014b001ede8fa25741275ddd56492 [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
Filip Tehlar109f3ce2023-09-05 15:36:28 +020026ifeq ($(VPPSRC),)
27VPPSRC=$(shell pwd)/../..
28endif
29
Dave Wallace05120fb2023-03-07 22:09:20 -050030ifeq ($(UBUNTU_CODENAME),)
31UBUNTU_CODENAME=$(shell grep '^UBUNTU_CODENAME=' /etc/os-release | cut -f2- -d=)
32endif
33
34ifeq ($(ARCH),)
35ARCH=$(shell dpkg --print-architecture)
36endif
37
Filip Tehlar671cf512023-01-31 10:34:18 +010038list_tests = @(grep -r ') Test' *_test.go | cut -d '*' -f2 | cut -d '(' -f1 | \
39 tr -d ' ' | tr ')' '/' | sed 's/Suite//')
40
41.PHONY: help
42help:
43 @echo "Make targets:"
44 @echo " test - run tests"
45 @echo " build - build test infra"
46 @echo " build-debug - build test infra (vpp debug image)"
47 @echo " build-go - just build golang files"
48 @echo " fixstyle - format .go source files"
49 @echo " list-tests - list all tests"
50 @echo
Filip Tehlar31eaea92023-06-15 10:06:57 +020051 @echo "make build arguments:"
Filip Tehlar671cf512023-01-31 10:34:18 +010052 @echo " UBUNTU_VERSION - ubuntu version for docker image"
Filip Tehlar31eaea92023-06-15 10:06:57 +020053 @echo " HST_EXTENDED_TESTS - build extended tests"
54 @echo
55 @echo "make test arguments:"
Filip Tehlar671cf512023-01-31 10:34:18 +010056 @echo " PERSIST=[true|false] - whether clean up topology and dockers after test"
57 @echo " VERBOSE=[true|false] - verbose output"
Florin Corase2415f72023-02-28 14:51:03 -080058 @echo " UNCONFIGURE=[true|false] - unconfigure selected test"
Filip Tehlarec5c40b2023-02-28 18:59:15 +010059 @echo " DEBUG=[true|false] - attach VPP to GDB"
Filip Tehlar671cf512023-01-31 10:34:18 +010060 @echo " TEST=[test-name] - specific test to run"
Filip Tehlar608d0062023-04-28 10:29:47 +020061 @echo " CPUS=[n-cpus] - number of cpus to run with vpp"
Filip Tehlar109f3ce2023-09-05 15:36:28 +020062 @echo " VPPSRC=[path-to-vpp-src] - path to vpp source files (for gdb)"
Filip Tehlar671cf512023-01-31 10:34:18 +010063 @echo
64 @echo "List of all tests:"
65 $(call list_tests)
66
67.PHONY: list-tests
68list-tests:
69 $(call list_tests)
70
71build-vpp-release:
72 @make -C ../.. build-release
73
74build-vpp-debug:
75 @make -C ../.. build
76
77.PHONY: test
78test: .deps.ok .build.vpp
Maros Ondrejickaaf004dd2023-02-27 16:52:57 +010079 @bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \
Filip Tehlar109f3ce2023-09-05 15:36:28 +020080 --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \
81 --vppsrc=$(VPPSRC)
Filip Tehlar671cf512023-01-31 10:34:18 +010082
83build-go:
Filip Tehlar229f5fc2022-08-09 14:44:47 +000084 go build ./tools/http_server
Filip Tehlar229f5fc2022-08-09 14:44:47 +000085
Filip Tehlar671cf512023-01-31 10:34:18 +010086build: .deps.ok build-vpp-release build-go
Dave Wallace05120fb2023-03-07 22:09:20 -050087 @rm -f .build.vpp
Filip Tehlar31eaea92023-06-15 10:06:57 +020088 bash ./script/build_hst.sh release
Filip Tehlar671cf512023-01-31 10:34:18 +010089 @touch .build.vpp
Filip Tehlar229f5fc2022-08-09 14:44:47 +000090
Filip Tehlar671cf512023-01-31 10:34:18 +010091build-debug: .deps.ok build-vpp-debug 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 debug
Filip Tehlar671cf512023-01-31 10:34:18 +010094 @touch .build.vpp
95
Dave Wallaced0df24d2023-04-26 18:03:03 -040096.deps.ok:
97 @sudo make install-deps
98
Filip Tehlar671cf512023-01-31 10:34:18 +010099.PHONY: install-deps
100install-deps:
Dave Wallace05120fb2023-03-07 22:09:20 -0500101 @rm -f .deps.ok
Dave Wallacef72bb6f2023-03-08 13:53:32 -0500102 @apt-get update \
103 && apt-get install -y apt-transport-https ca-certificates curl software-properties-common \
104 && apt-get install -y golang apache2-utils wrk bridge-utils
105 @if [ ! -f /usr/share/keyrings/docker-archive-keyring.gpg ] ; then \
106 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg; \
107 echo "deb [arch=$(ARCH) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(UBUNTU_CODENAME) stable" \
108 | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null ; \
109 apt-get update; \
110 fi
111 @apt-get install -y docker-ce
Filip Tehlar671cf512023-01-31 10:34:18 +0100112 @touch .deps.ok
113
114.PHONY: fixstyle
Filip Tehlarf3ee2b62023-01-09 12:07:09 +0100115fixstyle:
116 @gofmt -w .
Maros Ondrejicka7d7ab102023-02-14 12:56:49 +0100117 @go mod tidy