Reorganize cmake testing

This commit is contained in:
2024-01-24 10:57:37 -08:00
parent 77ce12e070
commit f0939e5c95

View File

@@ -47,23 +47,11 @@ set(TEST_FLAGS -Wall -Wextra -Wpedantic -Wunreachable-code -UNDEBUG)
include(CTest)
# unit test
add_executable(conflict_set_main ConflictSet.cpp)
target_include_directories(conflict_set_main PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_compile_definitions(conflict_set_main PRIVATE ENABLE_MAIN)
file(GLOB CORPUS_TESTS ${CMAKE_SOURCE_DIR}/corpus/*)
add_executable(conflict_set_test_driver ConflictSet.cpp TestDriver.cpp)
target_compile_definitions(conflict_set_test_driver PRIVATE ENABLE_FUZZ)
target_include_directories(conflict_set_test_driver PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
foreach(TEST ${CORPUS_TESTS})
get_filename_component(hash ${TEST} NAME)
add_test(NAME conflict_set_corpus_${hash} COMMAND conflict_set_test_driver ${TEST})
endforeach()
# fuzz test
# libfuzzer target, to generate/manage corpus
set(FUZZ_FLAGS "-fsanitize=fuzzer-no-link,address,undefined")
include(CheckCXXCompilerFlag)
cmake_push_check_state()
@@ -80,6 +68,19 @@ if (HAS_LIB_FUZZER)
target_link_options(conflict_set_fuzz_test PRIVATE ${FUZZ_FLAGS} -fsanitize=fuzzer)
endif()
# corpus tests
file(GLOB CORPUS_TESTS ${CMAKE_SOURCE_DIR}/corpus/*)
add_executable(conflict_set_test_driver ConflictSet.cpp TestDriver.cpp)
target_compile_options(conflict_set_test_driver PRIVATE ${TEST_FLAGS})
target_compile_definitions(conflict_set_test_driver PRIVATE ENABLE_FUZZ)
target_include_directories(conflict_set_test_driver PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
foreach(TEST ${CORPUS_TESTS})
get_filename_component(hash ${TEST} NAME)
add_test(NAME conflict_set_corpus_${hash} COMMAND conflict_set_test_driver ${TEST})
endforeach()
# api smoke tests
# c90