diff options
-rw-r--r-- | DefineOptions.cmake | 5 | ||||
-rw-r--r-- | cmake/Modules/FindClangFuzzer.cmake | 32 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 4 | ||||
-rw-r--r-- | tests/fuzz/CMakeLists.txt | 9 |
4 files changed, 48 insertions, 2 deletions
diff --git a/DefineOptions.cmake b/DefineOptions.cmake index a2a8c5e6..43457e54 100644 --- a/DefineOptions.cmake +++ b/DefineOptions.cmake @@ -14,7 +14,8 @@ option(WITH_TESTING "Build with unit tests" OFF) option(WITH_CLIENT_TESTING "Build with client tests; requires a running sshd" OFF) option(WITH_BENCHMARKS "Build benchmarks tools" OFF) option(WITH_EXAMPLES "Build examples" ON) -option(WITH_NACL "Build with libnacl (curve25519" ON) +option(WITH_NACL "Build with libnacl (curve25519)" ON) +option(FUZZ_TESTING "Build with fuzzer for the server" OFF) if (WITH_ZLIB) set(WITH_LIBZ ON) else (WITH_ZLIB) @@ -31,4 +32,4 @@ endif (WITH_TESTING) if (WITH_NACL) set(WITH_NACL ON) -endif (WITH_NACL)
\ No newline at end of file +endif (WITH_NACL) diff --git a/cmake/Modules/FindClangFuzzer.cmake b/cmake/Modules/FindClangFuzzer.cmake new file mode 100644 index 00000000..55dbf734 --- /dev/null +++ b/cmake/Modules/FindClangFuzzer.cmake @@ -0,0 +1,32 @@ +# - Try to find Fuzzer +# Once done this will define +# +# CLANG_FUZZER_FOUND - system has Fuzzer +# CLANG_FUZZER_LIBRARY - Link these to use Fuzzer +# +#============================================================================= +# Copyright (c) 2018 Andreas Schneider <asn@cryptomilk.org> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# + +find_package(Clang REQUIRED CONFIG) + +find_library(CLANG_FUZZER_LIBRARY + NAMES + Fuzzer + HINTS + ${LLVM_LIBRARY_DIR}/clang/${LLVM_PACKAGE_VERSION}/lib +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Fuzzer DEFAULT_MSG CLANG_FUZZER_LIBRARY) + +# show the CLANG_FUZZER_LIBRARY variables only in the advanced view +mark_as_advanced(CLANG_FUZZER_LIBRARY) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4f2413d1..4f933b5d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -138,3 +138,7 @@ endif (WITH_BENCHMARKS) if (WITH_SERVER) add_subdirectory(pkd) endif (WITH_SERVER) + +if (FUZZ_TESTING) + add_subdirectory(fuzz) +endif() diff --git a/tests/fuzz/CMakeLists.txt b/tests/fuzz/CMakeLists.txt new file mode 100644 index 00000000..b34ca66a --- /dev/null +++ b/tests/fuzz/CMakeLists.txt @@ -0,0 +1,9 @@ +project(fuzzing CXX) + +find_package(ClangFuzzer) + +add_executable(ssh_server_fuzzer ssh_server_fuzzer.cpp) +target_link_libraries(ssh_server_fuzzer + ${CLANG_FUZZER_LIBRARY} + ${LIBSSH_THREADS_STATIC_LIBRARY} + ${LIBSSH_THREADS_LINK_LIBRARIES}) |