Skip to content

Commit 027a6ee

Browse files
lszekerescopybara-github
authored andcommitted
Organize BUILD files.
PiperOrigin-RevId: 764542690
1 parent 3de7164 commit 027a6ee

File tree

21 files changed

+1770
-1490
lines changed

21 files changed

+1770
-1490
lines changed

.github/workflows/bazel_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
if: matrix.config == 'default'
6464
run: |
6565
bazel build -c ${{ matrix.compilation_mode }} \
66-
--copt=-DFUZZTEST_COMPATIBILITY_MODE -- //fuzztest:compatibility_mode
66+
--copt=-DFUZZTEST_COMPATIBILITY_MODE -- //fuzztest/internal:compatibility_mode
6767
- name: Run end-to-end tests with --config=fuzztest
6868
if: matrix.config == 'fuzztest'
6969
run: |

CMakeLists.txt

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2024 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
cmake_minimum_required(VERSION 3.19)
216
project(fuzztest)
317

@@ -36,6 +50,7 @@ fuzztest_setup_fuzzing_flags()
3650

3751
include(cmake/BuildDependencies.cmake)
3852
include(cmake/FuzzTestHelpers.cmake)
53+
include(cmake/CompatibilityModeLinkLibFuzzer.cmake)
3954

4055
include_directories(${re2_SOURCE_DIR})
4156

@@ -48,12 +63,16 @@ if (FUZZTEST_BUILD_TESTING)
4863
include(${protobuf_SOURCE_DIR}/cmake/protobuf-generate.cmake)
4964
endif ()
5065

51-
add_subdirectory(grammar_codegen)
52-
add_subdirectory(tools)
5366
add_subdirectory(common)
5467
add_subdirectory(fuzztest)
55-
68+
add_subdirectory(fuzztest/grammars)
69+
add_subdirectory(fuzztest/internal)
70+
add_subdirectory(fuzztest/internal/domains)
71+
add_subdirectory(grammar_codegen)
72+
add_subdirectory(grammar_codegen/generated_antlr_parser)
73+
add_subdirectory(tools)
5674
if (FUZZTEST_BUILD_TESTING)
5775
add_subdirectory(domain_tests)
5876
add_subdirectory(e2e_tests)
77+
add_subdirectory(e2e_tests/testdata)
5978
endif ()

bazel/setup_configs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ REPO_NAME="${1}"
6868
# When used in the fuzztest repo itself.
6969
if [[ ${REPO_NAME} == "@" ]]; then
7070
COMMON_FILTER="//common:"
71-
FUZZTEST_FILTER="//fuzztest:"
71+
FUZZTEST_FILTER="//fuzztest:,//fuzztest/internal:,//fuzztest/internal/domains:"
7272
CENTIPEDE_FILTER="//centipede:,-//centipede/.*fuzz_target"
7373
else # When used in a client repo.
7474
COMMON_FILTER="common/.*"

build_defs/cc_fuzztest_grammar_library.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,5 @@ def cc_fuzztest_grammar_library(name, srcs, top_level_rule = None, insert_whites
5656
native.cc_library(
5757
name = name,
5858
hdrs = [output_file_name],
59-
deps = ["@com_google_fuzztest//fuzztest:domain"],
59+
deps = ["@com_google_fuzztest//fuzztest/internal/domains:in_grammar_impl"],
6060
)

centipede/BUILD

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ cc_library(
845845
"@com_google_fuzztest//common:logging",
846846
"@com_google_fuzztest//common:remote_file",
847847
"@com_google_fuzztest//common:status_macros",
848-
"@com_google_fuzztest//fuzztest:configuration",
848+
"@com_google_fuzztest//fuzztest/internal:configuration",
849849
],
850850
)
851851

@@ -878,7 +878,7 @@ cc_library(
878878
"@com_google_fuzztest//common:logging",
879879
"@com_google_fuzztest//common:remote_file",
880880
"@com_google_fuzztest//common:status_macros",
881-
"@com_google_fuzztest//fuzztest:configuration",
881+
"@com_google_fuzztest//fuzztest/internal:configuration",
882882
],
883883
)
884884

