Skip to content

Commit

Permalink
build: Add target to convert lcov coverage report to the cobertura fo…
Browse files Browse the repository at this point in the history
…rmat
  • Loading branch information
Gabrielcarvfer committed Sep 7, 2024
1 parent 8dc668e commit 59ae023
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 24 additions & 1 deletion build-support/custom-modules/ns3-coverage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 changes: 2 additions & 0 deletions ns3
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 59ae023

Please sign in to comment.