Skip to content

Commit

Permalink
Add fuzztest_core build target
Browse files Browse the repository at this point in the history
This target depends on //fuzztest:domain_core, which in turn depends only on Abseil-C++. This allows downstream consumers that want to limit their third-party dependencies to use FuzzTest at the cost of the InRegExp and InGrammar domains.

PiperOrigin-RevId: 595464042
  • Loading branch information
FuzzTest Team authored and copybara-github committed Jan 5, 2024
1 parent 8d83f5c commit f5c4a00
Show file tree
Hide file tree
Showing 29 changed files with 289 additions and 213 deletions.
24 changes: 14 additions & 10 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,18 @@ workspace(name = "com_google_fuzztest")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

################################################################################
# Transitive dependencies (not directly required by FuzzTest itself)
# Direct dependencies required by core FuzzTest (//fuzztest:fuzztest_core)
################################################################################

http_archive(
name = "com_google_absl",
sha256 = "0ddd37f347c58d89f449dd189a645bfd97bcd85c5284404a3af27a3ca3476f39",
strip_prefix = "abseil-cpp-fad946221cec37175e762c399760f54b9de9a9fa",
url = "https://github.com/abseil/abseil-cpp/archive/fad946221cec37175e762c399760f54b9de9a9fa.tar.gz",
)

################################################################################
# Transitive dependencies for core FuzzTest
################################################################################

# Required by com_google_absl.
Expand All @@ -31,16 +42,9 @@ http_archive(
)

################################################################################
# Direct dependencies
# Direct dependencies required for full FuzzTest (//fuzztest:fuzztest)
################################################################################

http_archive(
name = "com_google_absl",
sha256 = "0ddd37f347c58d89f449dd189a645bfd97bcd85c5284404a3af27a3ca3476f39",
strip_prefix = "abseil-cpp-fad946221cec37175e762c399760f54b9de9a9fa",
url = "https://github.com/abseil/abseil-cpp/archive/fad946221cec37175e762c399760f54b9de9a9fa.tar.gz",
)

