aboutsummaryrefslogtreecommitdiffstats
path: root/extras/hs-test/Makefile
blob: 3d7673a7267dbc558f9cf954188e8e32553a510b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
ifeq ($(VERBOSE),)
VERBOSE=false
endif

ifeq ($(PERSIST),)
PERSIST=false
endif

ifeq ($(UNCONFIGURE),)
UNCONFIGURE=false
endif

ifeq ($(TEST),)
TEST=all
endif

ifeq ($(DEBUG),)
DEBUG=false
endif

ifeq ($(CPUS),)
CPUS=1
endif

ifeq ($(UBUNTU_CODENAME),)
UBUNTU_CODENAME=$(shell grep '^UBUNTU_CODENAME=' /etc/os-release | cut -f2- -d=)
endif

ifeq ($(ARCH),)
ARCH=$(shell dpkg --print-architecture)
endif

list_tests = @(grep -r ') Test' *_test.go | cut -d '*' -f2 | cut -d '(' -f1 | \
		tr -d ' ' | tr ')' '/' | sed 's/Suite//')

.PHONY: help
help:
	@echo "Make targets:"
	@echo " test                 - run tests"
	@echo " build                - build test infra"
	@echo " build-debug          - build test infra (vpp debug image)"
	@echo " build-go             - just build golang files"
	@echo " fixstyle             - format .go source files"
	@echo " list-tests           - list all tests"
	@echo
	@echo "Make arguments:"
	@echo " UBUNTU_VERSION           - ubuntu version for docker image"
	@echo " PERSIST=[true|false]     - whether clean up topology and dockers after test"
	@echo " VERBOSE=[true|false]     - verbose output"
	@echo " UNCONFIGURE=[true|false] - unconfigure selected test"
	@echo " DEBUG=[true|false]       - attach VPP to GDB"
	@echo " TEST=[test-name]         - specific test to run"
	@echo " CPUS=[n-cpus]            - number of cpus to run with vpp"
	@echo
	@echo "List of all tests:"
	$(call list_tests)

.PHONY: list-tests
list-tests:
	$(call list_tests)

build-vpp-release:
	@make -C ../.. build-release

build-vpp-debug:
	@make -C ../.. build

.PHONY: test
test: .deps.ok .build.vpp
	@bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \
		--unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS)

build-go:
	go build ./tools/http_server

build: .deps.ok build-vpp-release build-go
	@rm -f .build.vpp
	bash ./script/build.sh release
	@touch .build.vpp

build-debug: .deps.ok build-vpp-debug build-go
	@rm -f .build.vpp
	bash ./script/build.sh debug
	@touch .build.vpp

.deps.ok:
	@sudo make install-deps

.PHONY: install-deps
install-deps:
	@rm -f .deps.ok
	@apt-get update \
		&& apt-get install -y apt-transport-https ca-certificates curl software-properties-common \
		&& apt-get install -y golang apache2-utils wrk bridge-utils
	@if [ ! -f /usr/share/keyrings/docker-archive-keyring.gpg ] ; then \
		curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg; \
		echo "deb [arch=$(ARCH) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(UBUNTU_CODENAME) stable" \
			| sudo tee /etc/apt/sources.list.d/docker.list > /dev/null ; \
		apt-get update; \
	fi
	@apt-get install -y docker-ce
	@touch .deps.ok

.PHONY: fixstyle
fixstyle:
	@gofmt -w .
	@go mod tidy