Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39894 )
Change subject: tests: Add build subsystem and example for unit tests ......................................................................
Patch Set 1:
(3 comments)
https://review.coreboot.org/c/coreboot/+/39894/1/tests/Makefile.inc File tests/Makefile.inc:
https://review.coreboot.org/c/coreboot/+/39894/1/tests/Makefile.inc@26 PS1, Line 26: # Minimal required set for simplicity sake We'll likely need to reuse the normal coreboot CFLAGS because some of them modify behavior (e.g. certain code won't work without -O2 or -Wl,--gc-sections).
https://review.coreboot.org/c/coreboot/+/39894/1/tests/Makefile.inc@50 PS1, Line 50: $$(addprefix $$(SRC_DIR),$$(subst -test,.c,$$*)) This is an interesting approach but I don't think it will be flexible enough to support everything we'll want to do. I guess strict "unit testing" would only cover one function but I think ultimately we'll want to be able to cover larger components consisting of multiple files as well. Otherwise, we'll just force weird constraints on ourselves about what needs to be put in the same file in the main sources (and may create big headaches about how to port the tests whenever some refactoring splits a function in two).
https://review.coreboot.org/c/coreboot/+/39894/1/tests/include/config.h File tests/include/config.h:
PS1: What's our overall plan with Kconfig for the unit tests? Do we have one yet? I assume for most tests we can use a common base config (e.g. qemu-x86) but there will always be cases where a test needs some special config, or we even want to test the same function with multiple different values for a certain config. We should have a common way to implement tests for those kinds of situations.
Also, configs should get auto-generated and not checked in like this so they don't have to be fixed manually when the underlying Kconfig files change.