1 export HS_ROOT=$(CURDIR)
3 # sets WS_ROOT if called from extras/hs-test
5 export WS_ROOT=$(HS_ROOT)/../..
16 ifeq ($(UNCONFIGURE),)
45 VPPSRC=$(shell pwd)/../..
48 ifeq ($(UBUNTU_CODENAME),)
49 UBUNTU_CODENAME=$(shell grep '^UBUNTU_CODENAME=' /etc/os-release | cut -f2- -d=)
53 ARCH=$(shell dpkg --print-architecture)
59 @echo " test - run tests"
60 @echo " test-debug - run tests (vpp debug image)"
61 @echo " build - build test infra"
62 @echo " build-cov - coverage build of VPP and Docker images"
63 @echo " build-debug - build test infra (vpp debug image)"
64 @echo " build-go - just build golang files"
65 @echo " checkstyle-go - check style of .go source files"
66 @echo " fixstyle-go - format .go source files"
67 @echo " cleanup-hst - stops and removes all docker contaiers and namespaces"
68 @echo " list-tests - list all tests"
70 @echo "'make build' arguments:"
71 @echo " UBUNTU_VERSION - ubuntu version for docker image"
72 @echo " HST_EXTENDED_TESTS - build extended tests"
74 @echo "'make test' arguments:"
75 @echo " PERSIST=[true|false] - whether clean up topology and dockers after test"
76 @echo " VERBOSE=[true|false] - verbose output"
77 @echo " UNCONFIGURE=[true|false] - unconfigure selected test"
78 @echo " DEBUG=[true|false] - attach VPP to GDB"
79 @echo " TEST=[test-name] - specific test to run"
80 @echo " CPUS=[n-cpus] - number of cpus to allocate to VPP and containers"
81 @echo " VPPSRC=[path-to-vpp-src] - path to vpp source files (for gdb)"
82 @echo " PARALLEL=[n-cpus] - number of test processes to spawn to run in parallel"
83 @echo " REPEAT=[n] - repeat tests up to N times or until a failure occurs"
85 @echo "List of all tests:"
90 @go run github.com/onsi/ginkgo/v2/ginkgo --dry-run -v --no-color --seed=2 | head -n -1 | grep 'Test' | \
91 sed 's/^/* /; s/\(Suite\) /\1\//g'
93 .PHONY: build-vpp-release
95 @$(MAKE) -C ../.. build-release
97 .PHONY: build-vpp-debug
99 @$(MAKE) -C ../.. build
101 .PHONY: build-vpp-gcov
103 @$(MAKE) -C ../.. build-vpp-gcov
108 .build.cov.ok: build-vpp-gcov
111 .build_debug.ok: build-debug
115 test: .deps.ok .build.ok
116 @# '-' ignores the exit status, it is set in compress.sh
117 @# necessary so gmake won't skip executing the bash script
118 @-bash ./hs_test.sh --persist=$(PERSIST) --verbose=$(VERBOSE) \
119 --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \
120 --vppsrc=$(VPPSRC) --parallel=$(PARALLEL) --repeat=$(REPEAT)
121 @bash ./script/compress.sh
124 test-debug: .deps.ok .build_debug.ok
125 @# '-' ignores the exit status, it is set in compress.sh
126 @# necessary so gmake won't skip executing the bash script
127 @-bash ./hs_test.sh --persist=$(PERSIST) --verbose=$(VERBOSE) \
128 --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \
129 --vppsrc=$(VPPSRC) --parallel=$(PARALLEL) --repeat=$(REPEAT)
130 @bash ./script/compress.sh
133 test-cov: .deps.ok .build.cov.ok
134 @-bash ./hs_test.sh --persist=$(PERSIST) --verbose=$(VERBOSE) \
135 --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST-HS) --cpus=$(CPUS) \
137 @$(MAKE) -C ../.. test-cov-post HS_TEST=1
138 @bash ./script/compress.sh
142 go build ./tools/http_server
145 build: .deps.ok build-vpp-release build-go
147 bash ./script/build_hst.sh release
151 build-cov: .deps.ok build-vpp-gcov build-go
153 bash ./script/build_hst.sh gcov
157 build-debug: .deps.ok build-vpp-debug build-go
159 bash ./script/build_hst.sh debug
163 @sudo $(MAKE) install-deps
169 && apt-get install -y apt-transport-https ca-certificates curl software-properties-common \
170 apache2-utils wrk bridge-utils
171 @if [ ! -f /usr/share/keyrings/docker-archive-keyring.gpg ] ; then \
172 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg; \
173 echo "deb [arch=$(ARCH) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(UBUNTU_CODENAME) stable" \
174 | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null ; \
179 .PHONY: checkstyle-go
181 @output=$$(gofmt -d $${WS_ROOT}); \
182 if [ -z "$$output" ]; then \
183 echo "*******************************************************************"; \
184 echo "Checkstyle OK."; \
185 echo "*******************************************************************"; \
188 echo "*******************************************************************"; \
189 echo "Checkstyle failed. Use 'make fixstyle-go' or fix errors manually."; \
190 echo "*******************************************************************"; \
196 @echo "Modified files:"
197 @gofmt -w -l $(WS_ROOT)
199 @echo "*******************************************************************"
200 @echo "Fixstyle done."
201 @echo "*******************************************************************"
205 @if [ ! -f ".last_hst_ppid" ]; then \
206 echo "'.last_hst_ppid' file does not exist."; \
209 @echo "****************************"
210 @echo "Removing docker containers:"
211 @# "-" ignores errors
212 @-sudo docker rm $$(sudo docker stop $$(sudo docker ps -a -q --filter "name=$$(cat .last_hst_ppid)") -t 0)
213 @echo "****************************"
214 @echo "Removing IP address files:"
215 @find . -type f -regextype egrep -regex '.*[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' -exec sudo rm -v {} \;
216 @echo "****************************"
217 @echo "Removing network namespaces:"
218 @for ns in $$(ip netns list | grep $$(cat .last_hst_ppid) | awk '{print $$1}'); do \
220 sudo ip netns delete $$ns; \
222 @echo "****************************"
224 @echo "****************************"