Anastasia Klimchuk submitted this change.

View Change



13 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.

Approvals: build bot (Jenkins): Verified Anastasia Klimchuk: Looks good to me, approved
tests: Detect gcov run and redirect to real I/O functions

Code coverage writes data to disk, we need to use real io functions at
this point so that the data is really written.

BUG=b:187647884
BRANCH=None
TEST=meson test
TEST=ninja coverage

Change-Id: If06053ecd78e886c8f7fc55813f4b5635be78c6b
Signed-off-by: Evan Benn <evanbenn@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/69266
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
---
M Documentation/building.md
M tests/tests.c
2 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/Documentation/building.md b/Documentation/building.md
index aabb45b..81daeb0 100644
--- a/Documentation/building.md
+++ b/Documentation/building.md
@@ -48,6 +48,18 @@
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 41972ba..b11f642 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 <stdio.h>
#include <string.h>
@@ -77,6 +78,7 @@

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);


To view, visit change 69266. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: If06053ecd78e886c8f7fc55813f4b5635be78c6b
Gerrit-Change-Number: 69266
Gerrit-PatchSet: 15
Gerrit-Owner: Evan Benn <evanbenn@google.com>
Gerrit-Reviewer: Anastasia Klimchuk <aklm@chromium.org>
Gerrit-Reviewer: Thomas Heijligen <src@posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-CC: Felix Singer <felixsinger@posteo.net>
Gerrit-MessageType: merged