diff --git a/Documentation/building.md b/Documentation/building.md index aabb45b18..81daeb069 100644 --- a/Documentation/building.md +++ b/Documentation/building.md @@ -48,6 +48,18 @@ ninja -C builddir install ninja -C builddir test ``` +### Run unit tests with code coverage +#### gcov +Due to a bug in lcov, the html file will only be correct if lcov is not +installed and gcovr is installed. See +https://github.com/linux-test-project/lcov/issues/168 +https://github.com/mesonbuild/meson/issues/6747 +``` +meson setup buildcov -Db_coverage=true +ninja -C buildcov test +ninja -C buildcov coverage +``` + ## System specific information ### Ubuntu / Debian (Linux) * __linux-headers__ are version specific diff --git a/tests/tests.c b/tests/tests.c index 41972ba25..b11f64210 100644 --- a/tests/tests.c +++ b/tests/tests.c @@ -17,6 +17,7 @@ #include "io_mock.h" #include "tests.h" #include "wraps.h" +#include "io_real.h" #include #include @@ -77,6 +78,7 @@ uint8_t __wrap_sio_read(uint16_t port, uint8_t reg) static int mock_open(const char *pathname, int flags, mode_t mode) { + maybe_unmock_io(pathname); if (get_io() && get_io()->iom_open) return get_io()->iom_open(get_io()->state, pathname, flags, mode);