From 52adb07fee203f77824901a2ad907d00b98bc16a Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Wed, 17 Sep 2025 17:45:14 +0200 Subject: [PATCH] add code coverage --- CMakeLists.txt | 2 +- libs/spandisc/tests/CMakeLists.txt | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 81b24a1..205eca7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build Type [Debug|Release]") message(STATUS "CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}") if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") - set(CMAKE_C_FLAGS "-Wall -std=c99 -g -fsanitize=address") + set(CMAKE_C_FLAGS "-Wall -std=c99 -g -fsanitize=address -fprofile-arcs -ftest-coverage") else() set(CMAKE_C_FLAGS "-Werror -std=c99") endif() diff --git a/libs/spandisc/tests/CMakeLists.txt b/libs/spandisc/tests/CMakeLists.txt index 3dcc544..d72204d 100644 --- a/libs/spandisc/tests/CMakeLists.txt +++ b/libs/spandisc/tests/CMakeLists.txt @@ -14,4 +14,16 @@ target_link_libraries(splitter-test add_custom_target(run-splitter-test ALL ./splitter-test - DEPENDS splitter-test) \ No newline at end of file + DEPENDS splitter-test) + +add_custom_target(run-gcov + ALL gcov ../src/CMakeFiles/spandisc.dir/*.c.o + DEPENDS run-splitter-test) + +add_custom_target(run-lcov + ALL lcov --capture --directory ../src/CMakeFiles/spandisc.dir --output-file coverage.info + DEPENDS run-gcov) + +add_custom_target(gen-html + ALL genhtml coverage.info --output-directory coverage + DEPENDS run-lcov) \ No newline at end of file -- 2.47.3