Skip to content

Add flatbuffers enum domain #1642

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/cmake_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ jobs:
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache \
-D CMAKE_BUILD_TYPE=RelWithDebug \
-D FUZZTEST_BUILD_TESTING=on \
-D FUZZTEST_BUILD_FLATBUFFERS=on \
&& cmake --build build -j $(nproc) \
&& ctest --test-dir build -j $(nproc) --output-on-failure
- name: Run all tests in default mode with gcc
Expand All @@ -90,6 +91,7 @@ jobs:
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache \
-D CMAKE_BUILD_TYPE=RelWithDebug \
-D FUZZTEST_BUILD_TESTING=on \
-D FUZZTEST_BUILD_FLATBUFFERS=on \
&& cmake --build build_gcc -j $(nproc) \
&& ctest --test-dir build_gcc -j $(nproc) --output-on-failure
- name: Run end-to-end tests in fuzzing mode
Expand All @@ -104,6 +106,7 @@ jobs:
-D CMAKE_BUILD_TYPE=RelWithDebug \
-D FUZZTEST_FUZZING_MODE=on \
-D FUZZTEST_BUILD_TESTING=on \
-D FUZZTEST_BUILD_FLATBUFFERS=on \
&& cmake --build build -j $(nproc) \
&& ctest --test-dir build -j $(nproc) --output-on-failure -R "functional_test"
- name: Save new cache based on main
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.19)
project(fuzztest)

option(FUZZTEST_BUILD_TESTING "Building the tests." OFF)
option(FUZZTEST_BUILD_FLATBUFFERS "Building the flatbuffers support." OFF)
option(FUZZTEST_FUZZING_MODE "Building the fuzztest in fuzzing mode." OFF)
set(FUZZTEST_COMPATIBILITY_MODE "" CACHE STRING "Compatibility mode. Available options: <empty>, libfuzzer")
set(CMAKE_CXX_STANDARD 17)
Expand Down
6 changes: 4 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ bazel_dep(
name = "platforms",
version = "0.0.10",
)
bazel_dep(
name = "flatbuffers",
version = "25.2.10"
)
# GoogleTest is not a dev dependency, because it's needed when FuzzTest is used
# with GoogleTest integration (e.g., googletest_adaptor). Note that the FuzzTest
# framework can be used without GoogleTest integration as well.
Expand All @@ -55,8 +59,6 @@ bazel_dep(
name = "protobuf",
version = "30.2",
)
# TODO(lszekeres): Make this a dev dependency, as the protobuf library is only
# required for testing.
bazel_dep(
name = "rules_proto",
version = "7.1.0",
Expand Down
17 changes: 17 additions & 0 deletions cmake/BuildDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ set(proto_TAG v30.2)
set(nlohmann_json_URL https://github.com/nlohmann/json.git)
set(nlohmann_json_TAG v3.11.3)

set(flatbuffers_URL https://github.com/google/flatbuffers.git)
set(flatbuffers_TAG v25.2.10)

if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0135 NEW)
Expand Down Expand Up @@ -50,6 +53,14 @@ FetchContent_Declare(
URL_HASH MD5=${antlr_cpp_MD5}
)

if (FUZZTEST_BUILD_FLATBUFFERS)
FetchContent_Declare(
flatbuffers
GIT_REPOSITORY ${flatbuffers_URL}
GIT_TAG ${flatbuffers_TAG}
)
endif()

if (FUZZTEST_BUILD_TESTING)

FetchContent_Declare(
Expand Down Expand Up @@ -87,3 +98,9 @@ if (FUZZTEST_BUILD_TESTING)
FetchContent_MakeAvailable(nlohmann_json)

endif ()

if (FUZZTEST_BUILD_FLATBUFFERS)
set(FLATBUFFERS_BUILD_TESTS OFF)
set(FLATBUFFERS_BUILD_INSTALL OFF)
FetchContent_MakeAvailable(flatbuffers)
endif()
1 change: 1 addition & 0 deletions cmake/generate_cmake_from_bazel.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"@abseil-cpp//absl/types:optional": "absl::optional",
"@abseil-cpp//absl/types:span": "absl::span",
"@abseil-cpp//absl/types:variant": "absl::variant",
"@flatbuffers//:runtime_cc": "flatbuffers",
"@googletest//:gtest": "GTest::gtest",
"@googletest//:gtest_main": "GTest::gmock_main",
"@protobuf//:protobuf": "protobuf::libprotobuf",
Expand Down
16 changes: 16 additions & 0 deletions domain_tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@ cc_test(
],
)

cc_test(
name = "arbitrary_domains_flatbuffers_test",
srcs = ["arbitrary_domains_flatbuffers_test.cc"],
deps = [
":domain_testing",
"@abseil-cpp//absl/container:flat_hash_map",
"@abseil-cpp//absl/random",
"@com_google_fuzztest//fuzztest:domain",
"@com_google_fuzztest//fuzztest:flatbuffers",
"@com_google_fuzztest//fuzztest:meta",
"@com_google_fuzztest//fuzztest:test_flatbuffers_cc_fbs",
"@flatbuffers//:runtime_cc",
"@googletest//:gtest_main",
],
)

cc_test(
name = "arbitrary_domains_protobuf_test",
srcs = ["arbitrary_domains_protobuf_test.cc"],
Expand Down
23 changes: 23 additions & 0 deletions domain_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,29 @@ fuzztest_cc_test(
GTest::gmock_main
)

if (FUZZTEST_BUILD_FLATBUFFERS)
fuzztest_cc_test(
NAME
arbitrary_domains_flatbuffers_test
SRCS
"arbitrary_domains_flatbuffers_test.cc"
DEPS
absl::flat_hash_set
absl::random_bit_gen_ref
absl::random_random
absl::strings
flatbuffers
fuzztest::domain
fuzztest::domain_testing
fuzztest::flatbuffers
GTest::gmock_main
test_flatbuffers
)
add_dependencies(fuzztest_arbitrary_domains_flatbuffers_test
GENERATE_test_flatbuffers
)
endif()

fuzztest_cc_test(
NAME
arbitrary_domains_protobuf_test
Expand Down
Loading