dpm_core carries a namespace block saying what it holds and why its members keep external linkage while staying off the export table. Each unnamed namespace says its contents are private to that translation unit, and the one in the info module says why it has to be unnamed there: a module is built without hidden visibility or a version script, so a helper with external linkage would reach that module's exports. The three opaque handles in the public header were undocumented. What documentation they had came from the struct definitions in include/internal, which a consumer never sees. EXTRACT_ANON_NSPACES was off, so the documentation on every file-private helper was written and discarded. Doxygen also capitalizes the first letter of a brief, which turned libdpm-core.so into Libdpm-core.so wherever a brief opened with it; those are reworded. Bare references to the library are replaced with the artifact name throughout, including three in the info module's output. The cli_info_version regex follows.
67 lines
2.8 KiB
CMake
67 lines
2.8 KiB
CMake
# ---------------------------------------------------------------------
|
|
# Test fixture modules: one known-good stub, two deliberately broken
|
|
#
|
|
# The output paths come from the top-level file, which defines them
|
|
# before adding this directory so that each is written in one place.
|
|
# ---------------------------------------------------------------------
|
|
foreach(fixture good missing_symbols bad_version)
|
|
add_library(fixture_${fixture} MODULE fixtures/src/${fixture}.cpp)
|
|
set_target_properties(fixture_${fixture} PROPERTIES
|
|
PREFIX ""
|
|
SUFFIX ".so"
|
|
OUTPUT_NAME ${fixture}
|
|
LIBRARY_OUTPUT_DIRECTORY ${DPM_TEST_FIXTURE_DIR}
|
|
)
|
|
endforeach()
|
|
|
|
# ---------------------------------------------------------------------
|
|
# API test binary — drives libdpm-core.so through its public C API
|
|
# ---------------------------------------------------------------------
|
|
add_executable(test_core test_core.cpp)
|
|
|
|
target_link_libraries(test_core PRIVATE dpm-core)
|
|
|
|
target_compile_definitions(test_core PRIVATE
|
|
TEST_FIXTURE_MODULES="${DPM_TEST_FIXTURE_DIR}"
|
|
TEST_FIXTURE_CONF="${CMAKE_CURRENT_SOURCE_DIR}/fixtures/conf"
|
|
DPM_CORE_VERSION_EXPECTED="${PROJECT_VERSION}"
|
|
)
|
|
|
|
set_target_properties(test_core PROPERTIES
|
|
RUNTIME_OUTPUT_DIRECTORY ${DPM_TEST_DIR}
|
|
BUILD_RPATH "$ORIGIN/../lib"
|
|
)
|
|
|
|
foreach(fixture good missing_symbols bad_version)
|
|
add_dependencies(test_core fixture_${fixture})
|
|
endforeach()
|
|
|
|
add_test(NAME core_api COMMAND test_core)
|
|
|
|
# ---------------------------------------------------------------------
|
|
# CLI end-to-end tests (the dpm binary is the cheapest full-stack client)
|
|
# ---------------------------------------------------------------------
|
|
add_test(NAME cli_help COMMAND dpm --help)
|
|
set_tests_properties(cli_help PROPERTIES PASS_REGULAR_EXPRESSION "Usage: dpm")
|
|
|
|
add_test(NAME cli_list
|
|
COMMAND dpm -c ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/conf
|
|
-m ${CMAKE_BINARY_DIR}/modules --list-modules)
|
|
set_tests_properties(cli_list PROPERTIES PASS_REGULAR_EXPRESSION "info")
|
|
|
|
add_test(NAME cli_info_version
|
|
COMMAND dpm -c ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/conf
|
|
-m ${CMAKE_BINARY_DIR}/modules -L INFO info version)
|
|
set_tests_properties(cli_info_version PROPERTIES
|
|
PASS_REGULAR_EXPRESSION "libdpm-core\\.so Version: ${PROJECT_VERSION}")
|
|
|
|
add_test(NAME cli_module_not_found
|
|
COMMAND dpm -c ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/conf
|
|
-m ${CMAKE_BINARY_DIR}/modules nonexistent)
|
|
set_tests_properties(cli_module_not_found PROPERTIES WILL_FAIL TRUE)
|
|
|
|
add_test(NAME cli_rejects_invalid_module
|
|
COMMAND dpm -c ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/conf
|
|
-m ${DPM_TEST_FIXTURE_DIR} missing_symbols)
|
|
set_tests_properties(cli_rejects_invalid_module PROPERTIES WILL_FAIL TRUE)
|