1

I wrote a few python tests that run cpp binaries as subprocess. Python code is in charge of performing tests on that process.

I run these python tests in py_test bazel rule. Problem is that this doesn't count as if our cpp code is covered with tests because py_test rule can only do test coverga for python files. Files used to generate coverage are .gcda files and those files are generated when we run bazel coverage test_name. In our case the coverage of cpp files is impossible to do since tests are running as py_test and bazel has an open bug for that.

I tried to add copts = ["-fprofile-arcs","-ftest-coverage"] and linkopts = ["-fprofile-arcs", "-lgcov --coverage"] flags in cc_binary rule that builds cpp binaries (we test those executables with py_test), but the only thing that we manage to do is to get .gcno files (probably because our cc_binary is only built and not run).

Any idea how to get .gcda files or get coverage any other way?

1 Answers1

0

Once you run your binary, you can see the .gcda files generated. https://gcc.gnu.org/onlinedocs/gcc/Gcov-Data-Files.html The .gcda count data file is generated when a program containing object files built with the GCC -fprofile-arcs option is executed. A separate .gcda file is created for each object file compiled with this option. It contains arc transition counts, value profile counts, and some summary information.