@@ -947,7 +947,7 @@ cc_library(
947947
"@abseil-cpp//absl/types:span",
948948
"@com_google_fuzztest//common:defs",
949949
"@com_google_fuzztest//fuzztest:domain_core",
950-
"@com_google_fuzztest//fuzztest:table_of_recent_compares",
950+
"@com_google_fuzztest//fuzztest/internal:table_of_recent_compares",
951951
],
952952
)
953953

@@ -1252,7 +1252,7 @@ cc_test(
12521252
":environment",
12531253
"@abseil-cpp//absl/log:check",
12541254
"@abseil-cpp//absl/time",
1255-
"@com_google_fuzztest//fuzztest:configuration",
1255+
"@com_google_fuzztest//fuzztest/internal:configuration",
12561256
"@googletest//:gtest_main",
12571257
],
12581258
)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
function(_link_libfuzzer_in_compatibility_mode name)
16+
if (FUZZTEST_COMPATIBILITY_MODE STREQUAL "libfuzzer")
17+
EXECUTE_PROCESS (
18+
COMMAND bash -c "find \${PATH//:/ } -maxdepth 1 -executable -name 'llvm-config*'"
19+
OUTPUT_VARIABLE LLVM_CONFIG OUTPUT_STRIP_TRAILING_WHITESPACE
20+
)
21+
EXECUTE_PROCESS(
22+
COMMAND bash -c "find $(${LLVM_CONFIG} --libdir) \
23+
-name libclang_rt.fuzzer_no_main-x86_64.a"
24+
OUTPUT_VARIABLE FUZZER_NO_MAIN OUTPUT_STRIP_TRAILING_WHITESPACE
25+
)
26+
if(NOT FUZZER_NO_MAIN)
27+
# LLVM_ENABLE_PER_TARGET_RUNTIME_DIR was set to ON when building LLVM.
28+
EXECUTE_PROCESS(
29+
COMMAND bash -c "find / -regex \
30+
\"$(${LLVM_CONFIG} --libdir).*$(${LLVM_CONFIG} --host-target).*libclang_rt.fuzzer_no_main.a\""
31+
OUTPUT_VARIABLE FUZZER_NO_MAIN OUTPUT_STRIP_TRAILING_WHITESPACE
32+
)
33+
endif()
34+
target_link_libraries(${name} PRIVATE ${FUZZER_NO_MAIN})
35+
endif ()
36+
endfunction()

