build: Add target to convert lcov coverage report to the cobertura format

This commit is contained in:
Gabriel Ferreira
2024-09-06 17:17:15 +02:00
parent 8dc668e599
commit 59ae0231ed
2 changed files with 26 additions and 1 deletions

View File

@@ -18,6 +18,7 @@ if(${NS3_COVERAGE})
message(FATAL_ERROR "LCOV is required but it is not installed.")
endif()
set(zero_counters)
if(${NS3_COVERAGE_ZERO_COUNTERS})
set(zero_counters "--lcov-zerocounters")
endif()
@@ -32,8 +33,30 @@ if(${NS3_COVERAGE})
add_custom_target(
coverage_gcc
COMMAND lcov -o ns3.info -c --directory ${CMAKE_BINARY_DIR} ${zero_counters}
COMMAND genhtml ns3.info
WORKING_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY}/coverage
DEPENDS run_test_py
)
add_custom_target(
coverage_html
COMMAND genhtml ns3.info
WORKING_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY}/coverage
DEPENDS coverage_gcc
)
# Convert lcov results to cobertura (compatible with gitlab)
check_deps(cobertura_deps EXECUTABLES c++filt PYTHON_PACKAGES lcov_cobertura)
if(cobertura_deps)
message(
WARNING
"Code coverage conversion from LCOV to Cobertura requires missing dependencies: ${cobertura_deps}"
)
else()
add_custom_target(
coverage_cobertura
COMMAND lcov_cobertura ns3.info --output cobertura.xml --demangle
WORKING_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY}/coverage
DEPENDS coverage_gcc
)
endif()
endif()

2
ns3
View File

@@ -1285,7 +1285,9 @@ def build_step(
"check-version",
"cmake-format",
"cmake-format-check",
"coverage_cobertura",
"coverage_gcc",
"coverage_html",
"docs",
"doxygen",
"doxygen-no-build",