Skip to content

Commit

Permalink
Improve CTest configuration
Browse files Browse the repository at this point in the history
* CTest module is only configured and included if this is the top-level
  project
* Only add tr31-tool tests if this is the top-level project. The
  assumption is that when this project is not the top-level, only the
  library and its testing would be of interest to the parent project.
* Configure Valgrind if available
  • Loading branch information
leonlynch committed Apr 27, 2022
1 parent 5d6f045 commit a8dd5dd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,16 @@ endif()

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")

include(CTest)
# Configure testing before adding subdirectories
if(TR31_IS_TOP_LEVEL)
# Configure Valgrind before including CTest module
find_program(VALGRIND_COMMAND valgrind)
set(MEMORYCHECK_TYPE Valgrind)
set(VALGRIND_COMMAND_OPTIONS "--leak-check=full --show-reachable=yes --track-origins=yes --num-callers=100 --show-error-list=yes")

# Only top-level project should include CTest module
include(CTest)
endif()

# Allow parent scope to provide crypto targets when not building shared libs
if(TR31_IS_TOP_LEVEL OR BUILD_SHARED_LIBS)
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ install(
COMPONENT tr31_development
)

if(BUILD_TESTING)
if(TR31_IS_TOP_LEVEL AND BUILD_TESTING)
add_test(NAME tr31_tool_test1
COMMAND tr31-tool --import B0128B1TX00N0300KS18FFFF00A0200001E00000KC0C000169E3KP0C00ECAD626F9F1A826814AA066D86C8C18BD0E14033E1EBEC75BEDF586E6E325F3AA8C0E5 --kbpk AB2E09DB3EF0BA71E0CE6CD755C23A3B
)
Expand Down

0 comments on commit a8dd5dd

Please sign in to comment.