domain_tests/BUILD

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ cc_test(
3131
"@abseil-cpp//absl/types:span",
3232
"@abseil-cpp//absl/types:variant",
3333
"@com_google_fuzztest//fuzztest:domain_core",
34-
"@com_google_fuzztest//fuzztest:serialization",
35-
"@com_google_fuzztest//fuzztest:type_support",
34+
"@com_google_fuzztest//fuzztest/internal:serialization",
35+
"@com_google_fuzztest//fuzztest/internal:type_support",
3636
"@googletest//:gtest_main",
3737
],
3838
)
@@ -48,7 +48,7 @@ cc_test(
4848
"@abseil-cpp//absl/strings",
4949
"@abseil-cpp//absl/strings:string_view",
5050
"@com_google_fuzztest//fuzztest:domain",
51-
"@com_google_fuzztest//fuzztest:test_protobuf_cc_proto",
51+
"@com_google_fuzztest//fuzztest/internal:test_protobuf_cc_proto",
5252
"@googletest//:gtest_main",
5353
"@protobuf",
5454
],
@@ -64,11 +64,11 @@ cc_test(
6464
"@abseil-cpp//absl/random:bit_gen_ref",
6565
"@abseil-cpp//absl/status",
6666
"@abseil-cpp//absl/time",
67-
"@com_google_fuzztest//fuzztest:absl_helpers",
6867
"@com_google_fuzztest//fuzztest:domain_core",
69-
"@com_google_fuzztest//fuzztest:serialization",
70-
"@com_google_fuzztest//fuzztest:test_protobuf_cc_proto",
71-
"@com_google_fuzztest//fuzztest:type_support",
68+
"@com_google_fuzztest//fuzztest/internal:serialization",
69+
"@com_google_fuzztest//fuzztest/internal:test_protobuf_cc_proto",
70+
"@com_google_fuzztest//fuzztest/internal:type_support",
71+
"@com_google_fuzztest//fuzztest/internal/domains:core_domains_impl",
7272
"@googletest//:gtest_main",
7373
],
7474
)
@@ -95,7 +95,7 @@ cc_test(
9595
"@abseil-cpp//absl/random",
9696
"@abseil-cpp//absl/strings",
9797
"@com_google_fuzztest//fuzztest:domain_core",
98-
"@com_google_fuzztest//fuzztest:meta",
98+
"@com_google_fuzztest//fuzztest/internal:meta",
9999
"@googletest//:gtest_main",
100100
],
101101
)
@@ -109,7 +109,7 @@ cc_test(
109109
"@abseil-cpp//absl/container:flat_hash_set",
110110
"@abseil-cpp//absl/random",
111111
"@com_google_fuzztest//fuzztest:domain_core",
112-
"@com_google_fuzztest//fuzztest:table_of_recent_compares",
112+
"@com_google_fuzztest//fuzztest/internal:table_of_recent_compares",
113113
"@googletest//:gtest_main",
114114
],
115115
)
@@ -126,11 +126,11 @@ cc_library(
126126
"@abseil-cpp//absl/random:bit_gen_ref",
127127
"@abseil-cpp//absl/status",
128128
"@abseil-cpp//absl/strings",
129-
"@com_google_fuzztest//fuzztest:domain_core",
130-
"@com_google_fuzztest//fuzztest:logging",
131-
"@com_google_fuzztest//fuzztest:meta",
132-
"@com_google_fuzztest//fuzztest:serialization",
133-
"@com_google_fuzztest//fuzztest:test_protobuf_cc_proto",
129+
"@com_google_fuzztest//fuzztest/internal:logging",
130+
"@com_google_fuzztest//fuzztest/internal:meta",
131+
"@com_google_fuzztest//fuzztest/internal:serialization",
132+
"@com_google_fuzztest//fuzztest/internal:test_protobuf_cc_proto",
133+
"@com_google_fuzztest//fuzztest/internal/domains:core_domains_impl",
134134
"@googletest//:gtest",
135135
"@protobuf",
136136
],
@@ -144,8 +144,8 @@ cc_test(
144144
"@abseil-cpp//absl/container:flat_hash_set",
145145
"@abseil-cpp//absl/random",
146146
"@com_google_fuzztest//fuzztest:domain",
147-
"@com_google_fuzztest//fuzztest:serialization",
148147
"@com_google_fuzztest//fuzztest/grammars:json_grammar",
148+
"@com_google_fuzztest//fuzztest/internal:serialization",
149149
"@googletest//:gtest_main",
150150
"@nlohmann_json//:json",
151151
],
@@ -187,8 +187,8 @@ cc_test(
187187
"@abseil-cpp//absl/strings",
188188
"@abseil-cpp//absl/types:span",
189189
"@com_google_fuzztest//fuzztest:domain_core",
190-
"@com_google_fuzztest//fuzztest:meta",
191-
"@com_google_fuzztest//fuzztest:type_support",
190+
"@com_google_fuzztest//fuzztest/internal:meta",
191+
"@com_google_fuzztest//fuzztest/internal:type_support",
192192
"@googletest//:gtest_main",
193193
],
194194
)
@@ -204,7 +204,7 @@ cc_test(
204204
"@abseil-cpp//absl/status",
205205
"@abseil-cpp//absl/strings",
206206
"@com_google_fuzztest//fuzztest:domain_core",
207-
"@com_google_fuzztest//fuzztest:serialization",
207+
"@com_google_fuzztest//fuzztest/internal:serialization",
208208
"@googletest//:gtest_main",
209209
],
210210
)
@@ -253,7 +253,7 @@ cc_test(
253253
"@abseil-cpp//absl/container:flat_hash_set",
254254
"@abseil-cpp//absl/random",
255255
"@com_google_fuzztest//fuzztest:domain_core",
256-
"@com_google_fuzztest//fuzztest:table_of_recent_compares",
256+
"@com_google_fuzztest//fuzztest/internal:table_of_recent_compares",
257257
"@googletest//:gtest_main",
258258
],
259259
)

