From: George Karpenkov Date: Fri, 4 Aug 2017 19:29:16 +0000 (+0000) Subject: [libFuzzer tests] Only enable libFuzzer tests if X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ba96863e68ba660252dd213ebb6e0002d1ced265;p=llvm [libFuzzer tests] Only enable libFuzzer tests if -DLIBFUZZER_ENABLE_TESTS=ON is set. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310100 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/LibFuzzer.rst b/docs/LibFuzzer.rst index db6538f41d0..e22ed388e40 100644 --- a/docs/LibFuzzer.rst +++ b/docs/LibFuzzer.rst @@ -628,8 +628,7 @@ LibFuzzer is built as a part of LLVM project by default on macos and Linux. Users of other operating systems can explicitly request compilation using ``-DLIBFUZZER_ENABLE=YES`` flag. Tests are run using ``check-fuzzer`` target from the build directory -(note that tests will take a long time to run if the compiler was compiled -without optimizations): +which was configured with ``-DLIBFUZZER_ENABLE_TESTS=ON`` flag. .. code-block:: console diff --git a/lib/Fuzzer/CMakeLists.txt b/lib/Fuzzer/CMakeLists.txt index 4aa15f54c78..ef05b153234 100644 --- a/lib/Fuzzer/CMakeLists.txt +++ b/lib/Fuzzer/CMakeLists.txt @@ -22,6 +22,7 @@ endif() # Compile libFuzzer if the compilation is specifically requested, OR # if the platform is known to be working. set(LIBFUZZER_ENABLE ${LIBFUZZER_ENABLED_CHECK} CACHE BOOL "Build libFuzzer and its tests") +set(LIBFUZZER_ENABLE_TESTS OFF CACHE BOOL "Build libFuzzer and its tests") if (LIBFUZZER_ENABLE) add_library(LLVMFuzzerNoMainObjects OBJECT @@ -65,7 +66,7 @@ if (MSVC) add_custom_command(TARGET check-fuzzer COMMAND cmake -E echo "check-fuzzer is disalbed on Windows") else() - if (LLVM_INCLUDE_TESTS AND LIBFUZZER_ENABLE) + if (LLVM_INCLUDE_TESTS AND LIBFUZZER_ENABLE_TESTS) add_subdirectory(test) endif() endif() diff --git a/lib/Fuzzer/test/CMakeLists.txt b/lib/Fuzzer/test/CMakeLists.txt index 230c20fda7a..992ac367058 100644 --- a/lib/Fuzzer/test/CMakeLists.txt +++ b/lib/Fuzzer/test/CMakeLists.txt @@ -47,23 +47,20 @@ include_directories(..) set(LIBFUZZER_TEST_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang) set(LIBFUZZER_TEST_CXX_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++) -if ((TARGET asan) AND (TARGET clang)) - # LIT-based libFuzzer tests. - configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg - ) - - # libFuzzer unit tests. - configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/unit/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/unit/lit.site.cfg - ) +# LIT-based libFuzzer tests. +configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg + ) - add_lit_testsuite(check-fuzzer "Running Fuzzer tests" - ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS LLVMFuzzer-Unittest) +# libFuzzer unit tests. +configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/unit/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/unit/lit.site.cfg + ) - add_dependencies(check-fuzzer LLVMFuzzer asan clang llvm-symbolizer FileCheck sancov not) -endif() +add_lit_testsuite(check-fuzzer "Running Fuzzer tests" + ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS LLVMFuzzer-Unittest) +add_dependencies(check-fuzzer LLVMFuzzer asan clang llvm-symbolizer FileCheck sancov not)