hs-test: improve test infra
[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 ($(TEST),)
11 TEST=all
12 endif
13
14 list_tests = @(grep -r ') Test' *_test.go | cut -d '*' -f2 | cut -d '(' -f1 | \
15                 tr -d ' ' | tr ')' '/' | sed 's/Suite//')
16
17 .PHONY: help
18 help:
19         @echo "Make targets:"
20         @echo " test                 - run tests"
21         @echo " build                - build test infra"
22         @echo " build-debug          - build test infra (vpp debug image)"
23         @echo " build-go             - just build golang files"
24         @echo " fixstyle             - format .go source files"
25         @echo " list-tests           - list all tests"
26         @echo
27         @echo "Make arguments:"
28         @echo " UBUNTU_VERSION           - ubuntu version for docker image"
29         @echo " PERSIST=[true|false]     - whether clean up topology and dockers after test"
30         @echo " VERBOSE=[true|false]     - verbose output"
31         @echo " TEST=[test-name]         - specific test to run"
32         @echo
33         @echo "List of all tests:"
34         $(call list_tests)
35
36 .PHONY: list-tests
37 list-tests:
38         $(call list_tests)
39
40 build-vpp-release:
41         @make -C ../.. build-release
42
43 build-vpp-debug:
44         @make -C ../.. build
45
46 .PHONY: test
47 test: .deps.ok .build.vpp
48         @bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) --test=$(TEST)
49
50 build-go:
51         go build ./tools/http_server
52
53 build: .deps.ok build-vpp-release build-go
54         @rm .build.vpp || exit 0
55         bash ./script/build.sh release
56         @touch .build.vpp
57
58 build-debug: .deps.ok build-vpp-debug build-go
59         @rm .build.vpp || exit 0
60         bash ./script/build.sh debug
61         @touch .build.vpp
62
63 .PHONY: install-deps
64 install-deps:
65         @rm .deps.ok || exit 0
66         @apt update -y && apt install -y golang docker-ce apache2-utils wrk bridge-utils
67         @touch .deps.ok
68
69 .PHONY: fixstyle
70 fixstyle:
71         @gofmt -w .
72         @go mod tidy
73