[libFuzzer tests] Only enable libFuzzer tests if

-DLIBFUZZER_ENABLE_TESTS=ON is set.

llvm-svn: 310100
This commit is contained in:
George Karpenkov 2017-08-04 19:29:16 +00:00
parent 3fed079f8c
commit b0c2bb572d
3 changed files with 17 additions and 20 deletions

View File

@ -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

View File

@ -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()

View File

@ -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
)
# 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
)
# 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_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)
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)