Attention is currently required from: Evan Benn.
5 comments:
Commit Message:
Patch Set #6, Line 9: atexit
missing space: atexit -> at exit
Patchset:
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:
Patch Set #6, 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:
Patch Set #6, Line 52: real_io_mock
I think you can drop _mock, this is just real_io
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.
To view, visit change 69266. To unsubscribe, or for help writing mail filters, visit settings.