diff options
| author | 童宗振 <[email protected]> | 2023-12-06 01:32:10 +0000 |
|---|---|---|
| committer | 陆秋文 <[email protected]> | 2023-12-06 01:32:10 +0000 |
| commit | 0c5df1fe2e8451cb85ee25bf01fb111d15a4ed0f (patch) | |
| tree | b3094bf0c1d4ccf5701405af0ebd17b3a2807a21 /CMakeLists.txt | |
| parent | ec675d14711232e2ca3ddbc07b2d6f7209ea93c8 (diff) | |
add fuzz testing for the packet parser
Diffstat (limited to 'CMakeLists.txt')
| -rw-r--r-- | CMakeLists.txt | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 66447c1..218f43b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,12 @@ cmake_minimum_required(VERSION 3.0) + +# Must be set before project, otherwise you cannot choose between gcc and clang +option(ENABLE_FUZZING_TEST "Enable fuzzing test" False) +if(ENABLE_FUZZING_TEST) + set(CMAKE_C_COMPILER "clang") + set(CMAKE_CXX_COMPILER "clang++") +endif() + project(marsio) if(NOT MACHINE) @@ -9,7 +17,14 @@ set(RTE_MARCH ${MACHINE}) # Include Modules set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) + find_package(DPDK REQUIRED) +link_directories(${DPDK_LIBRARY_DIR}) +include_directories(${DPDK_INCLUDE_DIR}) + +find_package(PCAP REQUIRED) +link_directories(${PCAP_LIBRARY_DIR}) +include_directories(${PCAP_INCLUDE_DIR}) # version include(Version) @@ -46,6 +61,17 @@ elseif(ENABLE_SANITIZE_THREAD) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lasan") endif() +if(ENABLE_FUZZING_TEST) + # These options need to be added to the compilation options when building the library under test + # ref: https://github.com/google/fuzzer-test-suite/blob/master/common.sh + set(FSANITIZE_FUZZER_FLAGS "-fsanitize=address,fuzzer-no-link") + set(COVERAGE_FLAGS "-fprofile-instr-generate -fcoverage-mapping") + set(OTHER_FLAGS "-fPIC -m64 -march=${MACHINE}") + set(CMAKE_C_FLAGS "${FSANITIZE_FUZZER_FLAGS} ${COVERAGE_FLAGS} ${OTHER_FLAGS}") + set(CMAKE_CXX_FLAGS "${FSANITIZE_FUZZER_FLAGS} ${COVERAGE_FLAGS} ${OTHER_FLAGS}") + add_subdirectory(fuzzing) +endif() + if(ENABLE_VNODE_CHECK_THREAD_SAFE) add_definitions(-DVNODE_CHECK_THREAD_SAFE) endif() |
