Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gcov only reports coverage results for modules which have a test file #329

Open
roel0 opened this issue Feb 4, 2019 · 8 comments
Open

Comments

@roel0
Copy link

roel0 commented Feb 4, 2019

Gcov only reports coverage results for modules which have a test file.

Ceedling currently ignores the modules which don't have a test file, hence the overall code coverage reported by gcov is meaningless.

A workaround is to create empty test files for modules which don't have tests yet...

@dpostorivo
Copy link
Contributor

Can you provide a minimal example repo to reproduce this issue? I know with the filters off, the gcov utility will show any file touched by the tests even unity.

@roel0
Copy link
Author

roel0 commented Feb 4, 2019

Let's say I've the following project:
|
|- src/module_a.c
|- src/module_b.c
|- test/test_module_a.c

Gcov results will only give the coverage for module_a.c because module_b.c isn't touched by any test. This also means that the overall code coverage number is misleading.

Wouldn't it be a better practice if ceedling would take the untested modules into account automatically based on the defined source path in the project.yml file?

@dpostorivo
Copy link
Contributor

Ceedling could do this, but the current ceedling gcov implementation is tied closely to how gcov works which will only give you data on what you compile. A simple work around for this is to have a test file for every module to make sure they are all compiled.

I do think this would be something we could eventually tackle, but I'm not sure how much complexity it adds. I may do some simple investigation today to see if it's feasible.

@tobyjwebb
Copy link
Contributor

tobyjwebb commented Dec 17, 2019

Just FYI: I am currently working on a solution where if any files without coverage are detected, the command aborts with an error status (if enabled in the project.yml), with an optional list of files to exclude from this behaviour. I'll try to remember to drop a note here once the PR gets accepted. (It is actually implemented at the moment, but we're having some other issues with the latest changes which need addressing first.)

@beckerzito
Copy link

@tobyjwebb I saw that this feature was merged to master, but I still have a question. On the optional list of files to exclude, is it possible to add an entire folder and subfolder, like I do in :path_test: for exaemple: - src/**.

I'm asking this, because on the :path_test: of my ceedling project, I informed an entire source project folder with many source and header files. Then I create a test module for a specific source file with mocks for that.

However, when I perform the coverage analysis with gcov, I'm getting the error "Could not find coverage results for ..." for all the other source files on the folder. I'm not understanding why.

I need some kind of configuration where the gcov should analyze only the file under testing. Is there any configuration for that?

Or is there any other better solution in my case? good practice that I'm not following?

thank you!

@tobyjwebb
Copy link
Contributor

Hi @beckerzito

I need some kind of configuration where the gcov should analyze only the file under testing. Is there any configuration for that?

... Nope, sorry. What I'm doing at the moment is just commenting the line in the project.yml. It's not prefect, but it kinda works.

What would be nice to have is that this setting should only apply when gcov:all is used.

@kapitan-iglu
Copy link

Hi,
I recently hit this problem too. Even though I have only few source files covered by tests there is always 100% files coverage in Cobertura results. This is misleading and I expect to see real files coverage status over all source files even if there is no test_*.c file created.

Is there any way (after few years) how to generate empty coverage results for missing files?

Something like: for every source file stated in Could not find coverage results for xyz.c empty results would be generated instead. On overall report generation this will ensure real coverage calculation.

Creating empty test files for 100+ sources is...the last option :(

@mkschreder
Copy link

How hard can it be for lcov to simply generate an empty info file with zero counters for all C files in a directory?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants