mirror of
https://github.com/falcosecurity/falco.git
synced 2025-07-05 02:47:05 +00:00
build: add FALCO_Coverage CMake option
With cmake FALCO_Coverage=on the --coverage option is passed to both clang and gcc to help analyze untested portions of the code base. It produces gcov files. These files can be analyzed by many tools such as lcov, gcovr, etc. Here is an example of one such tool, lcov: lcov --directory . --capture --output-file coverage.info lcov --extract coverage.info '/source/*' --output-file coverage.info genhtml coverage.info Signed-off-by: Chris Goller <goller@gmail.com>
This commit is contained in:
parent
7159b43f68
commit
e31bfeb8b2
@ -18,6 +18,8 @@ cmake_minimum_required(VERSION 3.3.2)
|
||||
|
||||
project(falco)
|
||||
|
||||
option(FALCO_Coverage "Build test suite with coverage information" OFF)
|
||||
|
||||
if(NOT SYSDIG_DIR)
|
||||
get_filename_component(SYSDIG_DIR "${PROJECT_SOURCE_DIR}/../sysdig" REALPATH)
|
||||
endif()
|
||||
@ -633,6 +635,18 @@ endif()
|
||||
install(FILES falco.yaml
|
||||
DESTINATION "${FALCO_ETC_DIR}")
|
||||
|
||||
if(FALCO_Coverage)
|
||||
if (NOT (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")))
|
||||
message(FATAL_ERROR "FALCO_Coverage requires GCC or Clang.")
|
||||
endif()
|
||||
|
||||
message(STATUS "Building with coverage information")
|
||||
add_compile_options(-g --coverage)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "--coverage ${CMAKE_SHARED_LINKER_FLAGS}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "--coverage ${CMAKE_EXE_LINKER_FLAGS}")
|
||||
endif()
|
||||
|
||||
|
||||
add_subdirectory(test)
|
||||
add_subdirectory(rules)
|
||||
add_subdirectory(docker)
|
||||
|
Loading…
Reference in New Issue
Block a user