A recent OS upgrade made my coverage script fail miserably.
lcov 1.13
gcov (GCC) 9.1.1
The part of my CMake that is used to generate coverage data:
if ($ENV{COVERAGE})
message("Setting up for coverage")
enable_testing()
include(CodeCoverage)
setup_target_for_coverage(${PROJECT_NAME}_coverage tests coverage)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
endif ()
The lcov
command I issued after building tests:
lcov --capture --directory build/ --output-file coverage.info
Unfortunately now fails with:
Capturing coverage data from build/
Found gcov version: 9.1.1
Scanning build/ for .gcda files ...
geninfo: WARNING: no .gcda files found in build/ - skipping!
Finished .info-file creation
The error message makes sense because there are no .gcda
files - only .gcno
files. I am not sure if they serve the same purpose and / or can be used with lcov
.
I issued nm some_binary | grep gcov
and there are a lot of symbols in the form of:
00000000004b3520 d __gcov_._ZZZN6__pstl10__internal15__pattern_walk2IRKNS_9execution2v115parallel_policyEN9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEENS8_IPiSD_EEZSt9transformIS6_SE_SG_ZN12_GLOBAL__N_150ParallelTransformTest_NoDataShouldReturnEmpty_Test8TestBodyEvEUlRKT_E_ENSt9enable_ifIXsrNS3_19is_execution_policyINSt5decayISK_E4typeEEE5valueET1_E4typeEOSK_T0_SY_SU_T2_EUlRS9_RiE_St17integral_constantIbLb0EEEESU_SX_SY_SY_SU_SZ_T3_S13_IbLb1EEENKUlvE_clEvENKUlSE_SE_E_clESE_SE_
So I guess the CMake is still correctly trying to give me coverage data.
It worked fine on gcc 7
if I recall correctly.
Is there a new solution / CMake flag to issue / lcov flag to issue? Or is it broken right now and there is no workaround? Or perhaps I was doing something odd the whole time?
I believe GCC 9 outputs coverage data as JSON by default now, as mentioned in the change notes.
The gcov tool has changed its intermediate format to a new JSON format.
It also looks like lcov have an open issue for handling this new format.