Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions indra/cmake/ALAddTestBinary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ endif()
# al_add_test_binary(<name> PROJECT <project> SOURCES <test file>... [UNIT <file>...]
# [LIBRARIES <target>...] [SUPPORT <object library>...]
# [INCLUDES <dir>...] [DEFINES <define>...] [ENVIRONMENT <VAR=value>...]
# [GL] [PYTHON] [ISA_TIER <tier>] [RESOURCE_LOCK <name>...] [COMBINED])
# [GL] [PYTHON] [ISA_TIER <tier>] [RESOURCE_LOCK <name>...] [LAUNCHER <command>...]
# [COMBINED])
#
# Builds the test files into one Catch2 executable, <name>, with the harness
# (al_test_support: the main, the listeners and the matchers) and SUPPORT's
Expand Down Expand Up @@ -56,14 +57,17 @@ endif()
# ISA_TIER binary is built at that x86-64 tier, named <name>_<tier>, labelled
# isa, and skips on a host below it -- or below the tree's own tier, since it
# links the tree's libraries, built at that one. RESOURCE_LOCK names what the binary's
# entries hold that no two may hold at once, such as a fixed port.
# entries hold that no two may hold at once, such as a fixed port. LAUNCHER is
# a command each entry runs the binary through, its path and arguments after
# the command's own: llcorehttp's tests run under the Python peer that serves
# their requests. A per-case entry, and its discovery, go through it too.
function(al_add_test_binary name)
cmake_parse_arguments(
PARSE_ARGV 1
arg
"GL;PYTHON;COMBINED"
"PROJECT;ISA_TIER"
"SOURCES;UNIT;LIBRARIES;SUPPORT;INCLUDES;DEFINES;ENVIRONMENT;RESOURCE_LOCK"
"SOURCES;UNIT;LIBRARIES;SUPPORT;INCLUDES;DEFINES;ENVIRONMENT;RESOURCE_LOCK;LAUNCHER"
)
if(NOT arg_PROJECT)
message(FATAL_ERROR "al_add_test_binary(${name}): PROJECT is required")
Expand Down Expand Up @@ -119,6 +123,9 @@ function(al_add_test_binary name)
add_executable(${target} ${arg_SOURCES} ${arg_UNIT})
target_link_libraries(${target} PRIVATE al::flags al_test_support ${arg_SUPPORT} ${arg_LIBRARIES})
target_include_directories(${target} PRIVATE ${arg_INCLUDES} ${INDRA_SOURCE_DIR}/test)
# For the helpers in test/ that TUT tests still share, so each fails a
# test the way its framework does.
target_compile_definitions(${target} PRIVATE AL_TEST_CATCH2=1)
if(arg_UNIT)
target_include_directories(
${target}
Expand Down Expand Up @@ -190,6 +197,11 @@ function(al_add_test_binary name)
DISABLED
${disabled}
)
# Catch.cmake runs the discovery and each case through the target's
# emulator, which CMake's own add_test leaves alone in a native build.
if(arg_LAUNCHER)
set_target_properties(${target} PROPERTIES CROSSCOMPILING_EMULATOR "${arg_LAUNCHER}")
endif()
# The main makes Catch2's "all skipped" CTest's 125, so a skip is not
# left to the discovery's own code for it.
catch_discover_tests(
Expand Down Expand Up @@ -235,7 +247,7 @@ function(al_add_test_binary name)
foreach(stem IN LISTS stems)
add_test(
NAME ${target}/${stem}
COMMAND $<TARGET_FILE:${target}> --filenames-as-tags "[#${stem}]~[.]" ${arguments}
COMMAND ${arg_LAUNCHER} $<TARGET_FILE:${target}> --filenames-as-tags "[#${stem}]~[.]" ${arguments}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
set_tests_properties(
Expand Down Expand Up @@ -287,7 +299,7 @@ function(al_add_test_binary name)
endif()
add_test(
NAME ${target}/combined
COMMAND $<TARGET_FILE:${target}> ${arguments}
COMMAND ${arg_LAUNCHER} $<TARGET_FILE:${target}> ${arguments}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
set_tests_properties(
Expand Down
35 changes: 21 additions & 14 deletions indra/llcorehttp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,26 +76,33 @@ target_precompile_headers(llcorehttp REUSE_FROM llprecompiled)

# tests
if(AL_BUILD_TESTS)
# The suite runs under a Python peer that serves the requests it makes.
# The state guard's checks on what llcorehttp keeps for the process, for
# every test binary that links it.
add_library(llcorehttp_test_checks OBJECT tests/llcorehttp_test_checks.cpp)
target_link_libraries(llcorehttp_test_checks PRIVATE al::flags al_test_support llcorehttp llmessage)
set_target_properties(llcorehttp_test_checks PROPERTIES FOLDER "Tests/llcorehttp")

# The suites run under a Python peer that serves the requests they make.
# An http_proxy in the environment would put a proxy between the two, so
# the run clears it.
al_add_test(
llcorehttp
al_add_test_binary(
llcorehttp_tests
PROJECT llcorehttp
SOURCES
tests/test_httpstatus.hpp
tests/test_refcounted.hpp
tests/test_httpoperation.hpp
tests/test_httprequest.hpp
tests/test_httprequestqueue.hpp
tests/test_httpheaders.hpp
tests/test_bufferarray.hpp
tests/test_bufferstream.hpp
tests/test_jsonrpcws.hpp
tests/test_websocketmgr.hpp
tests/bufferarray_test.cpp
tests/bufferstream_test.cpp
tests/httpheaders_test.cpp
tests/httpoperation_test.cpp
tests/httprequest_test.cpp
tests/httprequestqueue_test.cpp
tests/httpstatus_test.cpp
tests/jsonrpcws_test.cpp
tests/refcounted_test.cpp
tests/websocketmgr_test.cpp
LIBRARIES llcorehttp llmessage llcommon
SUPPORT llcorehttp_test_checks
PYTHON
COMMAND ${Python3_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/tests/test_llcorehttp_peer.py"
LAUNCHER ${Python3_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/tests/test_llcorehttp_peer.py"
ENVIRONMENT "http_proxy="
)

Expand Down
Loading
Loading