Jakub Czapiga has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/58163 )
Change subject: tests: Fix JUNIT_OUTPUT=y to write to files instead of stderr ......................................................................
tests: Fix JUNIT_OUTPUT=y to write to files instead of stderr
CB:57144 broke JUNIT_OUTPUT=y, and unit-tests were writing to stderr instead of selected XML files, because test name used for XML file creation contains test path. Build system did not create necessary directiories, which CMocka required to create output files. This commit fixes this behaviour and now JUNIT_OUTPUT=y forces cmocka to write logs to `<test-name>(<test-group>)-junit.xml`, which for tests using macro cb_run_group_tests(), should expand to `$(testobj)/path/to/nice-test(test)-junit.xml`. Example: Test: tests/lib/cbfs-lookup-no-mcache-test Output file: `build/tests/tests/lib/cbfs-lookup-no-mcache-test(cbfs_lookup_aligned_and_unaligned_tests)-junit.xml
Change-Id: I09891aca923bf1271cafeaa09f89b6539022709c Signed-off-by: Jakub Czapiga jacz@semihalf.com --- M tests/Makefile.inc 1 file changed, 5 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/63/58163/1
diff --git a/tests/Makefile.inc b/tests/Makefile.inc index 5027dd8..9e54f65 100644 --- a/tests/Makefile.inc +++ b/tests/Makefile.inc @@ -220,13 +220,16 @@ .PHONY: $(alltests) $(addprefix clean-,$(alltests)) .PHONY: unit-tests build-unit-tests run-unit-tests clean-unit-tests
+# %g in CMOCKA_XML_FILE will be replaced with "__TEST_NAME__(<test-group-name>)" +# by macro cb_run_group_tests(), which should be used for running tests. +# __TEST_NAME__ contains test name including path e.g. tests/lib/rtc-test ifeq ($(JUNIT_OUTPUT),y) $(alltests): export CMOCKA_MESSAGE_OUTPUT=xml -$(alltests): export CMOCKA_XML_FILE=$(testobj)/junit-$(subst /,_,$^)-%g.xml +$(alltests): export CMOCKA_XML_FILE=$(testobj)/%g-junit.xml endif
$(alltests): $$($$(@)-bin) - rm -f $(testobj)/junit-$(subst /,_,$^).xml $(testobj)/$(subst /,_,$^).failed + rm -f $(patsubst %/,%,$(dir $^))(*)-junit.xml $(testobj)/$(subst /,_,$^).failed -./$^ || echo failed > $(testobj)/$(subst /,_,$^).failed
# Build a code coverage report by collecting all the gcov files into a single