hs-test: transition to ginkgo test framework
[vpp.git] / extras / hs-test / Makefile
1
2 ifeq ($(VERBOSE),)
3 VERBOSE=false
4 endif
5
6 ifeq ($(PERSIST),)
7 PERSIST=false
8 endif
9
10 ifeq ($(UNCONFIGURE),)
11 UNCONFIGURE=false
12 endif
13
14 ifeq ($(TEST),)
15 TEST=all
16 endif
17
18 ifeq ($(DEBUG),)
19 DEBUG=false
20 endif
21
22 ifeq ($(CPUS),)
23 CPUS=1
24 endif
25
26 ifeq ($(PARALLEL),)
27 PARALLEL=1
28 endif
29
30 ifeq ($(VPPSRC),)
31 VPPSRC=$(shell pwd)/../..
32 endif
33
34 ifeq ($(UBUNTU_CODENAME),)
35 UBUNTU_CODENAME=$(shell grep '^UBUNTU_CODENAME=' /etc/os-release | cut -f2- -d=)
36 endif
37
38 ifeq ($(ARCH),)
39 ARCH=$(shell dpkg --print-architecture)
40 endif
41
42 list_tests = @go run github.com/onsi/ginkgo/v2/ginkgo --dry-run -v --no-color --seed=2 | head -n -1 | grep 'Test' | \
43                 sed 's/^/* /; s/\(Suite\) /\1\//g'
44
45 .PHONY: help
46 help:
47         @echo "Make targets:"
48         @echo " test                 - run tests"
49         @echo " build                - build test infra"
50         @echo " build-debug          - build test infra (vpp debug image)"
51         @echo " build-go             - just build golang files"
52         @echo " fixstyle             - format .go source files"
53         @echo " list-tests           - list all tests"
54         @echo
55         @echo "make build arguments:"
56         @echo " UBUNTU_VERSION           - ubuntu version for docker image"
57         @echo " HST_EXTENDED_TESTS       - build extended tests"
58         @echo
59         @echo "make test arguments:"
60         @echo " PERSIST=[true|false]     - whether clean up topology and dockers after test"
61         @echo " VERBOSE=[true|false]     - verbose output"
62         @echo " UNCONFIGURE=[true|false] - unconfigure selected test"
63         @echo " DEBUG=[true|false]       - attach VPP to GDB"
64         @echo " TEST=[test-name]         - specific test to run"
65         @echo " CPUS=[n-cpus]            - number of cpus to run with vpp"
66         @echo " VPPSRC=[path-to-vpp-src] - path to vpp source files (for gdb)"
67         @echo " PARALLEL=[n-cpus]"               - number of test processes to spawn to run in parallel
68         @echo
69         @echo "List of all tests:"
70         $(call list_tests)
71
72 .PHONY: list-tests
73 list-tests:
74         $(call list_tests)
75
76 build-vpp-release:
77         @make -C ../.. build-release
78
79 build-vpp-debug:
80         @make -C ../.. build
81
82 .PHONY: test
83 test: .deps.ok .build.vpp
84         @bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \
85                 --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \
86                 --vppsrc=$(VPPSRC) --parallel=$(PARALLEL)
87
88 build-go:
89         go build ./tools/http_server
90
91 build: .deps.ok build-vpp-release build-go
92         @rm -f .build.vpp
93         bash ./script/build_hst.sh release
94         @touch .build.vpp
95
96 build-debug: .deps.ok build-vpp-debug build-go
97         @rm -f .build.vpp
98         bash ./script/build_hst.sh debug
99         @touch .build.vpp
100
101 .deps.ok:
102         @sudo make install-deps
103
104 .PHONY: install-deps
105 install-deps:
106         @rm -f .deps.ok
107         @apt-get update \
108                 && apt-get install -y apt-transport-https ca-certificates curl software-properties-common \
109                 && apt-get install -y golang apache2-utils wrk bridge-utils
110         @if [ ! -f /usr/share/keyrings/docker-archive-keyring.gpg ] ; then \
111                 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg; \
112                 echo "deb [arch=$(ARCH) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(UBUNTU_CODENAME) stable" \
113                         | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null ; \
114                 apt-get update; \
115         fi
116         @apt-get install -y docker-ce
117         @touch .deps.ok
118
119 .PHONY: fixstyle
120 fixstyle:
121         @gofmt -w .
122         @go mod tidy