Skip to content

Commit

Permalink
new: add the possibility to link external test files
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Terzolo <[email protected]>
  • Loading branch information
Andreagit97 authored and poiana committed Nov 29, 2023
1 parent 9677b66 commit 68a96aa
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions userspace/libsinsp/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ if (CMAKE_SYSTEM_NAME MATCHES "Linux")
public_sinsp_API/ppm_sc_codes.cpp)
endif()

# Link against additional files could be useful when testing plugins
# `ADDITIONAL_SINSP_TESTS_SUITE` is a list of source files `;` separated
if(ADDITIONAL_SINSP_TESTS_SUITE)
message(STATUS "- Additional sinsp source files: ${ADDITIONAL_SINSP_TESTS_SUITE}")
list(APPEND LIBSINSP_UNIT_TESTS_SOURCES "${ADDITIONAL_SINSP_TESTS_SUITE}")
endif()

add_executable(unit-test-libsinsp ${LIBSINSP_UNIT_TESTS_SOURCES})

if (EMSCRIPTEN)
Expand All @@ -180,6 +187,13 @@ if (CMAKE_BUILD_TYPE STREQUAL "Coverage")
)
endif()

# Add some additional include directories associated with `ADDITIONAL_SINSP_TESTS_SUITE`
# `ADDITIONAL_SINSP_TESTS_INCLUDE_FOLDERS` is a list of include paths `;` separated
if(ADDITIONAL_SINSP_TESTS_INCLUDE_FOLDERS)
message(STATUS "- Additional include directories: ${ADDITIONAL_SINSP_TESTS_INCLUDE_FOLDERS}")
target_include_directories(unit-test-libsinsp PRIVATE ${ADDITIONAL_SINSP_TESTS_INCLUDE_FOLDERS})
endif()

add_custom_target(run-unit-test-libsinsp
DEPENDS unit-test-libsinsp
COMMAND unit-test-libsinsp
Expand Down

0 comments on commit 68a96aa

Please sign in to comment.