blob: bf83f011aef324d5bfd8a46c823bbf420ba06d92 [file] [log] [blame]
# Copyright 2022 The Dawn & Tint Authors
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//build_overrides/build.gni")
import("../../../scripts/tint_overrides_with_defaults.gni")
# Fuzzers - Libfuzzer based fuzzing targets for Chromium
# To run the fuzzers outside of Chromium, use the CMake based builds.
if (tint_has_fuzzers) {
import("//testing/libfuzzer/fuzzer_test.gni")
import("../../../scripts/dawn_overrides_with_defaults.gni")
fuzzer_corpus_wgsl_dir = "${target_gen_dir}/fuzzer_corpus_wgsl"
fuzzer_corpus_wgsl_stamp = "${fuzzer_corpus_wgsl_dir}.stamp"
action("tint_generate_wgsl_corpus") {
script = "generate_wgsl_corpus.py"
sources = [ "generate_wgsl_corpus.py" ]
args = [
"--stamp=" + rebase_path(fuzzer_corpus_wgsl_stamp, root_build_dir),
rebase_path("${tint_root_dir}/test", root_build_dir),
rebase_path(fuzzer_corpus_wgsl_dir, root_build_dir),
]
outputs = [ fuzzer_corpus_wgsl_stamp ]
}
tint_fuzzer_common_libfuzzer_options = [
"only_ascii=1",
"max_len=10000",
]
if (build_with_chromium) {
tint_ast_fuzzer_common_libfuzzer_options =
tint_fuzzer_common_libfuzzer_options + [
"cross_over=0",
"mutate_depth=1",
"tint_enable_all_mutations=false",
"tint_mutation_batch_size=5",
]
}
tint_regex_fuzzer_common_libfuzzer_options =
tint_fuzzer_common_libfuzzer_options + [
"cross_over=0",
"mutate_depth=1",
]
# fuzzer_test doesn't have configs members, so need to define them in an empty
# source_set.
source_set("tint_fuzzer_common_src") {
public_configs = [
"${tint_src_dir}:tint_config",
"${tint_src_dir}:tint_common_config",
]
public_deps = [
"${tint_spirv_tools_dir}/:spvtools_val",
"${tint_src_dir}/api",
"${tint_src_dir}/api/common",
"${tint_src_dir}/lang/core/type",
"${tint_src_dir}/lang/glsl/writer",
"${tint_src_dir}/lang/hlsl/writer",
"${tint_src_dir}/lang/hlsl/writer/helpers",
"${tint_src_dir}/lang/msl/writer",
"${tint_src_dir}/lang/msl/writer/helpers",
"${tint_src_dir}/lang/spirv/writer",
"${tint_src_dir}/lang/spirv/writer/helpers",
"${tint_src_dir}/lang/wgsl/ast",
"${tint_src_dir}/lang/wgsl/ast/transform",
"${tint_src_dir}/lang/wgsl/helpers",
"${tint_src_dir}/lang/wgsl/inspector",
"${tint_src_dir}/lang/wgsl/program",
"${tint_src_dir}/lang/wgsl/reader",
"${tint_src_dir}/lang/wgsl/resolver",
"${tint_src_dir}/lang/wgsl/sem",
"${tint_src_dir}/lang/wgsl/writer",
"${tint_src_dir}/utils/diagnostic",
"${tint_src_dir}/utils/math",
]
sources = [
"data_builder.h",
"mersenne_twister_engine.cc",
"mersenne_twister_engine.h",
"random_generator.cc",
"random_generator.h",
"random_generator_engine.cc",
"random_generator_engine.h",
"shuffle_transform.cc",
"shuffle_transform.h",
"tint_common_fuzzer.cc",
"tint_common_fuzzer.h",
"tint_reader_writer_fuzzer.h",
"transform_builder.h",
]
if (is_mac) {
sources += [ "//testing/libfuzzer/libfuzzer_exports.h" ]
}
}
source_set("tint_fuzzer_common_with_init_src") {
public_deps = [ ":tint_fuzzer_common_src" ]
sources = [
"cli.cc",
"cli.h",
"fuzzer_init.cc",
"fuzzer_init.h",
]
}
if (tint_build_wgsl_reader && tint_build_wgsl_writer) {
if (build_with_chromium) {
fuzzer_test("tint_ast_wgsl_writer_fuzzer") {
sources = [ "tint_ast_fuzzer/tint_ast_wgsl_writer_fuzzer.cc" ]
deps = [ "tint_ast_fuzzer:tint_ast_fuzzer" ]
libfuzzer_options = tint_ast_fuzzer_common_libfuzzer_options
seed_corpus = fuzzer_corpus_wgsl_dir
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
}
}
fuzzer_test("tint_regex_wgsl_writer_fuzzer") {
sources = [ "tint_regex_fuzzer/tint_regex_wgsl_writer_fuzzer.cc" ]
deps = [ "tint_regex_fuzzer:tint_regex_fuzzer" ]
libfuzzer_options = tint_regex_fuzzer_common_libfuzzer_options
seed_corpus = fuzzer_corpus_wgsl_dir
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
}
}
if (tint_build_wgsl_reader && tint_build_spv_writer) {
fuzzer_test("tint_all_transforms_fuzzer") {
sources = [ "tint_all_transforms_fuzzer.cc" ]
deps = [ ":tint_fuzzer_common_with_init_src" ]
dict = "dictionary.txt"
libfuzzer_options = tint_fuzzer_common_libfuzzer_options
seed_corpus = fuzzer_corpus_wgsl_dir
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
}
if (build_with_chromium) {
fuzzer_test("tint_ast_spv_writer_fuzzer") {
sources = [ "tint_ast_fuzzer/tint_ast_spv_writer_fuzzer.cc" ]
deps = [ "tint_ast_fuzzer:tint_ast_fuzzer" ]
libfuzzer_options = tint_ast_fuzzer_common_libfuzzer_options
seed_corpus = fuzzer_corpus_wgsl_dir
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
}
}
fuzzer_test("tint_binding_remapper_fuzzer") {
sources = [ "tint_binding_remapper_fuzzer.cc" ]
deps = [ ":tint_fuzzer_common_with_init_src" ]
dict = "dictionary.txt"
libfuzzer_options = tint_fuzzer_common_libfuzzer_options
seed_corpus = fuzzer_corpus_wgsl_dir
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
}
# Disable this fuzzer on windows + ASAN. See crbug.com/1357188.
if (!(is_win && is_asan)) {
fuzzer_test("tint_concurrency_fuzzer") {
sources = [ "tint_concurrency_fuzzer.cc" ]
deps = [ ":tint_fuzzer_common_with_init_src" ]
dict = "dictionary.txt"
libfuzzer_options = tint_fuzzer_common_libfuzzer_options
seed_corpus = fuzzer_corpus_wgsl_dir
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
}
}
fuzzer_test("tint_first_index_offset_fuzzer") {
sources = [ "tint_first_index_offset_fuzzer.cc" ]
deps = [ ":tint_fuzzer_common_with_init_src" ]
dict = "dictionary.txt"
libfuzzer_options = tint_fuzzer_common_libfuzzer_options
seed_corpus = fuzzer_corpus_wgsl_dir
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
}
fuzzer_test("tint_regex_spv_writer_fuzzer") {
sources = [ "tint_regex_fuzzer/tint_regex_spv_writer_fuzzer.cc" ]
deps = [ "tint_regex_fuzzer:tint_regex_fuzzer" ]
libfuzzer_options = tint_regex_fuzzer_common_libfuzzer_options
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_with_init_src" ]
dict = "dictionary.txt"
libfuzzer_options = tint_fuzzer_common_libfuzzer_options
seed_corpus = fuzzer_corpus_wgsl_dir
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
}
fuzzer_test("tint_robustness_fuzzer") {
sources = [ "tint_robustness_fuzzer.cc" ]
deps = [ ":tint_fuzzer_common_with_init_src" ]
dict = "dictionary.txt"
libfuzzer_options = tint_fuzzer_common_libfuzzer_options
seed_corpus = fuzzer_corpus_wgsl_dir
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
}
fuzzer_test("tint_single_entry_point_fuzzer") {
sources = [ "tint_single_entry_point_fuzzer.cc" ]
deps = [ ":tint_fuzzer_common_with_init_src" ]
dict = "dictionary.txt"
libfuzzer_options = tint_fuzzer_common_libfuzzer_options
seed_corpus = fuzzer_corpus_wgsl_dir
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
}
fuzzer_test("tint_vertex_pulling_fuzzer") {
sources = [ "tint_vertex_pulling_fuzzer.cc" ]
deps = [ ":tint_fuzzer_common_with_init_src" ]
dict = "dictionary.txt"
libfuzzer_options = tint_fuzzer_common_libfuzzer_options
seed_corpus = fuzzer_corpus_wgsl_dir
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
}
fuzzer_test("tint_wgsl_reader_spv_writer_fuzzer") {
sources = [ "tint_wgsl_reader_spv_writer_fuzzer.cc" ]
deps = [ ":tint_fuzzer_common_with_init_src" ]
dict = "dictionary.txt"
libfuzzer_options = tint_fuzzer_common_libfuzzer_options
seed_corpus = fuzzer_corpus_wgsl_dir
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
}
}
if (tint_build_wgsl_reader && tint_build_hlsl_writer) {
if (build_with_chromium) {
fuzzer_test("tint_ast_hlsl_writer_fuzzer") {
sources = [ "tint_ast_fuzzer/tint_ast_hlsl_writer_fuzzer.cc" ]
deps = [ "tint_ast_fuzzer:tint_ast_fuzzer" ]
libfuzzer_options = tint_ast_fuzzer_common_libfuzzer_options
seed_corpus = fuzzer_corpus_wgsl_dir
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
}
}
fuzzer_test("tint_regex_hlsl_writer_fuzzer") {
sources = [ "tint_regex_fuzzer/tint_regex_hlsl_writer_fuzzer.cc" ]
deps = [ "tint_regex_fuzzer:tint_regex_fuzzer" ]
libfuzzer_options = tint_regex_fuzzer_common_libfuzzer_options
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_with_init_src" ]
dict = "dictionary.txt"
libfuzzer_options = tint_fuzzer_common_libfuzzer_options
seed_corpus = fuzzer_corpus_wgsl_dir
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
}
}
if (tint_build_wgsl_reader && tint_build_msl_writer) {
if (build_with_chromium) {
fuzzer_test("tint_ast_msl_writer_fuzzer") {
sources = [ "tint_ast_fuzzer/tint_ast_msl_writer_fuzzer.cc" ]
deps = [ "tint_ast_fuzzer:tint_ast_fuzzer" ]
libfuzzer_options = tint_ast_fuzzer_common_libfuzzer_options
seed_corpus = fuzzer_corpus_wgsl_dir
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
}
}
fuzzer_test("tint_regex_msl_writer_fuzzer") {
sources = [ "tint_regex_fuzzer/tint_regex_msl_writer_fuzzer.cc" ]
deps = [ "tint_regex_fuzzer:tint_regex_fuzzer" ]
libfuzzer_options = tint_regex_fuzzer_common_libfuzzer_options
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_with_init_src" ]
dict = "dictionary.txt"
libfuzzer_options = tint_fuzzer_common_libfuzzer_options
seed_corpus = fuzzer_corpus_wgsl_dir
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
}
}
group("fuzzers") {
testonly = true
deps = []
if (tint_build_wgsl_reader && tint_build_wgsl_writer) {
deps += [ ":tint_regex_wgsl_writer_fuzzer" ]
if (build_with_chromium) {
deps += [ ":tint_ast_wgsl_writer_fuzzer" ]
}
}
if (tint_build_wgsl_reader && tint_build_spv_writer) {
deps += [
":tint_all_transforms_fuzzer",
":tint_binding_remapper_fuzzer",
":tint_first_index_offset_fuzzer",
":tint_regex_spv_writer_fuzzer",
":tint_renamer_fuzzer",
":tint_robustness_fuzzer",
":tint_single_entry_point_fuzzer",
":tint_vertex_pulling_fuzzer",
":tint_wgsl_reader_spv_writer_fuzzer",
]
if (build_with_chromium) {
deps += [ ":tint_ast_spv_writer_fuzzer" ]
}
}
if (tint_build_wgsl_reader && tint_build_hlsl_writer) {
deps += [
":tint_regex_hlsl_writer_fuzzer",
":tint_wgsl_reader_hlsl_writer_fuzzer",
]
if (build_with_chromium) {
deps += [ ":tint_ast_hlsl_writer_fuzzer" ]
}
}
if (tint_build_wgsl_reader && tint_build_msl_writer) {
deps += [
":tint_regex_msl_writer_fuzzer",
":tint_wgsl_reader_msl_writer_fuzzer",
]
if (build_with_chromium) {
deps += [ ":tint_ast_msl_writer_fuzzer" ]
}
}
}
} else {
group("fuzzers") {
}
}