gcovr does't generate reports for some branches on Jenkins - gcov

We found that for some of our Github branches that are automatically pulled into Jenkins, gcovr does not generate any coverage information. It claims that no files are found and returns a code coverage of 0%.
Other branches work fine. Once we pull the code into master, gcovr can generate code coverage files for the very same code.

This happens because gcov creates files that hold the entire path, e.g. #usr#include#boost#numeric#conversion#detail#converter.hpp.gcov. If the branch name is part of Jenkins' workspace path, a long branch name may kick some of these generated file names over the filesystem's maximum file name length.
To fix this, set gcov to hash the filenames and run gcovr in two passes:
gcovr -r `pwd` --gcov-executable="gcov -s `pwd` -x" -k
gcovr -r `pwd` --gcov-executable="gcov -s `pwd` -x" -g --html --html-details -o coverage/index.html

Related

How to include all targets in bazel coverage

How do I include non-test targets in bazel coverage? Currently I use the following bazel command to get code coverage:
bazel coverage \
--instrument_test_targets \
--experimental_cc_coverage \
--combined_report=lcov \
//... --test_arg=--logtostderr
The project is written in C++. The command works fine. However, the output lcov trace file only includes the files that have coverage. If a C file does not have a test, it is not in the lcov trace file.
Does bazel coverage only executes the test targets? Is there a way to include all targets (the non-test targets)? So that even if a file has no test, I can still see it in the report (the report will show zero coverage). The intention for this is that if someone adds new files and doesn't write unit test, the file can be shown in coverage report.
Can you reproduce using --incompatible_cc_coverage?

Bazel: How to exclude path from code coverage for Scala / Java?

I am using Bazel with rules_scala. My problem now is how to exclude files from code coverage. So far this is how I am running coverage:
rm -rf coverage
bazel coverage --combined_report=lcov --coverage_report_generator="#bazel_tools//tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator:Main" ...
genhtml -o coverage --ignore-errors source bazel-out/_coverage/_coverage_report.dat
But there are some folders I would like to exclude from code coverage. I tried using the --instrumentation_filter flag, but no matter what I tried putting there Bazel still collect coverage for this folder.
Are there any examples how I should use this flag?
Thanks!
Use
bazel coverage --combined_report=lcov --coverage_report_generator="#bazel_tools//tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator:Main" -- //... -//package/to/ignore/...
This appears to be a bug with rules_scala. See this issue for more details.

Unable to generate gcda files in cross-profile environment

Trying to run gcov, by building source code in an environment different from run environment. I have built source code with --coverage option.
To ensure that if I run
strings -a binary| grep gcda
I am able to see some gcda files. But when I deploy rpm in docker container and run the testcase I don't see .gcda files getting generated.
I have added GCOV_PREFIX and GCOV_PREFIX_STRIP variables.

Jmeter --- generate separate .jtl result file for every run

How to generate a separate .jtl result file for each run. Following is my command which i am running using jenkins job (Performance trend plugin).
cd /apache-jmeter-2.13/bin
./jmeter.sh -n -t /jmxFiles/Jbpm6Rest3Jenkins1.jmx -l /jmxFiles/SIP.jtl -JUSERS=${USER_COUNT} -JRampUp=${RAMP_UP} -JLoopCount=${LOOP_COUNT}
Currently SIP.jtl file is appending result in same file for every run.
How to generate a separate .jtl result file for each run (SIP1, SIP2, SIP3 etc) and should display in Jenkins performance trend.?
you just need to add time function just after or before your JTL file name
Example:- jmeter -n -t Test_Plan.jmx -l
LOG_${__time(yy-MM-dd-HH-mm-ss-SS)}.jtl

Generating empty .gcda files

I use gcov for doing code coverage analysis with lcov for generating graphical output of coverage. This works well for code file where atleast some part of object file has been executed. I want to be able to track files which have not been executed at all. I suspect this has to do with .gcda files not being generated for these files. Is there a way to force the generation of .gcda file for all object files irrespective of execution?
The procedure to do this is outlined here:
http://linux.die.net/man/1/lcov
Recommended procedure when capturing data for a test case:
create baseline coverage data file
lcov -c -i -d appdir -o app_base.info
perform test
appdir/test
create test coverage data file
lcov -c -d appdir -o app_test.info
combine baseline and test coverage data
lcov -a app_base.info -a app_test.info -o app_total.info
For all of your files that are correctly compiled and linked, there will be a .gcda file. If you see that there's a missing *.gcda file check to see if the *.gcno file exists. If it doesn't check to see if all of you Makefiles are correctly build with:
-ftest-coverage : The .gcno notes file is generated when the source file is compiled with this
-fprofile-arcs : .gcda count data file is generated when a program containing object files built with the GCC -fprofile-arcs option is executed.
More info on: https://gcc.gnu.org/onlinedocs/gcc/Gcov.html#Gcov

Resources