From f0939e5c95c70ddcad82c0b9d167b1609c2ccbc1 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Wed, 24 Jan 2024 10:57:37 -0800 Subject: [PATCH] Reorganize cmake testing --- CMakeLists.txt | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d168025..6dec65a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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