2024-05-02 06:26:18 +00:00
|
|
|
include(CTest)
|
|
|
|
|
2024-05-02 08:04:00 +00:00
|
|
|
include_directories(${PROJECT_SOURCE_DIR}/src)
|
|
|
|
|
2024-05-30 19:43:14 +00:00
|
|
|
# ------------------------------------------------ #
|
|
|
|
# Setup Glib 2.0 #
|
|
|
|
# ------------------------------------------------ #
|
|
|
|
|
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
pkg_search_module(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
|
2024-06-02 22:24:17 +00:00
|
|
|
include_directories(PRIVATE ${GLIB_INCLUDE_DIRS})
|
|
|
|
|
|
|
|
# ------------------------------------------------ #
|
|
|
|
# Setup TOML-C99 #
|
|
|
|
# ------------------------------------------------ #
|
|
|
|
|
|
|
|
include_directories(${PROJECT_SOURCE_DIR}/dep/tomlc99)
|
2024-05-30 19:43:14 +00:00
|
|
|
|
2024-05-02 07:49:14 +00:00
|
|
|
# ------------------------------------------------------- #
|
|
|
|
# CTEST 1
|
|
|
|
# test the default output of the logger
|
|
|
|
|
2024-05-02 08:04:00 +00:00
|
|
|
add_executable(logging_output
|
|
|
|
${PROJECT_SOURCE_DIR}/src/sys/log.c
|
2024-05-30 19:43:14 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/src/sys/col.c
|
2024-06-02 22:24:17 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/src/cfg/opt.c
|
|
|
|
${PROJECT_SOURCE_DIR}/src/io/files.c
|
2024-06-05 18:00:14 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/src/mem/cache.c
|
2024-05-02 08:04:00 +00:00
|
|
|
output.c)
|
2024-05-02 07:49:14 +00:00
|
|
|
set_target_properties(logging_output
|
2024-05-02 06:26:18 +00:00
|
|
|
PROPERTIES
|
|
|
|
OUTPUT_NAME "output"
|
|
|
|
RUNTIME_OUTPUT_DIRECTORY ${GEMSTONE_BINARY_DIR}/tests/logging)
|
2024-06-02 22:24:17 +00:00
|
|
|
target_link_libraries(logging_output PkgConfig::GLIB)
|
|
|
|
target_link_libraries(logging_output tomlc99)
|
2024-05-02 08:04:00 +00:00
|
|
|
add_test(NAME logging_output
|
|
|
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
|
|
|
COMMAND python ${GEMSTONE_TEST_DIR}/logging/test_logging.py check_output)
|
2024-05-02 07:49:14 +00:00
|
|
|
|
|
|
|
# ------------------------------------------------------- #
|
2024-05-02 08:32:27 +00:00
|
|
|
# CTEST 2
|
2024-05-02 07:49:14 +00:00
|
|
|
# test the panic functionality of the logger
|
|
|
|
|
2024-05-02 08:04:00 +00:00
|
|
|
add_executable(logging_panic
|
|
|
|
${PROJECT_SOURCE_DIR}/src/sys/log.c
|
2024-05-30 19:43:14 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/src/sys/col.c
|
2024-06-02 22:24:17 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/src/cfg/opt.c
|
|
|
|
${PROJECT_SOURCE_DIR}/src/io/files.c
|
2024-06-05 18:00:14 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/src/mem/cache.c
|
2024-05-02 08:04:00 +00:00
|
|
|
panic.c)
|
2024-05-02 07:49:14 +00:00
|
|
|
set_target_properties(logging_panic
|
|
|
|
PROPERTIES
|
|
|
|
OUTPUT_NAME "panic"
|
|
|
|
RUNTIME_OUTPUT_DIRECTORY ${GEMSTONE_BINARY_DIR}/tests/logging)
|
2024-06-02 22:24:17 +00:00
|
|
|
target_link_libraries(logging_panic PkgConfig::GLIB)
|
|
|
|
target_link_libraries(logging_panic tomlc99)
|
2024-05-02 08:04:00 +00:00
|
|
|
add_test(NAME logging_panic
|
|
|
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
|
|
|
COMMAND python ${GEMSTONE_TEST_DIR}/logging/test_logging.py check_panic)
|
2024-05-02 08:32:27 +00:00
|
|
|
|
|
|
|
# ------------------------------------------------------- #
|
|
|
|
# CTEST 3
|
|
|
|
# test the ability to write to multiple output streams
|
|
|
|
|
|
|
|
add_executable(logging_streams
|
|
|
|
${PROJECT_SOURCE_DIR}/src/sys/log.c
|
2024-05-30 19:43:14 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/src/sys/col.c
|
2024-06-02 22:24:17 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/src/cfg/opt.c
|
|
|
|
${PROJECT_SOURCE_DIR}/src/io/files.c
|
2024-06-05 18:00:14 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/src/mem/cache.c
|
2024-05-02 08:32:27 +00:00
|
|
|
streams.c)
|
|
|
|
set_target_properties(logging_streams
|
|
|
|
PROPERTIES
|
|
|
|
OUTPUT_NAME "stream"
|
|
|
|
RUNTIME_OUTPUT_DIRECTORY ${GEMSTONE_BINARY_DIR}/tests/logging)
|
2024-06-02 22:24:17 +00:00
|
|
|
target_link_libraries(logging_streams PkgConfig::GLIB)
|
|
|
|
target_link_libraries(logging_streams tomlc99)
|
2024-05-02 08:32:27 +00:00
|
|
|
add_test(NAME logging_streams
|
|
|
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
|
|
|
COMMAND python ${GEMSTONE_TEST_DIR}/logging/test_logging.py check_stream)
|
2024-05-02 08:50:24 +00:00
|
|
|
|
|
|
|
# ------------------------------------------------------- #
|
|
|
|
# CTEST 4
|
|
|
|
# test compile time log level switch
|
|
|
|
|
|
|
|
add_executable(logging_level
|
|
|
|
${PROJECT_SOURCE_DIR}/src/sys/log.c
|
2024-05-30 19:43:14 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/src/sys/col.c
|
2024-06-02 22:24:17 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/src/cfg/opt.c
|
|
|
|
${PROJECT_SOURCE_DIR}/src/io/files.c
|
2024-06-05 18:00:14 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/src/mem/cache.c
|
2024-05-02 08:50:24 +00:00
|
|
|
level.c)
|
|
|
|
set_target_properties(logging_level
|
|
|
|
PROPERTIES
|
|
|
|
OUTPUT_NAME "level"
|
|
|
|
RUNTIME_OUTPUT_DIRECTORY ${GEMSTONE_BINARY_DIR}/tests/logging)
|
2024-06-02 22:24:17 +00:00
|
|
|
target_link_libraries(logging_level PkgConfig::GLIB)
|
|
|
|
target_link_libraries(logging_level tomlc99)
|
2024-05-02 08:50:24 +00:00
|
|
|
add_test(NAME logging_level
|
|
|
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
|
|
|
COMMAND python ${GEMSTONE_TEST_DIR}/logging/test_logging.py check_level)
|