From 399d44074b93d9ce7b0c7d7aae05510633725980 Mon Sep 17 00:00:00 2001 From: Adrian Villin Date: Thu, 22 Aug 2024 10:35:19 +0200 Subject: hs-test: fix incorrect exit status - exit status was incorrect when tests didn't compile - better summary formatting - removed "full stack trace: null" from summary when a test times out Type: test Change-Id: Idd6b6bf3429fc8b704dd2345d257e9bdce1b82b7 Signed-off-by: Adrian Villin --- extras/hs-test/Makefile | 24 ++++++++++-------------- extras/hs-test/hs_test.sh | 13 ++++++++++++- extras/hs-test/script/compress.sh | 2 ++ 3 files changed, 24 insertions(+), 15 deletions(-) (limited to 'extras/hs-test') diff --git a/extras/hs-test/Makefile b/extras/hs-test/Makefile index 83a42c84629..2a501580e53 100644 --- a/extras/hs-test/Makefile +++ b/extras/hs-test/Makefile @@ -119,30 +119,26 @@ 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 ./hs_test.sh --persist=$(PERSIST) --verbose=$(VERBOSE) \ + @bash ./hs_test.sh --persist=$(PERSIST) --verbose=$(VERBOSE) \ --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \ - --vppsrc=$(VPPSRC) --parallel=$(PARALLEL) --repeat=$(REPEAT) --cpu0=$(CPU0) - @bash ./script/compress.sh + --vppsrc=$(VPPSRC) --parallel=$(PARALLEL) --repeat=$(REPEAT) --cpu0=$(CPU0); \ + ./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 ./hs_test.sh --persist=$(PERSIST) --verbose=$(VERBOSE) \ + @bash ./hs_test.sh --persist=$(PERSIST) --verbose=$(VERBOSE) \ --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \ --vppsrc=$(VPPSRC) --parallel=$(PARALLEL) --repeat=$(REPEAT) --debug_build=true \ - --cpu0=$(CPU0) - @bash ./script/compress.sh + --cpu0=$(CPU0); \ + ./script/compress.sh $$? .PHONY: test-cov test-cov: .deps.ok .build.cov.ok - @-bash ./hs_test.sh --persist=$(PERSIST) --verbose=$(VERBOSE) \ + @bash ./hs_test.sh --persist=$(PERSIST) --verbose=$(VERBOSE) \ --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST-HS) --cpus=$(CPUS) \ - --vppsrc=$(VPPSRC) --cpu0=$(CPU0) - @$(MAKE) -C ../.. test-cov-post HS_TEST=1 - @bash ./script/compress.sh + --vppsrc=$(VPPSRC) --cpu0=$(CPU0); \ + ./script/compress.sh $$? .PHONY: test-leak test-leak: .deps.ok .build_debug.ok diff --git a/extras/hs-test/hs_test.sh b/extras/hs-test/hs_test.sh index c53c5a9de88..c72ef73301e 100644 --- a/extras/hs-test/hs_test.sh +++ b/extras/hs-test/hs_test.sh @@ -124,5 +124,16 @@ mkdir -p summary # shellcheck disable=SC2086 sudo -E go run github.com/onsi/ginkgo/v2/ginkgo --json-report=summary/report.json $ginkgo_args -- $args -jq -r '.[0] | .SpecReports[] | select((.State == "failed") or (.State == "timedout") or (.State == "panicked")) | select(.Failure != null) | "TestName: \(.LeafNodeText)\nSuite:\n\(.Failure.FailureNodeLocation.FileName)\nMessage:\n\(.Failure.Message)\n Full Stack Trace:\n\(.Failure.Location.FullStackTrace)\n"' summary/report.json > summary/failed-summary.log \ +if [ $? != 0 ]; then + jq -r '.[0] | .SpecReports[] | select((.State == "failed") or (.State == "timedout") or (.State == "panicked")) | select(.Failure != null) | +"TestName: + \(.LeafNodeText) +Suite: + \(.Failure.FailureNodeLocation.FileName) +Message: +\(.Failure.Message)" + + (if .Failure.Message == "A spec timeout occurred" then "\n" else +"\nFull Stack Trace: +\(.Failure.Location.FullStackTrace)\n" end)' summary/report.json > summary/failed-summary.log \ && echo "Summary generated -> summary/failed-summary.log" +fi diff --git a/extras/hs-test/script/compress.sh b/extras/hs-test/script/compress.sh index 654774842a3..09db9b6720d 100755 --- a/extras/hs-test/script/compress.sh +++ b/extras/hs-test/script/compress.sh @@ -32,4 +32,6 @@ then echo "*************************** SUMMARY ***************************" cat "${HS_ROOT}/summary/failed-summary.log" exit 1 +else + exit $1 fi -- cgit 1.2.3-korg