2

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
  • I would also be highly interested in an answer to this. Commented Aug 16, 2019 at 12:02

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.