How to enable specific coverage like only branch coverage using clang source based coverage - clang

I am using clang source based coverage for one of my projects which generates metrics for line, function and region coverage.
The profile files generated are of huge sizes is there a way to optimize it?
Also, is there a way to provide option to compiler to limit instrumentation based on coverage type?
Using fprofile-instr-generate -fcoverage-mapping option for compilation and linking.
This creates huge size of profile files and it takes a lot of time and memory for merging these profile files resulting in out of memory

Related

Confguration SpecFlow feature code generation to use "locally" sequential table suffixes

Whenever I add/remove a table in one feature file it seems to affect the code generation of the other features. This causes a lot of unnecessary files to be added to commits.
For example, this diff was caused by a change in a completely different feature:
Is there a way to configure the code generation to use locally sequential suffixes? i.e. I want all suffixes for a particular feature should start at table1 or table0 instead of continuing from the value in the "previous" feature. This way changing a table in one feature has no impact on the code generation of another.
I am using SpecFlow v3.70
SpecFlow 3 generates the code-behind files using MS Build. It is recommended to remove all *.feature.cs files from version control for precisely the same reason you asked your question. These auto generated files exhibit a lot of churn, so version control is not beneficial. The real benefit is adding the feature files themselves to version control. The .feature.cs files become an artifact of the build process, rather than an asset that requires tracking.

Gcov to consider filename and function name as an input for computing code coverage

Currently in our project both our client and our team working parallelly, to build the code both teams modules code required. We are using gcov for code coverage. Currently the generated coverage shows both teams. Is there any way to generate the unit gcov coverage only for our module.(Our module doesn’t build alone).
Is there any way is available to run only for our files (or) is it possible to run based on function name?
Yes, there are two main ways to control the coverage reports that are generated:
Telling your generator (e.g. lcov, gcovr) to include/exclude certain file patterns
Compiling only your source files with coverage enabled.
(1) is much easier than (2). For example, if you are using lcov, consider the --extract option:
Use this switch if you want to extract coverage data for only a
particular set of files from a tracefile. Additional command
line parameters will be interpreted as shell wildcard patterns
(note that they may need to be escaped accordingly to prevent
the shell from expanding them first). Every file entry in
tracefile which matches at least one of those patterns will be
extracted.
(2) could be difficult (or impossible) depending on your build system. To do so, you will need to:
Compile only your module with --coverage (equivalent to -ftest-coverage -fprofile-arcs for GNU compilers)
Link your library with lgcov.
This will produce the *.gcno 'notes' files that tell coverage generators about your source files only for the files that you compiled with the --coverage flags. Then, upon running your test suite, *.gcda files should only be generated for that same set of files. Running the final coverage report/HTML generator will only produce a report for your module.
To illustrate, here's a simple CMake file that only generates coverage information for covered.cxx. Notice the extra target_compile_options and target_link_libraries for the covered library.
add_executable(${PROJECT_NAME} main.cxx)
add_library(not-covered SHARED not-covered.cxx)
add_library(covered SHARED covered.cxx)
target_compile_options(covered PRIVATE --coverage)
target_link_libraries(covered PRIVATE --coverage)
target_link_libraries(${PROJECT_NAME} covered not-covered)

Jenkins cobertura plugin - comparison of code coverage reports

does anybody know if Cobertura provides possibility to automatically compare code coverage reports of two builds? If needed, I am always doing it manually in separate tabs in browser, which takes some time for larger modules

Can nose test's coverage report only show files that don't have 100% coverage?

Nose has a very thorough report for the coverage in the files that you run it for. Here's an example report.
This report is usually extremely long since I have lots of files that I need to run coverage for.
How can I generate a report for only the files that have less than 100% coverage?
Thank you!
The report you see is produced by coverage.py, the software nose uses for coverage measurement. Coverage.py doesn't yet have a feature to omit 100% files. So there isn't a way to generate a report like you want.

Using gcovr to show zero coverage

we try to use gcovr to generate coverage report for our c++ project in Jenkins.
I was able to get it worked, but I'm stuck with one problem. gcovr doesn't show any statistics for files with zero coverage - they have only .gcno files, no .gcda files are produced and gcovr don't show it in results.
So I have 80% coverage for the whole project, but only 2 tests were written and it's actually 80% coverage only for source files involved in tests.
For large project it makes of course no sense to use such statistic.
I have found https://software.sandia.gov/trac/fast/changeset/2766 this changeset as solution for this ticket https://software.sandia.gov/trac/fast/ticket/3887, but it seems not to be working.
Did I miss something?
p.s. I use gcovr 3.1-prerelease

Resources