How to generate a test coverage report after compiling opencv4.5.2?

I added the ENABLE_COVERAGE option when compiling, but I don’t know how to generate the test coverage report later. Is there a specific method?

Please check logs of nightly converage jobs for actual commands: BuildBot: Open Source Computer Vision Library

Actually I want to generate the test coverage report locally.
But i didn’t succeed

Yes, I understand. I meant that you can see which commands are used to produce reports on CI servers and then reproduce them locally.

  1. Build OpenCV with ENABLE_COVERAGE option
  2. In build directory (cleanup and init counters):
    • rm -rf coverage_html tmp*.gcno
    • lcov --directory /build/master-contrib_coverage-lin64-debug/build --zerocounters
    • lcov --directory /build/master-contrib_coverage-lin64-debug/build --capture --initial -o opencv_base.info
  3. Run tests
  4. In build directory (capture, filter and generate html report):
    • lcov --directory /build/master-contrib_coverage-lin64-debug/build --capture -o opencv_test.info
    • lcov -a opencv_base.info -a opencv_test.info -o opencv_total.info
    • lcov --remove opencv_total.info '/usr/include/*' '/usr/lib/*' '/usr/local/include/*' '*/opencv/apps/*' '*/opencv/samples/*' '*/opencv/3rdparty/*' '*/opencv/modules/ts/*' '*/opencv/modules/*/perf/*' '*/opencv/modules/*/test/*' '*/opencv/modules/*/samples/*' '*/build/modules/java_bindings_generator/*' '*/build/modules/python_bindings_generator/*' '*/opencv_contrib/modules/*/perf/*' '*/opencv_contrib/modules/*/test/*' '*/opencv_contrib/modules/*/samples/*' '*/opencv/*' -o opencv_filtered.info
    • genhtml --prefix /build/master-contrib_coverage-lin64-debug -t 'OpenCV: 4.5.4-154-gac4b592 / Contrib: 4.5.4-40-ga22e5a8 / Extra: 4.5.4-19-g0122c2f' -o coverage_html opencv_filtered.info

Details about options can be found in the lcov man: Linux Test Project - Coverage » lcov

1 Like