tests: make code coverage for unit tests optional
Add a new cmake option VPP_BUILD_TESTS_WITH_COVERAGE to enable building unittests with clang code coverage. Type: improvement Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: I9cbe9e3031afdcd03bc8f9203d662b91677724ab Signed-off-by: Ole Troan <ot@cisco.com>
This commit is contained in:
@@ -156,6 +156,14 @@ if(VPP_ENABLE_TRAJECTORY_TRACE)
|
|||||||
add_compile_definitions(VLIB_BUFFER_TRACE_TRAJECTORY=1)
|
add_compile_definitions(VLIB_BUFFER_TRACE_TRAJECTORY=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# unittest with clang ode coverage
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
if("${CMAKE_VERSION}" VERSION_GREATER_EQUAL "3.13" AND "${CMAKE_C_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang")
|
||||||
|
option(VPP_BUILD_TESTS_WITH_COVERAGE "Build unit tests with code coverage" OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# install config
|
# install config
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ add_custom_target(test_pnat-run
|
|||||||
DEPENDS test_pnat
|
DEPENDS test_pnat
|
||||||
)
|
)
|
||||||
|
|
||||||
if("${CMAKE_VERSION}" VERSION_GREATER_EQUAL "3.13" AND "${CMAKE_C_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang")
|
if(VPP_BUILD_TESTS_WITH_COVERAGE)
|
||||||
set(TARGET_NAME test_pnat)
|
set(TARGET_NAME test_pnat)
|
||||||
set(COV_SOURCES ${CMAKE_SOURCE_DIR}/plugins/nat/pnat/pnat.c ${CMAKE_SOURCE_DIR}/plugins/nat/pnat/pnat_node.h ${CMAKE_SOURCE_DIR}/plugins/nat/pnat/pnat_node.c)
|
set(COV_SOURCES ${CMAKE_SOURCE_DIR}/plugins/nat/pnat/pnat.c ${CMAKE_SOURCE_DIR}/plugins/nat/pnat/pnat_node.h ${CMAKE_SOURCE_DIR}/plugins/nat/pnat/pnat_node.c)
|
||||||
|
|
||||||
|
|||||||
@@ -52,8 +52,7 @@ add_vpp_executable(test_vat2 ENABLE_EXPORTS NO_INSTALL
|
|||||||
rt m dl crypto
|
rt m dl crypto
|
||||||
)
|
)
|
||||||
#target_link_options(test_vat2 PUBLIC "LINKER:-fsanitize=address")
|
#target_link_options(test_vat2 PUBLIC "LINKER:-fsanitize=address")
|
||||||
|
if(VPP_BUILD_TESTS_WITH_COVERAGE)
|
||||||
if("${CMAKE_VERSION}" VERSION_GREATER_EQUAL "3.13" AND "${CMAKE_C_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang")
|
|
||||||
set(TARGET_NAME test_vat2)
|
set(TARGET_NAME test_vat2)
|
||||||
|
|
||||||
message("Building with llvm Code Coverage Tools ${TARGET_NAME}")
|
message("Building with llvm Code Coverage Tools ${TARGET_NAME}")
|
||||||
|
|||||||
Reference in New Issue
Block a user