Code coverage incorrect / overwritten when project has multiple files
Hi there!
I'm facing problems when calculating the code coverage over a project.
When I run the tests to my project with the comand ceedling project:$project_name gcov:all utils:gcov, I get the wrong result. A look into the output quickly reveals the underlying problem:
libgcov profiling error:/home/lo/data/git_repos (copy)/sw/build/test_units/gcov/out/logger.gcda:overwriting an existing profile data with a different timestamp
I found that if the same source file is used in 2 or more separate tests_*.c files, only the coverage data of the last to run makes it into the result as all the results of the other runs are overwritten.
After some research, I found this Stackoverflow question / answer covering this issue. This link was also posted in #506 as kind of an answer. However, the only way I see to utilize this information would be to run each test individually, saving the code coverage file between each test and merging it manually afterwards. Running all tests automatically is a feature I very like about ceedling, to automate it myself would take away a key functionality of it. This is why - if I'm not missing something or making a mistake - I kind of feel like this is a bug, as it makes the gcov:all utils:gcov option in many cases unusable.
That leads me to my question: Is there a way to get ceedling to save all coverage results of all individual test separately? This would prevent the overwriting, allowing me to merge the files without having to run each test individually. Is there something that I'm missing or doing wrong about this whole problem? Of course, a way to have ceedling merge the results for me automatically would also be nice, but I would be totally happy with the first option.
If you need any more information, let me know. Thanks a lot for your help!
PS: I do the "manual merging" of the coverage files by enabling the JSON report and calling
gcovr -r . -a ${coverage_file_path[0]} \
-a ${coverage_file_path[1]} \
-a ${coverage_file_path[2]} \
-a ${coverage_file_path[3]} \
--html-details test_artifacts/coverage/coverage_report.html
Hi
If this can help : I am using multiple test files test_MyFile.c and test_MyFile_private.c and running ceedling on a single call :
ceedling project:myproject gcov:pattern[test_MyFile*] utils:gcov
Or
ceedling project:myproject gcov:all utils:gcov
Run both / all test files and merge gcov output.
Gcov output are overwritten only when I run a single test file.
Do you still have this problem when you call ceedling clobber before running gcov:all ?
Ah, this is interesting. So it might be only a problem with my version / configuration. But unfortunately, it happens even with an empty build folder. Do you have any other guesses?
Output of ceedling version:
Welcome to Ceedling!
Ceedling:: 0.31.1
CMock:: 2.5.4
Unity:: 2.5.4
CException:: 1.3.3
Here is my project.yml file shared by all projects: project.txt
and the specific yml file for one project: test_units.txt
I am still using Ceedling 0.31.0 maybe this is different in 0.31.1
My project file is similar to yours with these main differences :
:use_deep_dependencies: TRUE
:gcov:
:html_report: TRUE
:html_report_type: detailed
:html_medium_threshold: 75
:html_high_threshold: 90
:xml_report: FALSE
:reports:
- SonarQube