Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0-only |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 2 | |
Jakub Czapiga | eaf5ff3 | 2021-08-09 14:20:28 +0200 | [diff] [blame] | 3 | testsrc := $(top)/tests |
Paul Fagerburg | de6cbac | 2021-05-11 09:56:48 -0600 | [diff] [blame] | 4 | |
| 5 | # Place the build output in one of two places depending on COV, so that code |
| 6 | # built with code coverage never mixes with code built without code coverage. |
| 7 | ifeq ($(COV),1) |
Jakub Czapiga | eaf5ff3 | 2021-08-09 14:20:28 +0200 | [diff] [blame] | 8 | testobj := $(obj)/coverage |
Paul Fagerburg | de6cbac | 2021-05-11 09:56:48 -0600 | [diff] [blame] | 9 | else |
Jakub Czapiga | eaf5ff3 | 2021-08-09 14:20:28 +0200 | [diff] [blame] | 10 | testobj := $(obj)/tests |
Paul Fagerburg | de6cbac | 2021-05-11 09:56:48 -0600 | [diff] [blame] | 11 | endif |
| 12 | |
Jakub Czapiga | eaf5ff3 | 2021-08-09 14:20:28 +0200 | [diff] [blame] | 13 | cmockasrc := 3rdparty/cmocka |
| 14 | cmockaobj := $(objutil)/cmocka |
| 15 | coverage_dir := coverage_reports |
Jan Dabros | 7f00dba | 2020-05-22 09:57:17 +0200 | [diff] [blame] | 16 | |
| 17 | CMOCKA_LIB := $(cmockaobj)/src/libcmocka.so |
| 18 | |
Jakub Czapiga | eaf5ff3 | 2021-08-09 14:20:28 +0200 | [diff] [blame] | 19 | CMAKE := cmake |
| 20 | OBJCOPY ?= objcopy |
| 21 | OBJDUMP ?= objdump |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 22 | |
Jakub Czapiga | eaf5ff3 | 2021-08-09 14:20:28 +0200 | [diff] [blame] | 23 | TEST_DEFAULT_CONFIG := $(top)/configs/config.emulation_qemu_x86_i440fx |
| 24 | TEST_DOTCONFIG := $(testobj)/.config |
Jakub Czapiga | 5c3b05e | 2021-04-28 16:50:51 +0200 | [diff] [blame] | 25 | TEST_KCONFIG_AUTOHEADER := $(testobj)/config.src.h |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 26 | TEST_KCONFIG_AUTOCONFIG := $(testobj)/auto.conf |
| 27 | TEST_KCONFIG_DEPENDENCIES := $(testobj)/auto.conf.cmd |
Jakub Czapiga | 21863e3 | 2021-07-15 12:54:27 +0200 | [diff] [blame] | 28 | TEST_KCONFIG_SPLITCONFIG := $(testobj)/config/ |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 29 | TEST_KCONFIG_TRISTATE := $(testobj)/tristate.conf |
| 30 | |
Jakub Czapiga | eaf5ff3 | 2021-08-09 14:20:28 +0200 | [diff] [blame] | 31 | TEST_CFLAGS := -include $(src)/include/kconfig.h \ |
Julius Werner | 2174481 | 2020-05-04 17:44:04 -0700 | [diff] [blame] | 32 | -include $(src)/commonlib/bsd/include/commonlib/bsd/compiler.h \ |
| 33 | -include $(src)/include/rules.h |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 34 | |
| 35 | # Include generic test mock headers, before original ones |
Julius Werner | 2174481 | 2020-05-04 17:44:04 -0700 | [diff] [blame] | 36 | TEST_CFLAGS += -I$(testsrc)/include/mocks -I$(testsrc)/include |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 37 | |
| 38 | TEST_CFLAGS += -I$(src)/include -I$(src)/commonlib/include \ |
Julius Werner | 1e14de8 | 2020-06-10 15:35:08 -0700 | [diff] [blame] | 39 | -I$(src)/commonlib/bsd/include -I$(src)/arch/x86/include |
| 40 | |
| 41 | # Note: This is intentionally just a subset of the warnings in the toplevel |
| 42 | # Makefile.inc. We don't need to be as strict with test code, and things like |
| 43 | # -Wmissing-prototypes just make working with the test framework cumbersome. |
| 44 | # Only put conservative warnings here that really detect code that's obviously |
| 45 | # unintentional. |
Julius Werner | e54d784 | 2021-02-16 19:32:24 -0800 | [diff] [blame] | 46 | TEST_CFLAGS += -Wall -Werror -Wundef -Wstrict-prototypes -Wno-inline-asm |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 47 | |
| 48 | # Path for Kconfig autoheader |
| 49 | TEST_CFLAGS += -I$(dir $(TEST_KCONFIG_AUTOHEADER)) |
| 50 | |
Julius Werner | 2540037 | 2020-05-04 17:46:31 -0700 | [diff] [blame] | 51 | TEST_CFLAGS += -std=gnu11 -Os -ffunction-sections -fdata-sections -fno-builtin |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 52 | |
Jakub Czapiga | 084ad93 | 2021-03-25 13:10:31 +0100 | [diff] [blame] | 53 | TEST_CFLAGS += -D__TEST__ |
| 54 | |
Jan Dabros | 7f00dba | 2020-05-22 09:57:17 +0200 | [diff] [blame] | 55 | TEST_CFLAGS += -I$(cmockasrc)/include |
| 56 | |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 57 | # Link against Cmocka |
Jakub Czapiga | eaf5ff3 | 2021-08-09 14:20:28 +0200 | [diff] [blame] | 58 | TEST_LDFLAGS := -L$(cmockaobj)/src -lcmocka -Wl,-rpath=$(cmockaobj)/src |
Jan Dabros | 7f00dba | 2020-05-22 09:57:17 +0200 | [diff] [blame] | 59 | TEST_LDFLAGS += -Wl,--gc-sections |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 60 | |
Julius Werner | 84446e6 | 2021-02-12 17:37:27 -0800 | [diff] [blame] | 61 | # Some memlayout symbols don't work with userspace relocation -- disable it. |
| 62 | TEST_CFLAGS += -fno-pie -fno-pic |
| 63 | TEST_LDFLAGS += -no-pie |
| 64 | |
Paul Fagerburg | de6cbac | 2021-05-11 09:56:48 -0600 | [diff] [blame] | 65 | # Enable code coverage if COV=1 |
| 66 | ifeq ($(COV),1) |
| 67 | TEST_CFLAGS += --coverage |
| 68 | TEST_LDFLAGS += --coverage |
| 69 | endif |
| 70 | |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 71 | # Extra attributes for unit tests, declared per test |
Jakub Czapiga | eaf5ff3 | 2021-08-09 14:20:28 +0200 | [diff] [blame] | 72 | attributes := srcs cflags config mocks stage |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 73 | |
Jakub Czapiga | eaf5ff3 | 2021-08-09 14:20:28 +0200 | [diff] [blame] | 74 | stages := decompressor bootblock romstage smm verstage |
| 75 | stages += ramstage rmodule postcar libagesa |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 76 | |
Jakub Czapiga | eaf5ff3 | 2021-08-09 14:20:28 +0200 | [diff] [blame] | 77 | alltests := |
| 78 | subdirs := tests/arch tests/acpi tests/commonlib tests/console tests/cpu |
| 79 | subdirs += tests/device tests/drivers tests/ec tests/lib tests/mainboard |
| 80 | subdirs += tests/northbridge tests/security tests/soc tests/southbridge |
| 81 | subdirs += tests/superio tests/vendorcode |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 82 | |
| 83 | define tests-handler |
| 84 | alltests += $(1)$(2) |
| 85 | $(foreach attribute,$(attributes), |
| 86 | $(eval $(1)$(2)-$(attribute) += $($(2)-$(attribute)))) |
| 87 | $(foreach attribute,$(attributes), |
Jakub Czapiga | eaf5ff3 | 2021-08-09 14:20:28 +0200 | [diff] [blame] | 88 | $(eval $(2)-$(attribute) := )) |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 89 | |
| 90 | # Sanity check for stage attribute value |
Jakub Czapiga | eaf5ff3 | 2021-08-09 14:20:28 +0200 | [diff] [blame] | 91 | $(eval $(1)$(2)-stage := $(if $($(1)$(2)-stage),$($(1)$(2)-stage),ramstage)) |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 92 | $(if $(findstring $($(1)$(2)-stage), $(stages)),, |
| 93 | $(error Wrong $(1)$(2)-stage value $($(1)$(2)-stage). \ |
| 94 | Check your $(dir $(1)$(2))Makefile.inc)) |
| 95 | endef |
| 96 | |
Jakub Czapiga | 9bf716e | 2021-08-09 15:00:43 +0200 | [diff] [blame^] | 97 | # Copy attributes of one test to another. |
| 98 | # $1 - input test name |
| 99 | # $2 - output test name |
| 100 | copy-test = $(foreach attr,$(attributes), \ |
| 101 | $(eval $(strip $(2))-$(attr) := $($(strip $(1))-$(attr)))) |
| 102 | |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 103 | $(call add-special-class, tests) |
| 104 | $(call evaluate_subdirs) |
| 105 | |
| 106 | # Create actual targets for unit test binaries |
| 107 | # $1 - test name |
| 108 | define TEST_CC_template |
Jakub Czapiga | 5c3b05e | 2021-04-28 16:50:51 +0200 | [diff] [blame] | 109 | |
| 110 | # Generate custom config.h redefining given symbols |
Jakub Czapiga | 203698a | 2021-05-25 15:56:36 +0200 | [diff] [blame] | 111 | $(1)-config-file := $(testobj)/$(1)/config.h |
Jakub Czapiga | 5c3b05e | 2021-04-28 16:50:51 +0200 | [diff] [blame] | 112 | $$($(1)-config-file): $(TEST_KCONFIG_AUTOHEADER) |
| 113 | mkdir -p $$(dir $$@) |
| 114 | printf '// File generated by tests/Makefile.inc\n// Do not change\n' > $$@ |
| 115 | printf '#include <%s>\n\n' "$(notdir $(TEST_KCONFIG_AUTOHEADER))" >> $$@ |
| 116 | for kv in $$($(1)-config); do \ |
| 117 | key="`echo $$$$kv | cut -d '=' -f -1`"; \ |
| 118 | value="`echo $$$$kv | cut -d '=' -f 2-`"; \ |
| 119 | printf '#undef %s\n' "$$$$key" >> $$@; \ |
| 120 | printf '#define %s %s\n\n' "$$$$key" "$$$$value" >> $$@; \ |
| 121 | done |
| 122 | |
| 123 | $($(1)-objs): TEST_CFLAGS += -I$$(dir $$($(1)-config-file)) \ |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 124 | -D__$$(shell echo $$($(1)-stage) | tr '[:lower:]' '[:upper:]')__ |
Jakub Czapiga | a7a49e6 | 2021-07-29 13:27:54 +0200 | [diff] [blame] | 125 | |
| 126 | # Weaken symbols listed as mocks to enable overriding in the code |
Patrick Georgi | ce55ca2 | 2021-06-09 18:37:42 +0200 | [diff] [blame] | 127 | $($(1)-srcobjs): OBJCOPY_FLAGS += $$(foreach mock,$$($(1)-mocks),--globalize-symbol=$$(mock) --weaken-symbol=$$(mock)) |
Jakub Czapiga | a7a49e6 | 2021-07-29 13:27:54 +0200 | [diff] [blame] | 128 | |
| 129 | # Compile sources and apply mocking/wrapping of selected symbols. |
| 130 | # For each listed mock add new symbol with prefix `__real_`, |
| 131 | # and pointing to the same section:address. |
Paul Fagerburg | de6cbac | 2021-05-11 09:56:48 -0600 | [diff] [blame] | 132 | $($(1)-objs): $(testobj)/$(1)/%.o: $$$$*.c $$($(1)-config-file) |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 133 | mkdir -p $$(dir $$@) |
Yu-Ping Wu | 0f88f6f | 2021-07-20 14:32:40 +0800 | [diff] [blame] | 134 | $(HOSTCC) $(HOSTCFLAGS) $$(TEST_CFLAGS) $($(1)-cflags) -MMD \ |
| 135 | -MF $$(basename $$@).d -MT $$@ -c $$< -o $$@.orig |
Jakub Czapiga | a7a49e6 | 2021-07-29 13:27:54 +0200 | [diff] [blame] | 136 | $(OBJCOPY) $$@.orig $$(OBJCOPY_FLAGS) $$@.orig2 |
| 137 | objcopy_wrap_flags=''; \ |
| 138 | for sym in $$($(1)-mocks); do \ |
| 139 | sym_line="$$$$($(OBJDUMP) -t $$@.orig2 | grep -E "[0-9a-fA-F]+\\s+w\\s+F\\s+.*\\s$$$$sym$$$$")"; \ |
| 140 | if [ ! -z "$$$$sym_line" ] ; then \ |
| 141 | addr="$$$$(echo \"$$$$sym_line\" | awk '{ print $$$$1 }')"; \ |
| 142 | section="$$$$(echo \"$$$$sym_line\" | awk '{ print $$$$(NF - 2) }')"; \ |
| 143 | objcopy_wrap_flags="$$$$objcopy_wrap_flags --add-symbol __real_$$$${sym}=$$$${section}:0x$$$${addr},function,global"; \ |
| 144 | fi \ |
| 145 | done ; \ |
| 146 | $(OBJCOPY) $$@.orig2 $$$$objcopy_wrap_flags $$@ |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 147 | |
Jan Dabros | 7f00dba | 2020-05-22 09:57:17 +0200 | [diff] [blame] | 148 | $($(1)-bin): $($(1)-objs) $(CMOCKA_LIB) |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 149 | $(HOSTCC) $$^ $($(1)-cflags) $$(TEST_LDFLAGS) -o $$@ |
| 150 | |
| 151 | endef |
| 152 | |
| 153 | $(foreach test, $(alltests), \ |
Jakub Czapiga | eaf5ff3 | 2021-08-09 14:20:28 +0200 | [diff] [blame] | 154 | $(eval $(test)-srcobjs := $(addprefix $(testobj)/$(test)/, \ |
Patrick Georgi | ce55ca2 | 2021-06-09 18:37:42 +0200 | [diff] [blame] | 155 | $(patsubst %.c,%.o,$(filter src/%,$($(test)-srcs))))) \ |
Jakub Czapiga | eaf5ff3 | 2021-08-09 14:20:28 +0200 | [diff] [blame] | 156 | $(eval $(test)-objs := $(addprefix $(testobj)/$(test)/, \ |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 157 | $(patsubst %.c,%.o,$($(test)-srcs))))) |
| 158 | $(foreach test, $(alltests), \ |
Jakub Czapiga | eaf5ff3 | 2021-08-09 14:20:28 +0200 | [diff] [blame] | 159 | $(eval $(test)-bin := $(testobj)/$(test)/run)) |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 160 | $(foreach test, $(alltests), \ |
| 161 | $(eval $(call TEST_CC_template,$(test)))) |
| 162 | |
| 163 | $(foreach test, $(alltests), \ |
Jakub Czapiga | eaf5ff3 | 2021-08-09 14:20:28 +0200 | [diff] [blame] | 164 | $(eval all-test-objs += $($(test)-objs))) |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 165 | $(foreach test, $(alltests), \ |
Jakub Czapiga | eaf5ff3 | 2021-08-09 14:20:28 +0200 | [diff] [blame] | 166 | $(eval test-bins += $($(test)-bin))) |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 167 | |
| 168 | DEPENDENCIES += $(addsuffix .d,$(basename $(all-test-objs))) |
| 169 | -include $(DEPENDENCIES) |
| 170 | |
Jan Dabros | 7f00dba | 2020-05-22 09:57:17 +0200 | [diff] [blame] | 171 | # Build cmocka |
| 172 | $(CMOCKA_LIB): |
| 173 | echo "*** Building CMOCKA ***" |
| 174 | mkdir -p $(cmockaobj) |
| 175 | cd $(cmockaobj) && $(CMAKE) $(abspath $(cmockasrc)) |
| 176 | $(MAKE) -C $(cmockaobj) |
| 177 | |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 178 | # Kconfig targets |
| 179 | $(TEST_DOTCONFIG): |
| 180 | mkdir -p $(dir $@) |
| 181 | cp $(TEST_DEFAULT_CONFIG) $(TEST_DOTCONFIG) |
| 182 | |
| 183 | # Don't override default Kconfig variables, since this will affect all |
| 184 | # Kconfig targets. Change them only when calling sub-make instead. |
Jakub Czapiga | eaf5ff3 | 2021-08-09 14:20:28 +0200 | [diff] [blame] | 185 | $(TEST_KCONFIG_AUTOHEADER): TEST_KCONFIG_FLAGS := DOTCONFIG=$(TEST_DOTCONFIG) \ |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 186 | KCONFIG_AUTOHEADER=$(TEST_KCONFIG_AUTOHEADER) \ |
| 187 | KCONFIG_AUTOCONFIG=$(TEST_KCONFIG_AUTOCONFIG) \ |
| 188 | KCONFIG_DEPENDENCIES=$(TEST_KCONFIG_DEPENDENCIES) \ |
| 189 | KCONFIG_SPLITCONFIG=$(TEST_KCONFIG_SPLITCONFIG) \ |
| 190 | KCONFIG_TRISTATE=$(TEST_KCONFIG_TRISTATE) \ |
| 191 | KBUILD_DEFCONFIG=$(TEST_DEFAULT_CONFIG) |
| 192 | |
| 193 | $(TEST_KCONFIG_AUTOHEADER): $(TEST_DOTCONFIG) $(objutil)/kconfig/conf |
| 194 | mkdir -p $(dir $@) |
Patrick Georgi | 53ea1d4 | 2019-11-22 16:55:58 +0100 | [diff] [blame] | 195 | $(MAKE) $(TEST_KCONFIG_FLAGS) olddefconfig |
| 196 | $(MAKE) $(TEST_KCONFIG_FLAGS) syncconfig |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 197 | |
| 198 | $(TEST_KCONFIG_AUTOCONFIG): $(TEST_KCONFIG_AUTOHEADER) |
| 199 | true |
| 200 | |
| 201 | .PHONY: $(alltests) $(addprefix clean-,$(alltests)) |
| 202 | .PHONY: unit-tests build-unit-tests run-unit-tests clean-unit-tests |
| 203 | |
Patrick Georgi | a0a198f | 2020-05-27 10:59:09 +0200 | [diff] [blame] | 204 | ifeq ($(JUNIT_OUTPUT),y) |
| 205 | $(alltests): export CMOCKA_MESSAGE_OUTPUT=xml |
Jakub Czapiga | 1add483 | 2021-03-05 11:37:23 +0100 | [diff] [blame] | 206 | $(alltests): export CMOCKA_XML_FILE=$(testobj)/junit-$(subst /,_,$^)-%g.xml |
Patrick Georgi | a0a198f | 2020-05-27 10:59:09 +0200 | [diff] [blame] | 207 | endif |
| 208 | |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 209 | $(alltests): $$($$(@)-bin) |
Patrick Georgi | 1b35ec9 | 2020-05-27 11:39:32 +0200 | [diff] [blame] | 210 | rm -f $(testobj)/junit-$(subst /,_,$^).xml $(testobj)/$(subst /,_,$^).failed |
| 211 | -./$^ || echo failed > $(testobj)/$(subst /,_,$^).failed |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 212 | |
Paul Fagerburg | de6cbac | 2021-05-11 09:56:48 -0600 | [diff] [blame] | 213 | # Build a code coverage report by collecting all the gcov files into a single |
| 214 | # report. If COV is not set, this might be a user error, and they're trying |
| 215 | # to generate a coverage report without first having built and run the code |
| 216 | # with code coverage. So instead of silently correcting it by adding COV=1, |
| 217 | # let's flag it to the user so they can be sure they're doing the thing they |
| 218 | # want to do. |
Paul Fagerburg | 045fbf1 | 2021-04-16 11:36:25 -0600 | [diff] [blame] | 219 | |
Paul Fagerburg | de6cbac | 2021-05-11 09:56:48 -0600 | [diff] [blame] | 220 | .PHONY: coverage-report clean-coverage-report |
| 221 | |
| 222 | ifeq ($(COV),1) |
| 223 | coverage-report: |
| 224 | lcov -o $(testobj)/tests.info -c -d $(testobj) --exclude '$(testsrc)/*' |
| 225 | genhtml -q -o $(testobj)/$(coverage_dir) -t "coreboot unit tests" \ |
Paul Fagerburg | 045fbf1 | 2021-04-16 11:36:25 -0600 | [diff] [blame] | 226 | -s $(testobj)/tests.info |
| 227 | |
Paul Fagerburg | de6cbac | 2021-05-11 09:56:48 -0600 | [diff] [blame] | 228 | clean-coverage-report: |
| 229 | rm -Rf $(testobj)/$(coverage_dir) |
| 230 | else |
| 231 | coverage-report: |
| 232 | COV=1 V=$(V) $(MAKE) coverage-report |
| 233 | |
| 234 | clean-coverage-report: |
| 235 | COV=1 V=$(V) $(MAKE) clean-coverage-report |
| 236 | endif |
| 237 | |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 238 | unit-tests: build-unit-tests run-unit-tests |
| 239 | |
| 240 | build-unit-tests: $(test-bins) |
| 241 | |
| 242 | run-unit-tests: $(alltests) |
Patrick Georgi | 1b35ec9 | 2020-05-27 11:39:32 +0200 | [diff] [blame] | 243 | if [ `find $(testobj) -name '*.failed' | wc -l` -gt 0 ]; then \ |
| 244 | echo "**********************"; \ |
| 245 | echo " TESTS FAILED"; \ |
| 246 | echo "**********************"; \ |
| 247 | exit 1; \ |
| 248 | else \ |
| 249 | echo "**********************"; \ |
| 250 | echo " ALL TESTS PASSED"; \ |
| 251 | echo "**********************"; \ |
| 252 | exit 0; \ |
| 253 | fi |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 254 | |
| 255 | $(addprefix clean-,$(alltests)): clean-%: |
Paul Fagerburg | de6cbac | 2021-05-11 09:56:48 -0600 | [diff] [blame] | 256 | rm -rf $(testobj)/$* |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 257 | |
| 258 | clean-unit-tests: |
| 259 | rm -rf $(testobj) |
Jakub Czapiga | a4819b3 | 2021-04-13 16:07:05 +0200 | [diff] [blame] | 260 | |
| 261 | list-unit-tests: |
| 262 | @echo "unit-tests:" |
| 263 | for t in $(sort $(alltests)); do \ |
| 264 | echo " $$t"; \ |
| 265 | done |
| 266 | |
| 267 | help-unit-tests help:: |
| 268 | @echo '*** coreboot unit-tests targets ***' |
Paul Fagerburg | de6cbac | 2021-05-11 09:56:48 -0600 | [diff] [blame] | 269 | @echo ' Use "COV=1 make [target]" to enable code coverage for unit tests' |
Paul Fagerburg | 045fbf1 | 2021-04-16 11:36:25 -0600 | [diff] [blame] | 270 | @echo ' unit-tests - Run all unit-tests from tests/' |
| 271 | @echo ' clean-unit-tests - Remove unit-tests build artifacts' |
| 272 | @echo ' list-unit-tests - List all unit-tests' |
| 273 | @echo ' <unit-test> - Build and run single unit-test' |
| 274 | @echo ' clean-<unit-test> - Remove single unit-test build artifacts' |
Paul Fagerburg | de6cbac | 2021-05-11 09:56:48 -0600 | [diff] [blame] | 275 | @echo ' coverage-report - Generate a code coverage report' |
| 276 | @echo ' clean-coverage-report - Remove the code coverage report' |
Jakub Czapiga | a4819b3 | 2021-04-13 16:07:05 +0200 | [diff] [blame] | 277 | @echo |