Skip to content

Commit

Permalink
Fuzzing: Add CMake project files for fuzz targets
Browse files Browse the repository at this point in the history
Change-Id: Ied44bfd2c83d5590066146187a7333b677ceb179
Reviewed-by: Alexandru Croitor <[email protected]>
  • Loading branch information
rlohning committed May 31, 2021
1 parent 4b0b87b commit 8b691ce
Show file tree
Hide file tree
Showing 13 changed files with 344 additions and 108 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
cmake_minimum_required(VERSION 3.14)
project(next LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

find_package(Qt6 COMPONENTS Core)

qt_add_executable(next
main.cpp
)

target_link_libraries(next PUBLIC
Qt::Core
)
if(DEFINED ENV{LIB_FUZZING_ENGINE})
target_link_libraries(next PRIVATE
$ENV{LIB_FUZZING_ENGINE}
)
else()
target_link_libraries(next PRIVATE
-fsanitize=fuzzer
)
endif()
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
cmake_minimum_required(VERSION 3.14)
project(fromcbor LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

find_package(Qt6 COMPONENTS Core)

qt_add_executable(fromcbor
main.cpp
)

target_link_libraries(fromcbor PUBLIC
Qt::Core
)
if(DEFINED ENV{LIB_FUZZING_ENGINE})
target_link_libraries(fromcbor PRIVATE
$ENV{LIB_FUZZING_ENGINE}
)
else()
target_link_libraries(fromcbor PRIVATE
-fsanitize=fuzzer
)
endif()
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
cmake_minimum_required(VERSION 3.14)
project(extractionoperator-float LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

find_package(Qt6 COMPONENTS Core)

qt_add_executable(extractionoperator-float
main.cpp
)

target_link_libraries(extractionoperator-float PUBLIC
Qt::Core
)
if(DEFINED ENV{LIB_FUZZING_ENGINE})
target_link_libraries(extractionoperator-float PRIVATE
$ENV{LIB_FUZZING_ENGINE}
)
else()
target_link_libraries(extractionoperator-float PRIVATE
-fsanitize=fuzzer
)
endif()
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
cmake_minimum_required(VERSION 3.14)
project(readnext LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

find_package(Qt6 COMPONENTS Core)

qt_add_executable(readnext
main.cpp
)

target_link_libraries(readnext PUBLIC
Qt::Core
)
if(DEFINED ENV{LIB_FUZZING_ENGINE})
target_link_libraries(readnext PRIVATE
$ENV{LIB_FUZZING_ENGINE}
)
else()
target_link_libraries(readnext PRIVATE
-fsanitize=fuzzer
)
endif()
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# Generated from optimize.pro.
cmake_minimum_required(VERSION 3.14)
project(optimize LANGUAGES CXX)

#####################################################################
## optimize Binary:
#####################################################################
set(CMAKE_INCLUDE_CURRENT_DIR ON)

qt_internal_add_executable(optimize
GUI
SOURCES
main.cpp
)

#### Keys ignored in scope 1:.:.:optimize.pro:<TRUE>:
# FUZZ_ENGINE = "$$(LIB_FUZZING_ENGINE)"
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

## Scopes:
#####################################################################
find_package(Qt6 COMPONENTS Core)

qt_internal_extend_target(optimize CONDITION FUZZ_ENGINE_ISEMPTY
LINK_OPTIONS
"-fsanitize=fuzzer"
qt_add_executable(optimize
main.cpp
)

qt_internal_extend_target(optimize CONDITION NOT FUZZ_ENGINE_ISEMPTY
PUBLIC_LIBRARIES
$ENV{LIB_FUZZING_ENGINE}
target_link_libraries(optimize PUBLIC
Qt::Core
)
if(DEFINED ENV{LIB_FUZZING_ENGINE})
target_link_libraries(optimize PRIVATE
$ENV{LIB_FUZZING_ENGINE}
)
else()
target_link_libraries(optimize PRIVATE
-fsanitize=fuzzer
)
endif()
27 changes: 27 additions & 0 deletions tests/libfuzzer/corelib/time/qdatetime/fromstring/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
cmake_minimum_required(VERSION 3.14)
project(fromstring LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

find_package(Qt6 COMPONENTS Core)

qt_add_executable(fromstring
main.cpp
)

target_link_libraries(fromstring PUBLIC
Qt::Core
)
if(DEFINED ENV{LIB_FUZZING_ENGINE})
target_link_libraries(fromstring PRIVATE
$ENV{LIB_FUZZING_ENGINE}
)
else()
target_link_libraries(fromstring PRIVATE
-fsanitize=fuzzer
)
endif()
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
cmake_minimum_required(VERSION 3.14)
project(result LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

find_package(Qt6 COMPONENTS Core)

qt_add_executable(result
main.cpp
)

target_link_libraries(result PUBLIC
Qt::Core
)
if(DEFINED ENV{LIB_FUZZING_ENGINE})
target_link_libraries(result PRIVATE
$ENV{LIB_FUZZING_ENGINE}
)
else()
target_link_libraries(result PRIVATE
-fsanitize=fuzzer
)
endif()
33 changes: 33 additions & 0 deletions tests/libfuzzer/gui/image/qimage/loadfromdata/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
cmake_minimum_required(VERSION 3.14)
project(loadfromdata LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)

qt_add_executable(loadfromdata
main.cpp
)

target_link_libraries(loadfromdata PUBLIC
Qt::Core
Qt::Gui
)
if(DEFINED ENV{LIB_FUZZING_ENGINE})
target_link_libraries(loadfromdata PRIVATE
$ENV{LIB_FUZZING_ENGINE}
)
else()
target_link_libraries(loadfromdata PRIVATE
-fsanitize=fuzzer
)
endif()

qt_import_plugins(loadfromdata
INCLUDE Qt::QMinimalIntegrationPlugin
)
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
# Generated from fromiccprofile.pro.
cmake_minimum_required(VERSION 3.14)
project(fromiccprofile LANGUAGES CXX)

#####################################################################
## fromiccprofile Binary:
#####################################################################
set(CMAKE_INCLUDE_CURRENT_DIR ON)

qt_internal_add_executable(fromiccprofile
GUI
SOURCES
main.cpp
PUBLIC_LIBRARIES
Qt::Gui
)

#### Keys ignored in scope 1:.:.:fromiccprofile.pro:<TRUE>:
# FUZZ_ENGINE = "$$(LIB_FUZZING_ENGINE)"
# QTPLUGIN = "qminimal"
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

## Scopes:
#####################################################################
find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)

qt_internal_extend_target(fromiccprofile CONDITION FUZZ_ENGINE_ISEMPTY
LINK_OPTIONS
"-fsanitize=fuzzer"
qt_add_executable(fromiccprofile
main.cpp
)

qt_internal_extend_target(fromiccprofile CONDITION NOT FUZZ_ENGINE_ISEMPTY
PUBLIC_LIBRARIES
target_link_libraries(fromiccprofile PUBLIC
Qt::Core
Qt::Gui
)
if(DEFINED ENV{LIB_FUZZING_ENGINE})
target_link_libraries(fromiccprofile PRIVATE
$ENV{LIB_FUZZING_ENGINE}
)
else()
target_link_libraries(fromiccprofile PRIVATE
-fsanitize=fuzzer
)
endif()

qt_import_plugins(fromiccprofile
INCLUDE Qt::QMinimalIntegrationPlugin
)
47 changes: 25 additions & 22 deletions tests/libfuzzer/gui/text/qtextdocument/sethtml/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
# Generated from sethtml.pro.
cmake_minimum_required(VERSION 3.14)
project(sethtml LANGUAGES CXX)

#####################################################################
## sethtml Binary:
#####################################################################
set(CMAKE_INCLUDE_CURRENT_DIR ON)

qt_internal_add_executable(sethtml
GUI
SOURCES
main.cpp
PUBLIC_LIBRARIES
Qt::Gui
)

#### Keys ignored in scope 1:.:.:sethtml.pro:<TRUE>:
# FUZZ_ENGINE = "$$(LIB_FUZZING_ENGINE)"
# QTPLUGIN = "qminimal"
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

## Scopes:
#####################################################################
find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)

qt_internal_extend_target(sethtml CONDITION FUZZ_ENGINE_ISEMPTY
LINK_OPTIONS
"-fsanitize=fuzzer"
qt_add_executable(sethtml
main.cpp
)

qt_internal_extend_target(sethtml CONDITION NOT FUZZ_ENGINE_ISEMPTY
PUBLIC_LIBRARIES
target_link_libraries(sethtml PUBLIC
Qt::Core
Qt::Gui
)
if(DEFINED ENV{LIB_FUZZING_ENGINE})
target_link_libraries(sethtml PRIVATE
$ENV{LIB_FUZZING_ENGINE}
)
else()
target_link_libraries(sethtml PRIVATE
-fsanitize=fuzzer
)
endif()

qt_import_plugins(sethtml
INCLUDE Qt::QMinimalIntegrationPlugin
)
Loading

0 comments on commit 8b691ce

Please sign in to comment.