gcov plugin: Unable to exclude certain source files from gcov coverage test

666 views
Skip to first unread message

miecc kn

unread,
Apr 7, 2022, 7:14:54 AM4/7/22
to ThrowTheSwitch Forums
Environment:
Project tested with ceedling
$ ceedling version
Ceedling:: 0.31.1
Unity:: 2.5.4
CMock:: 2.5.4
CException:: 1.3.3
$ gcov -v
gcov (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
$ gcc -v
gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)

Hello everyone,

I have been trying to use the gcov plugin and it does work in general, creating a coverage report for all files in my project.
However, I now want to exclude a certain set of files and/or directories so that the report is clean(er) but I am struggling to define the right patterns for it.

The setup is as follows: 
$ tree
.
├── CMakeLists.txt
├── Proj_Makefile
├── project.yml
├── README.md
├── app
│   ├── CMakeLists.txt
│   └── main.c
├── src
│   ├── CMakeLists.txt
│   ├── mysourcefile.c
│   ├── mysourcefile.h
│   └── system_abstractions
│       ├── abstraction_file_io.h
│       └── abstraction_file_unix.c
└── test
    ├── CMakeLists.txt
    ├── support
    └── test_mysourcefile.c

I have my library "mysourcefile" and a corresponding unity test for it, for which I want to create a coverage report. However, the files in the directory system_abstractions should be excluded from the report as they a) are not meant to be tested (excluding the reason why for brevity), but need to be in that location for platform compilation compliance reasons and b) pollute the report, mostly by not being built by ceedling as they are not tested and thus reporting "Could not find coverage results  for src/system_abstractions/abstraction_file_unix.c"
I also noticed that files such as "build/test/runners/test_metafile_internal_runner.c" or 
"build/test/mocks/mock_abstraction_file_io.c" are seemingly processed by gcov(?), which I would like to avoid if possible.

My question is, how do I exclude these files from being processed and reported, so that only the true src files under test are really checked for coverage? In my current example, everything in src/ that is not in src/system_abstractions/.

So far I have added the following to my gcov section in the project.yml and various other combinations of a regex have so far yielded no difference, making me wonder if I am using this correctly at all:
:gcov:
  :utilities:
    - gcovr
  :reports:
    # - HtmlDetailed
    - lcov
  :gcovr:
    :report_exclude: "abstraction_.*"
    :gcov_exclude: "abstraction_.*"
    :exclude_directories: "src/system_abstractions"
    :report_root: "."
    :html_medium_threshold: 75
    :html_high_threshold: 90

Especially the reporting of "Could not find coverage results for src/system_abstractions/abstraction_file_unix.c" is what is bothering me the most and getting rid of that would already be a huge benefit.

Reply all
Reply to author
Forward
0 new messages