blob: 6ee89bc2770a7722cc08768385c9184dbbb7514e [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"
Matus Fabian2d1bc4c2024-05-09 10:46:58 +020053 @echo " test-debug - run tests (vpp debug image)"
Filip Tehlar671cf512023-01-31 10:34:18 +010054 @echo " build - build test infra"
55 @echo " build-debug - build test infra (vpp debug image)"
56 @echo " build-go - just build golang files"
57 @echo " fixstyle - format .go source files"
58 @echo " list-tests - list all tests"
59 @echo
Filip Tehlar31eaea92023-06-15 10:06:57 +020060 @echo "make build arguments:"
Filip Tehlar671cf512023-01-31 10:34:18 +010061 @echo " UBUNTU_VERSION - ubuntu version for docker image"
Filip Tehlar31eaea92023-06-15 10:06:57 +020062 @echo " HST_EXTENDED_TESTS - build extended tests"
63 @echo
64 @echo "make test arguments:"
Filip Tehlar671cf512023-01-31 10:34:18 +010065 @echo " PERSIST=[true|false] - whether clean up topology and dockers after test"
66 @echo " VERBOSE=[true|false] - verbose output"
Florin Corase2415f72023-02-28 14:51:03 -080067 @echo " UNCONFIGURE=[true|false] - unconfigure selected test"
Filip Tehlarec5c40b2023-02-28 18:59:15 +010068 @echo " DEBUG=[true|false] - attach VPP to GDB"
Filip Tehlar671cf512023-01-31 10:34:18 +010069 @echo " TEST=[test-name] - specific test to run"
Filip Tehlar608d0062023-04-28 10:29:47 +020070 @echo " CPUS=[n-cpus] - number of cpus to run with vpp"
Filip Tehlar109f3ce2023-09-05 15:36:28 +020071 @echo " VPPSRC=[path-to-vpp-src] - path to vpp source files (for gdb)"
Matus Fabianbbee45c2024-04-22 19:47:27 +020072 @echo " PARALLEL=[n-cpus] - number of test processes to spawn to run in parallel"
73 @echo " REPEAT=[n] - repeat tests up to N times or until a failure occurs"
Filip Tehlar671cf512023-01-31 10:34:18 +010074 @echo
75 @echo "List of all tests:"
76 $(call list_tests)
77
78.PHONY: list-tests
79list-tests:
80 $(call list_tests)
81
Dave Wallace83b12bf2024-04-25 16:21:37 -040082.PHONY: build-vpp-release
Filip Tehlar671cf512023-01-31 10:34:18 +010083build-vpp-release:
84 @make -C ../.. build-release
85
Dave Wallace83b12bf2024-04-25 16:21:37 -040086.PHONY: build-vpp-debug
Filip Tehlar671cf512023-01-31 10:34:18 +010087build-vpp-debug:
88 @make -C ../.. build
89
Dave Wallace83b12bf2024-04-25 16:21:37 -040090.build.ok: build
91 @touch .build.ok
92
Matus Fabian2d1bc4c2024-05-09 10:46:58 +020093.build_debug.ok: build-debug
94 @touch .build.ok
95
Filip Tehlar671cf512023-01-31 10:34:18 +010096.PHONY: test
Dave Wallace83b12bf2024-04-25 16:21:37 -040097test: .deps.ok .build.ok
Adrian Villin637edda2024-05-06 06:55:34 -040098 -bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \
Filip Tehlar109f3ce2023-09-05 15:36:28 +020099 --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \
Matus Fabianbbee45c2024-04-22 19:47:27 +0200100 --vppsrc=$(VPPSRC) --parallel=$(PARALLEL) --repeat=$(REPEAT)
Adrian Villin637edda2024-05-06 06:55:34 -0400101 $(call jq-summary)
102 @bash ./script/compress.sh
Filip Tehlar671cf512023-01-31 10:34:18 +0100103
Matus Fabian2d1bc4c2024-05-09 10:46:58 +0200104.PHONY: test-debug
105test-debug: .deps.ok .build_debug.ok
106 @bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \
107 --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \
108 --vppsrc=$(VPPSRC) --parallel=$(PARALLEL) --repeat=$(REPEAT)
109
Dave Wallace83b12bf2024-04-25 16:21:37 -0400110.PHONY: build-go
Filip Tehlar671cf512023-01-31 10:34:18 +0100111build-go:
Filip Tehlar229f5fc2022-08-09 14:44:47 +0000112 go build ./tools/http_server
Filip Tehlar229f5fc2022-08-09 14:44:47 +0000113
Dave Wallace83b12bf2024-04-25 16:21:37 -0400114.PHONY: build
Filip Tehlar671cf512023-01-31 10:34:18 +0100115build: .deps.ok build-vpp-release build-go
Dave Wallace83b12bf2024-04-25 16:21:37 -0400116 @rm -f .build.ok
Filip Tehlar31eaea92023-06-15 10:06:57 +0200117 bash ./script/build_hst.sh release
Dave Wallace83b12bf2024-04-25 16:21:37 -0400118 @touch .build.ok
Filip Tehlar229f5fc2022-08-09 14:44:47 +0000119
Dave Wallace83b12bf2024-04-25 16:21:37 -0400120.PHONY: build-debug
Filip Tehlar671cf512023-01-31 10:34:18 +0100121build-debug: .deps.ok build-vpp-debug build-go
Dave Wallace83b12bf2024-04-25 16:21:37 -0400122 @rm -f .build.ok
Filip Tehlar31eaea92023-06-15 10:06:57 +0200123 bash ./script/build_hst.sh debug
Dave Wallace83b12bf2024-04-25 16:21:37 -0400124 @touch .build.ok
Filip Tehlar671cf512023-01-31 10:34:18 +0100125
Dave Wallaced0df24d2023-04-26 18:03:03 -0400126.deps.ok:
127 @sudo make install-deps
128
Filip Tehlar671cf512023-01-31 10:34:18 +0100129.PHONY: install-deps
130install-deps:
Dave Wallace05120fb2023-03-07 22:09:20 -0500131 @rm -f .deps.ok
Dave Wallacef72bb6f2023-03-08 13:53:32 -0500132 @apt-get update \
133 && apt-get install -y apt-transport-https ca-certificates curl software-properties-common \
Dave Wallace83b12bf2024-04-25 16:21:37 -0400134 apache2-utils wrk bridge-utils
Dave Wallacef72bb6f2023-03-08 13:53:32 -0500135 @if [ ! -f /usr/share/keyrings/docker-archive-keyring.gpg ] ; then \
136 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg; \
137 echo "deb [arch=$(ARCH) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(UBUNTU_CODENAME) stable" \
138 | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null ; \
139 apt-get update; \
140 fi
Filip Tehlar671cf512023-01-31 10:34:18 +0100141 @touch .deps.ok
142
143.PHONY: fixstyle
Filip Tehlarf3ee2b62023-01-09 12:07:09 +0100144fixstyle:
145 @gofmt -w .
Maros Ondrejicka7d7ab102023-02-14 12:56:49 +0100146 @go mod tidy
Adrian Villin637edda2024-05-06 06:55:34 -0400147
148# splitting this into multiple lines breaks the command
149jq-summary = @jq -r '.[0] | .SpecReports[] | select(.State == "failed") | select(.Failure != null) | "TestName: \(.LeafNodeText)\nMessage:\n\(.Failure.Message)\n Full Stack Trace:\n\(.Failure.Location.FullStackTrace)\n"' summary/report.json > summary/failed-summary.log \
150 && echo "Summary generated -> failed-summary.log"