PROTON-1412: Reorganise the fuzz testing CMakefiles a little
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/64ed1852 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/64ed1852 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/64ed1852 Branch: refs/heads/go1 Commit: 64ed18520c4e154652c41488b1996262f6ba21c5 Parents: aadabc3 Author: Andrew Stitcher <astitc...@apache.org> Authored: Wed Mar 21 20:34:31 2018 -0400 Committer: Andrew Stitcher <astitc...@apache.org> Committed: Wed Mar 21 23:51:43 2018 -0400 ---------------------------------------------------------------------- proton-c/CMakeLists.txt | 11 ++++-- proton-c/src/tests/CMakeLists.txt | 5 +++ proton-c/src/tests/fuzz/CMakeLists.txt | 54 ++++++++++++++++------------- 3 files changed, 44 insertions(+), 26 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/64ed1852/proton-c/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/proton-c/CMakeLists.txt b/proton-c/CMakeLists.txt index b3683be..a345190 100644 --- a/proton-c/CMakeLists.txt +++ b/proton-c/CMakeLists.txt @@ -32,7 +32,7 @@ set(CMAKE_THREAD_PREFER_PTHREAD TRUE) find_package(Threads) find_package(PythonInterp REQUIRED) find_package(SWIG) -# FindSwig.cmake "forgets" make its outputs advanced like a good citizen +# FindSwig.cmake "forgets" to make its outputs advanced like a good citizen mark_as_advanced(SWIG_DIR SWIG_EXECUTABLE SWIG_VERSION) # See if Cyrus SASL is available @@ -200,12 +200,18 @@ if (APPLE) set (NOENABLE_UNDEFINED_ERROR ON) endif (APPLE) +# Can't build fuzz tests/or run regression tests on MSVC currently +# (due to limit on command line length) +if (MSVC) + set (NOENABLE_FUZZ_TESTING ON) +endif (MSVC) + # Make LTO default to off until we can figure out the valgrind issues set (NOENABLE_LINKTIME_OPTIMIZATION ON) # Add options here called <whatever> they will turn into "ENABLE_<whatever" and can be # overridden on a platform specific basis above by NOENABLE_<whatever> -set (OPTIONS WARNING_ERROR UNDEFINED_ERROR LINKTIME_OPTIMIZATION HIDE_UNEXPORTED_SYMBOLS) +set (OPTIONS WARNING_ERROR UNDEFINED_ERROR LINKTIME_OPTIMIZATION HIDE_UNEXPORTED_SYMBOLS FUZZ_TESTING) foreach (OPTION ${OPTIONS}) if (NOT NOENABLE_${OPTION}) @@ -218,6 +224,7 @@ option(ENABLE_WARNING_ERROR "Consider compiler warnings to be errors" ${DEFAULT_ option(ENABLE_UNDEFINED_ERROR "Check for unresolved library symbols" ${DEFAULT_UNDEFINED_ERROR}) option(ENABLE_LINKTIME_OPTIMIZATION "Perform link time optimization" ${DEFAULT_LINKTIME_OPTIMIZATION}) option(ENABLE_HIDE_UNEXPORTED_SYMBOLS "Only export library symbols that are explicitly requested" ${DEFAULT_HIDE_UNEXPORTED_SYMBOLS}) +option(ENABLE_FUZZ_TESTING "Enable building fuzzers and regression testing with libFuzzer" ${DEFAULT_FUZZ_TESTING}) # Set any additional compiler specific flags if (CMAKE_COMPILER_IS_GNUCC) http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/64ed1852/proton-c/src/tests/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/proton-c/src/tests/CMakeLists.txt b/proton-c/src/tests/CMakeLists.txt index 9dffca0..49d1300 100644 --- a/proton-c/src/tests/CMakeLists.txt +++ b/proton-c/src/tests/CMakeLists.txt @@ -59,3 +59,8 @@ if(HAS_PROACTOR) add_test(NAME c-fdlimit-tests COMMAND ${env_py} -- "PATH=${path}" "PYTHONPATH=${pypath}" ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/fdlimit.py) endif(HAS_PROACTOR) + +# fuzz tests: tests/fuzz +if (ENABLE_FUZZ_TESTING) + add_subdirectory(fuzz) +endif (ENABLE_FUZZ_TESTING) http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/64ed1852/proton-c/src/tests/fuzz/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/proton-c/src/tests/fuzz/CMakeLists.txt b/proton-c/src/tests/fuzz/CMakeLists.txt index 8e5057f..0e617ee 100644 --- a/proton-c/src/tests/fuzz/CMakeLists.txt +++ b/proton-c/src/tests/fuzz/CMakeLists.txt @@ -19,38 +19,44 @@ add_definitions(${COMPILE_WARNING_FLAGS} ${COMPILE_PLATFORM_FLAGS}) +option(FUZZ_REGRESSION_TESTS "Run fuzz tests with regression test driver" ON) +option(FUZZ_LONG_TESTS "Run fuzz tests that take a long time" OFF) + +if (FUZZ_REGRESSION_TESTS) + set(FUZZING_LIBRARY StandaloneFuzzTargetMain) +else () + set(FUZZING_LIBRARY FuzzingEngine) +endif () + add_library (StandaloneFuzzTargetMain StandaloneFuzzTargetMain.c) -if (BUILD_WITH_CXX) - # ignore the flag for this file, it complicates things for no gain -endif (BUILD_WITH_CXX) macro (pn_add_fuzz_test test) add_executable (${test} ${ARGN}) - if (FUZZING_ENGINE) - target_link_libraries (${test} qpid-proton FuzzingEngine) - else (FUZZING_ENGINE) - target_link_libraries (${test} qpid-proton StandaloneFuzzTargetMain) - endif (FUZZING_ENGINE) - if (BUILD_WITH_CXX) - set_source_files_properties (${ARGN} PROPERTIES LANGUAGE CXX) - else (BUILD_WITH_CXX) - set_target_properties(${test} PROPERTIES LINKER_LANGUAGE CXX) - endif (BUILD_WITH_CXX) - - if (FUZZING_ENGINE) - add_test (${test} ${CMAKE_CURRENT_BINARY_DIR}/${test} -runs=1 ${CMAKE_CURRENT_SOURCE_DIR}/${test}) - else (FUZZING_ENGINE) + target_link_libraries (${test} qpid-proton-core ${FUZZING_LIBRARY}) + + if (FUZZ_REGRESSION_TESTS) # StandaloneFuzzTargetMain cannot walk directory trees file(GLOB_RECURSE files ${CMAKE_CURRENT_SOURCE_DIR}/${test}/*) - add_test (${test} ${CMAKE_CURRENT_BINARY_DIR}/${test} ${files}) - endif (FUZZING_ENGINE) + add_test (${test} ${memcheck-cmd} ${CMAKE_CURRENT_BINARY_DIR}/${test} ${files}) + else () + add_test (${test} ${CMAKE_CURRENT_BINARY_DIR}/${test} -runs=1 ${CMAKE_CURRENT_SOURCE_DIR}/${test}) + endif () endmacro(pn_add_fuzz_test) +# Fuzz tests at the User API level pn_add_fuzz_test (fuzz-connection-driver fuzz-connection-driver.c) pn_add_fuzz_test (fuzz-message-decode fuzz-message-decode.c) -# pni_sniff_header is internal, it has to be compiled in anew -pn_add_fuzz_test (fuzz-sniff-header fuzz-sniff-header.c ${PROJECT_SOURCE_DIR}/proton-c/src/core/autodetect.c) -pn_add_fuzz_test (fuzz-url fuzz-url.c) -if(HAS_PROACTOR) + +# pn_url_parse is not in proton core and is only used by messenger so compile specially +pn_add_fuzz_test (fuzz-url fuzz-url.c ${PROJECT_SOURCE_DIR}/proton-c/src/extra/url.c ${PROJECT_SOURCE_DIR}/proton-c/src/core/util.c) + +# This regression test can take a very long time so don't run by default +if(HAS_PROACTOR AND FUZZ_LONG_TESTS) pn_add_fuzz_test (fuzz-proactor-receive fuzz-proactor-receive.c) -endif(HAS_PROACTOR) + target_link_libraries(fuzz-proactor-receive qpid-proton-proactor) +endif() + +# Fuzz tests of internals + +# pni_sniff_header is internal so it has to be compiled specially +pn_add_fuzz_test (fuzz-sniff-header fuzz-sniff-header.c ${PROJECT_SOURCE_DIR}/proton-c/src/core/autodetect.c) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org