google / google/fuzztest

Integrating FuzzTest into GoogleTests

Open
#1,185 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
1.1k
Forks
137
Avg merge
3d 6h
Merged PRs (30d)
22

Description

Hi,

Here is my CMakeLists.txt file for my existing google unit tests, and Now I want to integrate Fuzztests to it.
How can I add/update my existing CMakeLists.txt file to support this?
Do I need to install any package for fuzztest ?

here is my CMakeLists.txt file:

```
include(FetchContent)
include(GoogleTest)

FetchContent_Declare(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.11.0
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-src"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-build"
)

FetchContent_MakeAvailable(googletest)

add_compile_options(
-O0
-ggdb
)

# Add source files from the src/dbus directory
file(GLOB SRC_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../../src/*.cpp)

include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/../../src
${CMAKE_CURRENT_SOURCE_DIR}/../../src/dbus
${GLIBMM_INCLUDE_DIRS}
${JSONRPC_INCLUDE_DIRS}
${OPENSSL_INCLUDE_DIRS}
${LIBWEBSOCKETS_INCLUDE_DIRS}
${LIBCURL_INCLUDE_DIRS}
${CMAKE_BINARY_DIR}/_deps/googletest-src/googletest/include
${CMAKE_CURRENT_BINARY_DIR}/googletest-src/googletest
${CMAKE_CURRENT_BINARY_DIR}/googletest-src/googletest/include
${CMAKE_CURRENT_BINARY_DIR}/googletest-src/googlemock
${CMAKE_CURRENT_BINARY_DIR}/googletest-src/googlemock/include

)

# Set sources for your test files
set(TEST_SOURCES
Test_Main.cpp
)

# Create executable for tests
add_executable(tests ${TEST_SOURCES} ${DBUS_SOURCES} ${SRC_SOURCES})
#target_link_libraries(tests gtest gtest_main)
# Link GoogleTest to your executable
#target_link_libraries(tests ${GTEST_LIBRARIES} pthread)

target_link_libraries(tests ${GTEST_LIBRARIES}
gtest
gtest_main
gmock
gmock_main
${GLIBMM_LIBRARIES}
${JSONRPC_LIBRARIES}
${LIBSYSTEMD_LIBRARIES}
${OPENSSL_LIBRARIES}
${LIBWEBSOCKETS_LIBRARIES}
${LIBCURL_LIBRARIES}
)

```
I am thinking of having a package check , uisng below code in my main CMakeLists.txt file:
find_package(fuzztest REQUIRED)

I am thing about this approach because I need fuzztest.h header for test files.

Please suggest.

Thanks

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.