Attention is currently required from: Evan Benn.
Anastasia Klimchuk has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/69266 )
Change subject: tests: Detect gcov file io and unmock io functions ......................................................................
Patch Set 6:
(5 comments)
Commit Message:
https://review.coreboot.org/c/flashrom/+/69266/comment/aab6a688_5a3a70bc PS6, Line 9: atexit missing space: atexit -> at exit
Patchset:
PS6: I suggest this patch can be split into 3 patches: 1) Adding two new iom_* custom mocks and calling them from tests.c 2) Implementing coverage.c with unwraps, real_io, check_suffix and anything else needed for coverage (probably includes __real_* wraps too) 3) Calling handle_coverage call into mock_open.
1) ans 2) are no-op , the last patch 3) changes the behaviour.
File tests/io_mock.h:
https://review.coreboot.org/c/flashrom/+/69266/comment/4f52fdef_a2862fae PS6, Line 110: size_t (*iom_fwrite)(void *state, const void *buf, size_t size, size_t len, FILE *fp); Adding these (iom_fwrite and iom_fdopen) two can go into a separate patch, together with their callsites in tests.c
File tests/tests.c:
https://review.coreboot.org/c/flashrom/+/69266/comment/7ff0aa43_d9238b70 PS6, Line 52: real_io_mock I think you can drop _mock, this is just real_io
https://review.coreboot.org/c/flashrom/+/69266/comment/a4436626_5391c09b PS6, Line 29: static int unwrap_open(void *state, const char *pathname, int flags, mode_t mode) : { : LOG_ME; : (void)state; : return __real_open(pathname, flags, mode); : } : : static FILE *unwrap_fdopen(void *state, int fd, const char *mode) : { : LOG_ME; : (void)state; : return __real_fdopen(fd, mode); : } : : static size_t unwrap_fwrite(void *state, const void *ptr, size_t size, size_t nmemb, FILE *fp) : { : LOG_ME; : (void)state; : return __real_fwrite(ptr, size, nmemb, fp); : } : : // Mock ios that defer to the real io functions. : // These exist so that code coverage can print to real files on disk. : static const struct io_mock real_io_mock = { : .iom_open = unwrap_open, : .iom_fwrite = unwrap_fwrite, : .iom_fdopen = unwrap_fdopen, : }; Ideally, if this could go to a separate file for example `coverage.c` which would only expose one function: `handle_coverage` (name is my suggestion). This function will be called in `mock_open`. The rest of code is inside coverage.c: all unwraps, real_io, check_suffix and anything else coverage specific.