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>
This commit is contained in:
Alastair Donaldson 2021-07-29 11:58:18 +00:00 committed by Tint LUCI CQ
parent 7249404827
commit 1f0200a3ff
2 changed files with 81 additions and 0 deletions

View File

@ -73,6 +73,12 @@ if (build_with_chromium) {
"tint_transformation_batch_size=5", "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 # fuzzer_test doesn't have configs members, so need to define them in an empty
# source_set. # source_set.
@ -113,6 +119,15 @@ if (build_with_chromium) {
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ] 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") { fuzzer_test("tint_wgsl_reader_wgsl_writer_fuzzer") {
sources = [ "tint_wgsl_reader_wgsl_writer_fuzzer.cc" ] sources = [ "tint_wgsl_reader_wgsl_writer_fuzzer.cc" ]
deps = [ ":tint_fuzzer_common" ] deps = [ ":tint_fuzzer_common" ]
@ -164,6 +179,15 @@ if (build_with_chromium) {
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ] 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") { fuzzer_test("tint_renamer_fuzzer") {
sources = [ "tint_renamer_fuzzer.cc" ] sources = [ "tint_renamer_fuzzer.cc" ]
deps = [ ":tint_fuzzer_common" ] deps = [ ":tint_fuzzer_common" ]
@ -215,6 +239,15 @@ if (build_with_chromium) {
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ] 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") { fuzzer_test("tint_wgsl_reader_hlsl_writer_fuzzer") {
sources = [ "tint_wgsl_reader_hlsl_writer_fuzzer.cc" ] sources = [ "tint_wgsl_reader_hlsl_writer_fuzzer.cc" ]
deps = [ ":tint_fuzzer_common" ] deps = [ ":tint_fuzzer_common" ]
@ -234,6 +267,15 @@ if (build_with_chromium) {
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ] 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") { fuzzer_test("tint_wgsl_reader_msl_writer_fuzzer") {
sources = [ "tint_wgsl_reader_msl_writer_fuzzer.cc" ] sources = [ "tint_wgsl_reader_msl_writer_fuzzer.cc" ]
deps = [ ":tint_fuzzer_common" ] deps = [ ":tint_fuzzer_common" ]
@ -340,6 +382,7 @@ if (build_with_chromium) {
if (tint_build_wgsl_reader && tint_build_wgsl_writer) { if (tint_build_wgsl_reader && tint_build_wgsl_writer) {
deps += [ deps += [
":tint_ast_wgsl_writer_fuzzer", ":tint_ast_wgsl_writer_fuzzer",
":tint_regex_wgsl_writer_fuzzer",
":tint_wgsl_reader_wgsl_writer_fuzzer", ":tint_wgsl_reader_wgsl_writer_fuzzer",
] ]
} }
@ -350,6 +393,7 @@ if (build_with_chromium) {
":tint_binding_remapper_fuzzer", ":tint_binding_remapper_fuzzer",
":tint_first_index_offset_fuzzer", ":tint_first_index_offset_fuzzer",
":tint_inspector_fuzzer", ":tint_inspector_fuzzer",
":tint_regex_spv_writer_fuzzer",
":tint_renamer_fuzzer", ":tint_renamer_fuzzer",
":tint_robustness_fuzzer", ":tint_robustness_fuzzer",
":tint_single_entry_point_fuzzer", ":tint_single_entry_point_fuzzer",
@ -360,12 +404,14 @@ if (build_with_chromium) {
if (tint_build_wgsl_reader && tint_build_hlsl_writer) { if (tint_build_wgsl_reader && tint_build_hlsl_writer) {
deps += [ deps += [
":tint_ast_hlsl_writer_fuzzer", ":tint_ast_hlsl_writer_fuzzer",
":tint_regex_hlsl_writer_fuzzer",
":tint_wgsl_reader_hlsl_writer_fuzzer", ":tint_wgsl_reader_hlsl_writer_fuzzer",
] ]
} }
if (tint_build_wgsl_reader && tint_build_msl_writer) { if (tint_build_wgsl_reader && tint_build_msl_writer) {
deps += [ deps += [
":tint_ast_msl_writer_fuzzer", ":tint_ast_msl_writer_fuzzer",
":tint_regex_msl_writer_fuzzer",
":tint_wgsl_reader_msl_writer_fuzzer", ":tint_wgsl_reader_msl_writer_fuzzer",
] ]
} }

View File

@ -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",
]
}
}