blob: 196bca5c25f0b5d2c6be690ba2fdd9e8c5694ca6 [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
Adrian Villincee15aa2024-03-14 11:42:55 -040026ifeq ($(PARALLEL),)
27PARALLEL=1
28endif
29
Matus Fabianbbee45c2024-04-22 19:47:27 +020030ifeq ($(REPEAT),)
31REPEAT=0
32endif
33
Filip Tehlar109f3ce2023-09-05 15:36:28 +020034ifeq ($(VPPSRC),)
35VPPSRC=$(shell pwd)/../..
36endif
37
Dave Wallace05120fb2023-03-07 22:09:20 -050038ifeq ($(UBUNTU_CODENAME),)
39UBUNTU_CODENAME=$(shell grep '^UBUNTU_CODENAME=' /etc/os-release | cut -f2- -d=)
40endif
41
42ifeq ($(ARCH),)
43ARCH=$(shell dpkg --print-architecture)
44endif
45
Adrian Villincee15aa2024-03-14 11:42:55 -040046list_tests = @go run github.com/onsi/ginkgo/v2/ginkgo --dry-run -v --no-color --seed=2 | head -n -1 | grep 'Test' | \
47 sed 's/^/* /; s/\(Suite\) /\1\//g'
Filip Tehlar671cf512023-01-31 10:34:18 +010048
49.PHONY: help
50help:
51 @echo "Make targets:"
52 @echo " test - run tests"
53 @echo " build - build test infra"
54 @echo " build-debug - build test infra (vpp debug image)"
55 @echo " build-go - just build golang files"
56 @echo " fixstyle - format .go source files"
57 @echo " list-tests - list all tests"
58 @echo
Filip Tehlar31eaea92023-06-15 10:06:57 +020059 @echo "make build arguments:"
Filip Tehlar671cf512023-01-31 10:34:18 +010060 @echo " UBUNTU_VERSION - ubuntu version for docker image"
Filip Tehlar31eaea92023-06-15 10:06:57 +020061 @echo " HST_EXTENDED_TESTS - build extended tests"
62 @echo
63 @echo "make test arguments:"
Filip Tehlar671cf512023-01-31 10:34:18 +010064 @echo " PERSIST=[true|false] - whether clean up topology and dockers after test"
65 @echo " VERBOSE=[true|false] - verbose output"
Florin Corase2415f72023-02-28 14:51:03 -080066 @echo " UNCONFIGURE=[true|false] - unconfigure selected test"
Filip Tehlarec5c40b2023-02-28 18:59:15 +010067 @echo " DEBUG=[true|false] - attach VPP to GDB"
Filip Tehlar671cf512023-01-31 10:34:18 +010068 @echo " TEST=[test-name] - specific test to run"
Filip Tehlar608d0062023-04-28 10:29:47 +020069 @echo " CPUS=[n-cpus] - number of cpus to run with vpp"
Filip Tehlar109f3ce2023-09-05 15:36:28 +020070 @echo " VPPSRC=[path-to-vpp-src] - path to vpp source files (for gdb)"
Matus Fabianbbee45c2024-04-22 19:47:27 +020071 @echo " PARALLEL=[n-cpus] - number of test processes to spawn to run in parallel"
72 @echo " REPEAT=[n] - repeat tests up to N times or until a failure occurs"
Filip Tehlar671cf512023-01-31 10:34:18 +010073 @echo
74 @echo "List of all tests:"
75 $(call list_tests)
76
77.PHONY: list-tests
78list-tests:
79 $(call list_tests)
80
81build-vpp-release:
82 @make -C ../.. build-release
83
84build-vpp-debug:
85 @make -C ../.. build
86
87.PHONY: test
88test: .deps.ok .build.vpp
Maros Ondrejickaaf004dd2023-02-27 16:52:57 +010089 @bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \
Filip Tehlar109f3ce2023-09-05 15:36:28 +020090 --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \
Matus Fabianbbee45c2024-04-22 19:47:27 +020091 --vppsrc=$(VPPSRC) --parallel=$(PARALLEL) --repeat=$(REPEAT)
Filip Tehlar671cf512023-01-31 10:34:18 +010092
93build-go:
Filip Tehlar229f5fc2022-08-09 14:44:47 +000094 go build ./tools/http_server
Filip Tehlar229f5fc2022-08-09 14:44:47 +000095
Filip Tehlar671cf512023-01-31 10:34:18 +010096build: .deps.ok build-vpp-release build-go
Dave Wallace05120fb2023-03-07 22:09:20 -050097 @rm -f .build.vpp
Filip Tehlar31eaea92023-06-15 10:06:57 +020098 bash ./script/build_hst.sh release
Filip Tehlar671cf512023-01-31 10:34:18 +010099 @touch .build.vpp
Filip Tehlar229f5fc2022-08-09 14:44:47 +0000100
Filip Tehlar671cf512023-01-31 10:34:18 +0100101build-debug: .deps.ok build-vpp-debug build-go
Dave Wallace05120fb2023-03-07 22:09:20 -0500102 @rm -f .build.vpp
Filip Tehlar31eaea92023-06-15 10:06:57 +0200103 bash ./script/build_hst.sh debug
Filip Tehlar671cf512023-01-31 10:34:18 +0100104 @touch .build.vpp
105
Dave Wallaced0df24d2023-04-26 18:03:03 -0400106.deps.ok:
107 @sudo make install-deps
108
Filip Tehlar671cf512023-01-31 10:34:18 +0100109.PHONY: install-deps
110install-deps:
Dave Wallace05120fb2023-03-07 22:09:20 -0500111 @rm -f .deps.ok
Dave Wallacef72bb6f2023-03-08 13:53:32 -0500112 @apt-get update \
113 && apt-get install -y apt-transport-https ca-certificates curl software-properties-common \
114 && apt-get install -y golang apache2-utils wrk bridge-utils
115 @if [ ! -f /usr/share/keyrings/docker-archive-keyring.gpg ] ; then \
116 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg; \
117 echo "deb [arch=$(ARCH) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(UBUNTU_CODENAME) stable" \
118 | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null ; \
119 apt-get update; \
120 fi
121 @apt-get install -y docker-ce
Filip Tehlar671cf512023-01-31 10:34:18 +0100122 @touch .deps.ok
123
124.PHONY: fixstyle
Filip Tehlarf3ee2b62023-01-09 12:07:09 +0100125fixstyle:
126 @gofmt -w .
Maros Ondrejicka7d7ab102023-02-14 12:56:49 +0100127 @go mod tidy