Add gn support for regex fuzzer
Allows the tint regex fuzzer to be built using gn, so that it can be
deployed on ClusterFuzz.
Fixes: tint:1075
Change-Id: I88f8bd0eefe3044483b66784cc32feebcdc63928
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60202
Auto-Submit: Alastair Donaldson <afdx@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Alastair Donaldson <afdx@google.com>
diff --git a/fuzzers/BUILD.gn b/fuzzers/BUILD.gn
index 30f61ba..14da9db 100644
--- a/fuzzers/BUILD.gn
+++ b/fuzzers/BUILD.gn
@@ -73,6 +73,12 @@
"tint_transformation_batch_size=5",
]
+ tint_regex_fuzzer_common_libfuzzer_options = [
+ "cross_over=0",
+ "max_len=100000",
+ "mutate_depth=1",
+ ]
+
# fuzzer_test doesn't have configs members, so need to define them in an empty
# source_set.
@@ -113,6 +119,15 @@
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
}
+ fuzzer_test("tint_regex_wgsl_writer_fuzzer") {
+ sources = []
+ deps = [ "tint_regex_fuzzer:tint_regex_fuzzer" ]
+ libfuzzer_options = tint_regex_fuzzer_common_libfuzzer_options +
+ [ "tint_fuzzing_target=wgsl" ]
+ seed_corpus = fuzzer_corpus_wgsl_dir
+ seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
+ }
+
fuzzer_test("tint_wgsl_reader_wgsl_writer_fuzzer") {
sources = [ "tint_wgsl_reader_wgsl_writer_fuzzer.cc" ]
deps = [ ":tint_fuzzer_common" ]
@@ -164,6 +179,15 @@
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
}
+ fuzzer_test("tint_regex_spv_writer_fuzzer") {
+ sources = []
+ deps = [ "tint_regex_fuzzer:tint_regex_fuzzer" ]
+ libfuzzer_options = tint_regex_fuzzer_common_libfuzzer_options +
+ [ "tint_fuzzing_target=spv" ]
+ seed_corpus = fuzzer_corpus_wgsl_dir
+ seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
+ }
+
fuzzer_test("tint_renamer_fuzzer") {
sources = [ "tint_renamer_fuzzer.cc" ]
deps = [ ":tint_fuzzer_common" ]
@@ -215,6 +239,15 @@
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
}
+ fuzzer_test("tint_regex_hlsl_writer_fuzzer") {
+ sources = []
+ deps = [ "tint_regex_fuzzer:tint_regex_fuzzer" ]
+ libfuzzer_options = tint_regex_fuzzer_common_libfuzzer_options +
+ [ "tint_fuzzing_target=hlsl" ]
+ seed_corpus = fuzzer_corpus_wgsl_dir
+ seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
+ }
+
fuzzer_test("tint_wgsl_reader_hlsl_writer_fuzzer") {
sources = [ "tint_wgsl_reader_hlsl_writer_fuzzer.cc" ]
deps = [ ":tint_fuzzer_common" ]
@@ -234,6 +267,15 @@
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
}
+ fuzzer_test("tint_regex_msl_writer_fuzzer") {
+ sources = []
+ deps = [ "tint_regex_fuzzer:tint_regex_fuzzer" ]
+ libfuzzer_options = tint_regex_fuzzer_common_libfuzzer_options +
+ [ "tint_fuzzing_target=msl" ]
+ seed_corpus = fuzzer_corpus_wgsl_dir
+ seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
+ }
+
fuzzer_test("tint_wgsl_reader_msl_writer_fuzzer") {
sources = [ "tint_wgsl_reader_msl_writer_fuzzer.cc" ]
deps = [ ":tint_fuzzer_common" ]
@@ -340,6 +382,7 @@
if (tint_build_wgsl_reader && tint_build_wgsl_writer) {
deps += [
":tint_ast_wgsl_writer_fuzzer",
+ ":tint_regex_wgsl_writer_fuzzer",
":tint_wgsl_reader_wgsl_writer_fuzzer",
]
}
@@ -350,6 +393,7 @@
":tint_binding_remapper_fuzzer",
":tint_first_index_offset_fuzzer",
":tint_inspector_fuzzer",
+ ":tint_regex_spv_writer_fuzzer",
":tint_renamer_fuzzer",
":tint_robustness_fuzzer",
":tint_single_entry_point_fuzzer",
@@ -360,12 +404,14 @@
if (tint_build_wgsl_reader && tint_build_hlsl_writer) {
deps += [
":tint_ast_hlsl_writer_fuzzer",
+ ":tint_regex_hlsl_writer_fuzzer",
":tint_wgsl_reader_hlsl_writer_fuzzer",
]
}
if (tint_build_wgsl_reader && tint_build_msl_writer) {
deps += [
":tint_ast_msl_writer_fuzzer",
+ ":tint_regex_msl_writer_fuzzer",
":tint_wgsl_reader_msl_writer_fuzzer",
]
}
diff --git a/fuzzers/tint_regex_fuzzer/BUILD.gn b/fuzzers/tint_regex_fuzzer/BUILD.gn
new file mode 100644
index 0000000..1ebb545
--- /dev/null
+++ b/fuzzers/tint_regex_fuzzer/BUILD.gn
@@ -0,0 +1,35 @@
+# Copyright 2021 The Tint Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import("//build_overrides/build.gni")
+import("../../tint_overrides_with_defaults.gni")
+
+if (build_with_chromium) {
+ source_set("tint_regex_fuzzer") {
+ public_configs = [
+ "${tint_root_dir}/src:tint_config",
+ "${tint_root_dir}/src:tint_common_config",
+ ]
+
+ deps = [ "${tint_root_dir}/fuzzers:tint_fuzzer_common" ]
+
+ sources = [
+ "cli.cc",
+ "cli.h",
+ "fuzzer.cc",
+ "wgsl_mutator.cc",
+ "wgsl_mutator.h",
+ ]
+ }
+}