http_archive(
name = "com_googlesource_code_re2",
sha256 = "5bb6875ae1cd1e9fedde98018c346db7260655f86fdb8837e3075103acd3649b",
Expand All @@ -63,7 +67,7 @@ http_archive(
)

################################################################################
# Dependencies required for Riegeli
# Transitive dependencies required by Riegeli (and therefore by full FuzzTest)
################################################################################

http_archive(
Expand Down
23 changes: 21 additions & 2 deletions cmake/AddFuzzTest.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
function(link_fuzztest name)
target_link_libraries(${name} PRIVATE fuzztest::fuzztest_gtest_main)
function(_link_fuzztest_compatibility_mode name)
if (FUZZTEST_COMPATIBILITY_MODE STREQUAL "libfuzzer")
EXECUTE_PROCESS (
COMMAND bash -c "command -v llvm-config || command -v llvm-config-16 || command -v llvm-config-15 || command -v llvm-config-14 || command -v llvm-config-13 || command -v llvm-config-12 || echo"
Expand All @@ -12,3 +11,23 @@ function(link_fuzztest name)
target_link_libraries(${name} PRIVATE ${FUZZER_NO_MAIN})
endif ()
endfunction()

function(link_fuzztest name)
target_link_libraries(
${name}
PRIVATE
fuzztest::fuzztest
fuzztest::fuzztest_gtest_main
)
_link_fuzztest_compatibility_mode(${name})
endfunction()

function(link_fuzztest_core name)
target_link_libraries(
${name}
PRIVATE
fuzztest::fuzztest_core
fuzztest::fuzztest_gtest_main
)
_link_fuzztest_compatibility_mode(${name})
endfunction()
19 changes: 9 additions & 10 deletions domain_tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ cc_test(
"@com_google_absl//absl/types:optional",
"@com_google_absl//absl/types:span",
"@com_google_absl//absl/types:variant",
"@com_google_fuzztest//fuzztest:domain",
"@com_google_fuzztest//fuzztest:domain_core",
"@com_google_googletest//:gtest_main",
],
)
Expand Down Expand Up @@ -60,7 +60,6 @@ cc_test(
"@com_google_absl//absl/status",
"@com_google_absl//absl/time",
"@com_google_fuzztest//fuzztest:absl_helpers",
"@com_google_fuzztest//fuzztest:domain",
"@com_google_fuzztest//fuzztest:domain_core",
"@com_google_fuzztest//fuzztest:serialization",
"@com_google_fuzztest//fuzztest:test_protobuf_cc_proto",
Expand All @@ -78,7 +77,7 @@ cc_test(
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/random",
"@com_google_absl//absl/strings",
"@com_google_fuzztest//fuzztest:domain",
"@com_google_fuzztest//fuzztest:domain_core",
"@com_google_fuzztest//fuzztest:type_support",
"@com_google_googletest//:gtest_main",
],
Expand All @@ -93,7 +92,7 @@ cc_test(
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/random",
"@com_google_fuzztest//fuzztest:coverage",
"@com_google_fuzztest//fuzztest:domain",
"@com_google_fuzztest//fuzztest:domain_core",
"@com_google_fuzztest//fuzztest:type_support",
"@com_google_googletest//:gtest_main",
],
Expand Down Expand Up @@ -173,7 +172,7 @@ cc_test(
"@com_google_absl//absl/numeric:int128",
"@com_google_absl//absl/random",
"@com_google_absl//absl/types:span",
"@com_google_fuzztest//fuzztest:domain",
"@com_google_fuzztest//fuzztest:domain_core",
"@com_google_fuzztest//fuzztest:meta",
"@com_google_fuzztest//fuzztest:type_support",
"@com_google_googletest//:gtest_main",
Expand All @@ -191,7 +190,7 @@ cc_test(
"@com_google_absl//absl/status",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:span",
"@com_google_fuzztest//fuzztest:domain",
"@com_google_fuzztest//fuzztest:domain_core",
"@com_google_fuzztest//fuzztest:serialization",
"@com_google_googletest//:gtest_main",
],
Expand All @@ -203,7 +202,7 @@ cc_test(
deps = [
":domain_testing",
"@com_google_absl//absl/random",
"@com_google_fuzztest//fuzztest:domain",
"@com_google_fuzztest//fuzztest:domain_core",
"@com_google_googletest//:gtest_main",
],
)
Expand All @@ -214,7 +213,7 @@ cc_test(
deps = [
":domain_testing",
"@com_google_absl//absl/random",
"@com_google_fuzztest//fuzztest:domain",
"@com_google_fuzztest//fuzztest:domain_core",
"@com_google_googletest//:gtest_main",
],
)
Expand All @@ -228,7 +227,7 @@ cc_test(
"@com_google_absl//absl/random",
"@com_google_absl//absl/time",
"@com_google_absl//absl/types:span",
"@com_google_fuzztest//fuzztest:domain",
"@com_google_fuzztest//fuzztest:domain_core",
"@com_google_googletest//:gtest_main",
],
)
Expand All @@ -240,7 +239,7 @@ cc_test(
":domain_testing",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/random",
"@com_google_fuzztest//fuzztest:domain",
"@com_google_fuzztest//fuzztest:domain_core",
"@com_google_googletest//:gtest_main",
],
)
19 changes: 9 additions & 10 deletions domain_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fuzztest_cc_test(
absl::optional
absl::span
absl::variant
fuzztest::domain
fuzztest::domain_core
GTest::gmock_main
)

Expand Down Expand Up @@ -48,7 +48,6 @@ fuzztest_cc_test(
absl::status
absl::time
fuzztest::absl_helpers
fuzztest::domain
fuzztest::domain_core
fuzztest::serialization
test_protobuf
Expand All @@ -67,7 +66,7 @@ fuzztest_cc_test(
absl::flat_hash_set
absl::random_random
absl::strings
fuzztest::domain
fuzztest::domain_core
fuzztest::type_support
GTest::gmock_main
)
Expand All @@ -83,7 +82,7 @@ fuzztest_cc_test(
absl::flat_hash_set
absl::random_random
fuzztest::coverage
fuzztest::domain
fuzztest::domain_core
fuzztest::type_support
GTest::gmock_main
)
Expand Down Expand Up @@ -166,7 +165,7 @@ fuzztest_cc_test(
absl::int128
absl::random_random
absl::span
fuzztest::domain
fuzztest::domain_core
fuzztest::meta
fuzztest::type_support
GTest::gmock_main
Expand All @@ -185,7 +184,7 @@ fuzztest_cc_test(
absl::status
absl::strings
absl::span
fuzztest::domain
fuzztest::domain_core
fuzztest::serialization
GTest::gmock_main
)
Expand All @@ -198,7 +197,7 @@ fuzztest_cc_test(
DEPS
fuzztest::domain_testing
absl::random_random
fuzztest::domain
fuzztest::domain_core
GTest::gmock_main
)

Expand All @@ -210,7 +209,7 @@ fuzztest_cc_test(
DEPS
fuzztest::domain_testing
absl::random_random
fuzztest::domain
fuzztest::domain_core
GTest::gmock_main
)

Expand All @@ -225,7 +224,7 @@ fuzztest_cc_test(
absl::random_random
absl::time
absl::span
fuzztest::domain
fuzztest::domain_core
GTest::gmock_main
)

Expand All @@ -238,6 +237,6 @@ fuzztest_cc_test(
fuzztest::domain_testing
absl::flat_hash_set
absl::random_random
fuzztest::domain
fuzztest::domain_core
GTest::gmock_main
)
2 changes: 1 addition & 1 deletion domain_tests/aggregate_combinators_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "absl/types/optional.h"
#include "absl/types/span.h"
#include "absl/types/variant.h"
#include "./fuzztest/domain.h"
#include "./fuzztest/domain_core.h"
#include "./domain_tests/domain_testing.h"

namespace fuzztest {
Expand Down
2 changes: 1 addition & 1 deletion domain_tests/arbitrary_domains_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "absl/random/random.h"
#include "absl/status/status.h"
#include "absl/time/time.h"
#include "./fuzztest/domain.h" // IWYU pragma: keep
#include "./fuzztest/domain_core.h" // IWYU pragma: keep
#include "./domain_tests/domain_testing.h"
#include "./fuzztest/internal/domains/absl_helpers.h"
#include "./fuzztest/internal/domains/arbitrary_impl.h"
Expand Down
2 changes: 1 addition & 1 deletion domain_tests/container_combinators_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "absl/container/flat_hash_set.h"
#include "absl/random/random.h"
#include "absl/strings/str_cat.h"
#include "./fuzztest/domain.h"
#include "./fuzztest/domain_core.h"
#include "./domain_tests/domain_testing.h"
#include "./fuzztest/internal/type_support.h"

Expand Down
2 changes: 1 addition & 1 deletion domain_tests/container_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "absl/container/flat_hash_map.h"
#include "absl/container/flat_hash_set.h"
#include "absl/random/random.h"
#include "./fuzztest/domain.h"
#include "./fuzztest/domain_core.h"
#include "./domain_tests/domain_testing.h"
#include "./fuzztest/internal/coverage.h"
#include "./fuzztest/internal/type_support.h"
Expand Down
2 changes: 1 addition & 1 deletion domain_tests/misc_domains_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "absl/numeric/int128.h"
#include "absl/random/random.h"
#include "absl/types/span.h"
#include "./fuzztest/domain.h"
#include "./fuzztest/domain_core.h"
#include "./domain_tests/domain_testing.h"
#include "./fuzztest/internal/meta.h"
#include "./fuzztest/internal/type_support.h"
Expand Down
2 changes: 1 addition & 1 deletion domain_tests/numeric_domains_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "absl/strings/str_cat.h"
#include "absl/strings/substitute.h"
#include "absl/types/span.h"
#include "./fuzztest/domain.h"
#include "./fuzztest/domain_core.h"
#include "./domain_tests/domain_testing.h"
#include "./fuzztest/internal/serialization.h"

Expand Down
2 changes: 1 addition & 1 deletion domain_tests/pointer_domains_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "absl/random/random.h"
#include "./fuzztest/domain.h"
#include "./fuzztest/domain_core.h"
#include "./domain_tests/domain_testing.h"

namespace fuzztest {
Expand Down
2 changes: 1 addition & 1 deletion domain_tests/recursive_domains_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "absl/random/random.h"
#include "./fuzztest/domain.h"
#include "./fuzztest/domain_core.h"
#include "./domain_tests/domain_testing.h"

namespace fuzztest {
Expand Down
2 changes: 1 addition & 1 deletion domain_tests/specific_value_domains_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "absl/random/random.h"
#include "absl/time/time.h"
#include "absl/types/span.h"
#include "./fuzztest/domain.h"
#include "./fuzztest/domain_core.h"
#include "./domain_tests/domain_testing.h"

namespace fuzztest {
Expand Down
2 changes: 1 addition & 1 deletion domain_tests/string_domains_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "gtest/gtest.h"
#include "absl/container/flat_hash_set.h"
#include "absl/random/random.h"
#include "./fuzztest/domain.h"
#include "./fuzztest/domain_core.h"
#include "./domain_tests/domain_testing.h"

namespace fuzztest {
Expand Down
4 changes: 2 additions & 2 deletions e2e_tests/testdata/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ cc_binary(
testonly = 1,
srcs = ["fuzz_tests_with_invalid_seeds.cc"],
deps = [
"@com_google_fuzztest//fuzztest",
"@com_google_fuzztest//fuzztest:fuzztest_core",
"@com_google_fuzztest//fuzztest:fuzztest_gtest_main",
],
)
Expand All @@ -85,7 +85,7 @@ cc_binary(
testonly = 1,
srcs = ["dynamically_registered_fuzz_tests.cc"],
deps = [
"@com_google_fuzztest//fuzztest",
"@com_google_fuzztest//fuzztest:fuzztest_core",
"@com_google_fuzztest//fuzztest:fuzztest_gtest_main",
],
)
2 changes: 1 addition & 1 deletion e2e_tests/testdata/dynamically_registered_fuzz_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "./fuzztest/fuzztest.h"
#include "./fuzztest/fuzztest_core.h"

namespace {

Expand Down
2 changes: 1 addition & 1 deletion e2e_tests/testdata/fuzz_tests_with_invalid_seeds.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

// Fuzz test examples to be used by `functional_test` only.

#include "./fuzztest/fuzztest.h"
#include "./fuzztest/fuzztest_core.h"

namespace {

Expand Down
Loading

0 comments on commit f5c4a00

Please sign in to comment.