Paul Fagerburg 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@37 PS1, Line 37: TEST_LDFLAGS = -lcmocka
You're not using any of the actual function mocking features of cmocka in your example, btw. […]
You should definitely add at least one mock function to the example code.
https://review.coreboot.org/c/coreboot/+/39894/1/tests/lib/string-test.c File tests/lib/string-test.c:
https://review.coreboot.org/c/coreboot/+/39894/1/tests/lib/string-test.c@13 PS1, Line 13: {"is\0very", 2}, Maybe add a comment that strlen is only 2 because of the embedded \0 character?
https://review.coreboot.org/c/coreboot/+/39894/1/tests/lib/string-test.c@21 PS1, Line 21: /* Below will fail the test */ : size = strlen(NULL); In general, taking strlen of NULL (or str-anything of NULL) is a bad idea. Please explain how it fails the test. Does it return a non-zero value? Does it coredump? If it coredumps, what does Cmocka do? Can you have Cmocka catch the coredump as an expected result (like GoogleTest's DEATH tests)?