Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrating FuzzTest into GoogleTests #1185

Open
athukuria opened this issue May 16, 2024 · 0 comments
Open

Integrating FuzzTest into GoogleTests #1185

athukuria opened this issue May 16, 2024 · 0 comments

Comments

@athukuria
Copy link

athukuria commented May 16, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant