[fuzz] add CMake support (#6147)

This commit is contained in:
Jonathan Hui
2021-02-08 11:28:05 -08:00
committed by GitHub
parent d8b89223b4
commit abb415c419
3 changed files with 142 additions and 3 deletions
+2 -1
View File
@@ -190,7 +190,8 @@ add_subdirectory(third_party EXCLUDE_FROM_ALL)
if(OT_PLATFORM STREQUAL "simulation")
enable_testing()
add_subdirectory(tests)
endif()
add_subdirectory(tests)
add_custom_target(print-ot-config ALL COMMAND echo -e "$<JOIN:$<TARGET_PROPERTY:ot-config,INTERFACE_COMPILE_DEFINITIONS>,\"\\n\">")
+10 -2
View File
@@ -26,6 +26,14 @@
# POSSIBILITY OF SUCH DAMAGE.
#
if(OT_FTD)
add_subdirectory(unit)
if(OT_PLATFORM STREQUAL "simulation")
if(OT_FTD)
add_subdirectory(unit)
endif()
endif()
option(OT_FUZZ_TARGETS "enable fuzz targets" OFF)
if(OT_FUZZ_TARGETS)
add_subdirectory(fuzz)
endif()
+130
View File
@@ -0,0 +1,130 @@
#
# Copyright (c) 2021, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
set(COMMON_INCLUDES
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/src/core
)
set(COMMON_COMPILE_OPTIONS
-DOPENTHREAD_FTD=1
-DOPENTHREAD_SPINEL_CONFIG_OPENTHREAD_MESSAGE_ENABLE=1
)
set(COMMON_SOURCES
fuzzer_platform.cpp
)
set(COMMON_LIBS
openthread-ftd
${OT_MBEDTLS}
$ENV{LIB_FUZZING_ENGINE}
ot-config
)
add_executable(cli-uart-received-fuzzer
cli_uart_received.cpp
${COMMON_SOURCES}
)
target_compile_options(cli-uart-received-fuzzer
PRIVATE
${COMMON_COMPILE_OPTIONS}
)
target_include_directories(cli-uart-received-fuzzer
PRIVATE
${COMMON_INCLUDES}
)
target_link_libraries(cli-uart-received-fuzzer
PRIVATE
openthread-cli-ftd
${COMMON_LIBS}
)
add_executable(ip6-send-fuzzer
ip6_send.cpp
${COMMON_SOURCES}
)
target_compile_options(ip6-send-fuzzer
PRIVATE
${COMMON_COMPILE_OPTIONS}
)
target_include_directories(ip6-send-fuzzer
PRIVATE
${COMMON_INCLUDES}
)
target_link_libraries(ip6-send-fuzzer
PRIVATE
${COMMON_LIBS}
)
add_executable(radio-receive-done-fuzzer
radio_receive_done.cpp
${COMMON_SOURCES}
)
target_compile_options(radio-receive-done-fuzzer
PRIVATE
${COMMON_COMPILE_OPTIONS}
)
target_include_directories(radio-receive-done-fuzzer
PRIVATE
${COMMON_INCLUDES}
)
target_link_libraries(radio-receive-done-fuzzer
PRIVATE
${COMMON_LIBS}
)
add_executable(ncp-uart-received-fuzzer
ncp_uart_received.cpp
${COMMON_SOURCES}
)
target_compile_options(ncp-uart-received-fuzzer
PRIVATE
${COMMON_COMPILE_OPTIONS}
)
target_include_directories(ncp-uart-received-fuzzer
PRIVATE
${COMMON_INCLUDES}
)
target_link_libraries(ncp-uart-received-fuzzer
PRIVATE
openthread-ncp-ftd
${COMMON_LIBS}
)