domain_tests/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ fuzztest_cc_test(
5252
absl::random_bit_gen_ref
5353
absl::status
5454
absl::time
55-
fuzztest::absl_helpers
5655
fuzztest::domain_core
5756
fuzztest::serialization
5857
test_protobuf

domain_tests/arbitrary_domains_test.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@
3737
#include "absl/time/time.h"
3838
#include "./fuzztest/domain_core.h" // IWYU pragma: keep
3939
#include "./domain_tests/domain_testing.h"
40-
#include "./fuzztest/internal/domains/absl_helpers.h"
41-
#include "./fuzztest/internal/domains/arbitrary_impl.h"
42-
#include "./fuzztest/internal/domains/container_mutation_helpers.h"
4340
#include "./fuzztest/internal/domains/domain_base.h"
4441
#include "./fuzztest/internal/serialization.h"
4542
#include "./fuzztest/internal/test_protobuf.pb.h"

e2e_tests/BUILD

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ cc_library(
2929
"@abseil-cpp//absl/strings",
3030
"@abseil-cpp//absl/strings:string_view",
3131
"@abseil-cpp//absl/time",
32-
"@com_google_fuzztest//fuzztest:flag_name",
33-
"@com_google_fuzztest//fuzztest:subprocess",
32+
"@com_google_fuzztest//fuzztest/internal:flag_name",
33+
"@com_google_fuzztest//fuzztest/internal:subprocess",
3434
],
3535
)
3636

@@ -66,13 +66,13 @@ cc_test(
6666
"@abseil-cpp//absl/time",
6767
"@com_google_fuzztest//centipede:weak_sancov_stubs",
6868
"@com_google_fuzztest//common:temp_dir",
69-
"@com_google_fuzztest//fuzztest:escaping",
70-
"@com_google_fuzztest//fuzztest:io",
71-
"@com_google_fuzztest//fuzztest:logging",
72-
"@com_google_fuzztest//fuzztest:printer",
73-
"@com_google_fuzztest//fuzztest:serialization",
74-
"@com_google_fuzztest//fuzztest:subprocess",
75-
"@com_google_fuzztest//fuzztest:type_support",
69+
"@com_google_fuzztest//fuzztest/internal:escaping",
70+
"@com_google_fuzztest//fuzztest/internal:io",
71+
"@com_google_fuzztest//fuzztest/internal:logging",
72+
"@com_google_fuzztest//fuzztest/internal:printer",
73+
"@com_google_fuzztest//fuzztest/internal:serialization",
74+
"@com_google_fuzztest//fuzztest/internal:subprocess",
75+
"@com_google_fuzztest//fuzztest/internal:type_support",
7676
"@googletest//:gtest_main",
7777
"@re2",
7878
],
@@ -91,8 +91,8 @@ cc_binary(
9191
"@abseil-cpp//absl/strings",
9292
"@abseil-cpp//absl/strings:str_format",
9393
"@abseil-cpp//absl/time",
94-
"@com_google_fuzztest//fuzztest:logging",
95-
"@com_google_fuzztest//fuzztest:subprocess",
94+
"@com_google_fuzztest//fuzztest/internal:logging",
95+
"@com_google_fuzztest//fuzztest/internal:subprocess",
9696
"@re2",
9797
],
9898
)
@@ -127,10 +127,10 @@ cc_test(
127127
"@abseil-cpp//absl/time",
128128
"@com_google_fuzztest//centipede:weak_sancov_stubs",
129129
"@com_google_fuzztest//common:temp_dir",
130-
"@com_google_fuzztest//fuzztest:escaping",
131-
"@com_google_fuzztest//fuzztest:io",
132-
"@com_google_fuzztest//fuzztest:logging",
133-
"@com_google_fuzztest//fuzztest:subprocess",
130+
"@com_google_fuzztest//fuzztest/internal:escaping",
131+
"@com_google_fuzztest//fuzztest/internal:io",
132+
"@com_google_fuzztest//fuzztest/internal:logging",
133+
"@com_google_fuzztest//fuzztest/internal:subprocess",
134134
"@googletest//:gtest_main",
135135
],
136136
)

0 commit comments

Comments
 (0)