From 7d1e4a4ddba8c2fb5b269ea51e75edf28de156ea Mon Sep 17 00:00:00 2001 From: Adrian Villin Date: Thu, 13 Jun 2024 08:59:58 +0200 Subject: hs-test: added cleanup target - Also added checkstyle-go and fixstyle-go to 'make help' Type: make Change-Id: I5402efa02bbbc54a20db8f54b0488c58a62ffaa1 Signed-off-by: Adrian Villin --- extras/hs-test/Makefile | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'extras/hs-test/Makefile') diff --git a/extras/hs-test/Makefile b/extras/hs-test/Makefile index 118afefa543..7fab6dca514 100644 --- a/extras/hs-test/Makefile +++ b/extras/hs-test/Makefile @@ -67,6 +67,7 @@ help: @echo " build-go - just build golang files" @echo " checkstyle-go - check style of .go source files" @echo " fixstyle-go - format .go source files" + @echo " cleanup-hst - stops and removes all docker contaiers and namespaces" @echo " list-tests - list all tests" @echo @echo "make build arguments:" @@ -114,25 +115,25 @@ build-vpp-gcov: .PHONY: test test: .deps.ok .build.ok - # '-' ignores the exit status, it is set in compress.sh - # necessary so gmake won't skip executing the bash script - -bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \ + @# '-' ignores the exit status, it is set in compress.sh + @# necessary so gmake won't skip executing the bash script + @-bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \ --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \ --vppsrc=$(VPPSRC) --parallel=$(PARALLEL) --repeat=$(REPEAT) @bash ./script/compress.sh .PHONY: test-debug test-debug: .deps.ok .build_debug.ok - # '-' ignores the exit status, it is set in compress.sh - # necessary so gmake won't skip executing the bash script - -bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \ + @# '-' ignores the exit status, it is set in compress.sh + @# necessary so gmake won't skip executing the bash script + @-bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \ --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \ --vppsrc=$(VPPSRC) --parallel=$(PARALLEL) --repeat=$(REPEAT) @bash ./script/compress.sh .PHONY: test-cov test-cov: .deps.ok .build.cov.ok - -bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \ + @-bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \ --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST-HS) --cpus=$(CPUS) \ --vppsrc=$(VPPSRC) @$(MAKE) -C ../.. test-cov-post HS_TEST=1 @@ -200,3 +201,26 @@ fixstyle-go: @echo "*******************************************************************" @echo "Fixstyle done." @echo "*******************************************************************" + +.PHONY: cleanup-hst +cleanup-hst: + @if [ ! -f ".last_hst_ppid" ]; then \ + echo "'.last_hst_ppid' file does not exist."; \ + exit 1; \ + fi + @echo "****************************" + @echo "Removing docker containers:" + @# "-" ignores errors + @-sudo docker rm $$(sudo docker stop $$(sudo docker ps -a -q --filter "name=$$(cat .last_hst_ppid)") -t 0) + @echo "****************************" + @echo "Removing IP address files:" + @find . -type f -regextype egrep -regex '.*[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' -exec sudo rm -v {} \; + @echo "****************************" + @echo "Removing network namespaces:" + @for ns in $$(ip netns list | grep $$(cat .last_hst_ppid) | awk '{print $$1}'); do \ + echo $$ns; \ + sudo ip netns delete $$ns; \ + done + @echo "****************************" + @echo "Done." + @echo "****************************" -- cgit 1.2.3-korg