diff options
author | Jan Dabros <jsd@semihalf.com> | 2020-03-28 00:15:03 +0100 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2020-05-01 06:32:47 +0000 |
commit | ef1c968374ab9eb599ec18523700e0dacbeef351 (patch) | |
tree | 529bf710fe95d6aa6fc03e15ecd99a7ada130365 /Makefile | |
parent | 6449b674275812da9b7d69da99bedf0debfaa17f (diff) |
tests: Add build subsystem for unit testing coreboot
Add a subsystem which will be used for writing, building and running
unit tests for different coreboot's modules. This work is built using
Cmocka unit testing framework. Description of what unit testing means
(for the author) and how unit testing framework evaluation was performed
may be found in Documentation/technotes/2020-03-unit-testing-coreboot.md
Makefiles structure is very similar to this used for building coreboot
images. Every directory has its own Makefile.inc were tests' names,
sources, subdirs and multiple other test-related attributes are defined
in form of variables.
Signed-off-by: Jan Dabros <jsd@semihalf.com>
Change-Id: I9b0220b84b9a6e448476ca3eb3ccccc5fb829ad1
Reviewed-on: https://review.coreboot.org/c/coreboot/+/39894
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -141,6 +141,14 @@ NOMKDIR:=1 endif endif +ifneq ($(filter %-test %-tests,$(MAKECMDGOALS)),) +ifneq ($(filter-out %-test %-tests, $(MAKECMDGOALS)),) +$(error Cannot mix unit-tests targets with other targets) +endif +UNIT_TEST:=1 +NOCOMPILE:= +endif + .xcompile: util/xcompile/xcompile rm -f $@ $< $(XGCCPATH) > $@.tmp @@ -159,7 +167,9 @@ real-all: @exit 1 else +ifneq ($(UNIT_TEST),1) include $(DOTCONFIG) +endif # in addition to the dependency below, create the file if it doesn't exist # to silence stupid warnings about a file that would be generated anyway. @@ -177,7 +187,9 @@ ifneq ($(CONFIG_MMX),y) CFLAGS_x86_32 += -mno-mmx endif +ifneq ($(UNIT_TEST),1) include toolchain.inc +endif strip_quotes = $(strip $(subst ",,$(subst \",,$(1)))) # fix makefile syntax highlighting after strip macro \" ")) @@ -276,7 +288,14 @@ evaluate_subdirs= \ # collect all object files eligible for building subdirs:=$(TOPLEVEL) postinclude-hooks := + +# Don't iterate through Makefile.incs under src/ when building tests +ifneq ($(UNIT_TEST),1) $(eval $(call evaluate_subdirs)) +else +include $(TOPLEVEL)/tests/Makefile.inc +endif + ifeq ($(FAILBUILD),1) $(error cannot continue build) endif |