292 lines
9.8 KiB
Plaintext
292 lines
9.8 KiB
Plaintext
# 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")
|
|
|
|
# Fuzzers - Libfuzzer based fuzzing targets for Chromium
|
|
# To run the fuzzers outside of Chromium, use the CMake based builds.
|
|
|
|
if (build_with_chromium) {
|
|
import("//testing/libfuzzer/fuzzer_test.gni")
|
|
|
|
fuzzer_corpus_wgsl_dir = "${target_gen_dir}/fuzzer_corpus_wgsl"
|
|
action("tint_generate_wgsl_corpus") {
|
|
script = "generate_wgsl_corpus.py"
|
|
sources = [ "generate_wgsl_corpus.py" ]
|
|
args = [ rebase_path("${tint_root_dir}/test", root_build_dir), rebase_path(fuzzer_corpus_wgsl_dir, root_build_dir) ]
|
|
outputs = [ fuzzer_corpus_wgsl_dir ]
|
|
}
|
|
|
|
fuzzer_corpus_spirv_dir = "${target_gen_dir}/fuzzer_corpus_spirv"
|
|
action("tint_generate_spirv_corpus") {
|
|
# The spirv-as tool is used to turn SPIR-V assembly files into binary form.
|
|
# When cross compiling, it is important that spirv-as is built for the
|
|
# *host* tool chain, and that the host version of spirv-as is used to
|
|
# prepare the corpus.
|
|
spirv_as_target = "${tint_spirv_tools_dir}/:spirv-as(${host_toolchain})"
|
|
spirv_as_out_dir = get_label_info(spirv_as_target, "root_out_dir")
|
|
deps = [ spirv_as_target ]
|
|
script = "generate_spirv_corpus.py"
|
|
sources = [ "generate_spirv_corpus.py" ]
|
|
args = [ rebase_path("${tint_root_dir}/test", root_build_dir), rebase_path(fuzzer_corpus_spirv_dir, root_build_dir), rebase_path("${spirv_as_out_dir}/spirv-as", root_build_dir) ]
|
|
outputs = [ fuzzer_corpus_spirv_dir ]
|
|
}
|
|
|
|
# fuzzer_test doesn't have configs members, so need to define them in an empty
|
|
# source_set.
|
|
|
|
source_set("tint_fuzzer_common") {
|
|
public_configs = [
|
|
"${tint_root_dir}/src:tint_config",
|
|
"${tint_root_dir}/src:tint_common_config",
|
|
]
|
|
|
|
public_deps = [
|
|
"${tint_root_dir}/src:libtint",
|
|
"${tint_spirv_tools_dir}/:spvtools_val",
|
|
]
|
|
|
|
sources = [
|
|
"tint_common_fuzzer.cc",
|
|
"tint_common_fuzzer.h",
|
|
]
|
|
}
|
|
|
|
if (tint_build_wgsl_reader) {
|
|
fuzzer_test("tint_wgsl_reader_fuzzer") {
|
|
sources = [ "tint_wgsl_reader_fuzzer.cc" ]
|
|
deps = [ ":tint_fuzzer_common" ]
|
|
dict = "dictionary.txt"
|
|
seed_corpus = fuzzer_corpus_wgsl_dir
|
|
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
|
|
}
|
|
}
|
|
|
|
if (tint_build_wgsl_reader && tint_build_wgsl_writer) {
|
|
fuzzer_test("tint_wgsl_reader_wgsl_writer_fuzzer") {
|
|
sources = [ "tint_wgsl_reader_wgsl_writer_fuzzer.cc" ]
|
|
deps = [ ":tint_fuzzer_common" ]
|
|
dict = "dictionary.txt"
|
|
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" ]
|
|
dict = "dictionary.txt"
|
|
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" ]
|
|
dict = "dictionary.txt"
|
|
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" ]
|
|
dict = "dictionary.txt"
|
|
seed_corpus = fuzzer_corpus_wgsl_dir
|
|
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
|
|
}
|
|
|
|
fuzzer_test("tint_inspector_fuzzer") {
|
|
sources = [ "tint_inspector_fuzzer.cc" ]
|
|
deps = [ ":tint_fuzzer_common" ]
|
|
dict = "dictionary.txt"
|
|
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" ]
|
|
dict = "dictionary.txt"
|
|
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" ]
|
|
dict = "dictionary.txt"
|
|
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" ]
|
|
dict = "dictionary.txt"
|
|
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" ]
|
|
dict = "dictionary.txt"
|
|
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" ]
|
|
dict = "dictionary.txt"
|
|
seed_corpus = fuzzer_corpus_wgsl_dir
|
|
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
|
|
}
|
|
}
|
|
|
|
if (tint_build_wgsl_reader && tint_build_hlsl_writer) {
|
|
fuzzer_test("tint_wgsl_reader_hlsl_writer_fuzzer") {
|
|
sources = [ "tint_wgsl_reader_hlsl_writer_fuzzer.cc" ]
|
|
deps = [ ":tint_fuzzer_common" ]
|
|
dict = "dictionary.txt"
|
|
seed_corpus = fuzzer_corpus_wgsl_dir
|
|
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
|
|
}
|
|
}
|
|
|
|
if (tint_build_wgsl_reader && tint_build_msl_writer) {
|
|
fuzzer_test("tint_wgsl_reader_msl_writer_fuzzer") {
|
|
sources = [ "tint_wgsl_reader_msl_writer_fuzzer.cc" ]
|
|
deps = [ ":tint_fuzzer_common" ]
|
|
dict = "dictionary.txt"
|
|
seed_corpus = fuzzer_corpus_wgsl_dir
|
|
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
|
|
}
|
|
}
|
|
|
|
if (tint_build_spv_reader) {
|
|
fuzzer_test("tint_spv_reader_fuzzer") {
|
|
sources = [ "tint_spv_reader_fuzzer.cc" ]
|
|
deps = [ ":tint_fuzzer_common" ]
|
|
seed_corpus = fuzzer_corpus_spirv_dir
|
|
seed_corpus_deps = [ ":tint_generate_spirv_corpus" ]
|
|
}
|
|
}
|
|
|
|
if (tint_build_spv_reader && tint_build_wgsl_writer) {
|
|
fuzzer_test("tint_spv_reader_wgsl_writer_fuzzer") {
|
|
sources = [ "tint_spv_reader_wgsl_writer_fuzzer.cc" ]
|
|
deps = [ ":tint_fuzzer_common" ]
|
|
seed_corpus = fuzzer_corpus_spirv_dir
|
|
seed_corpus_deps = [ ":tint_generate_spirv_corpus" ]
|
|
}
|
|
}
|
|
|
|
if (tint_build_spv_reader && tint_build_spv_writer) {
|
|
fuzzer_test("tint_spv_reader_spv_writer_fuzzer") {
|
|
sources = [ "tint_spv_reader_spv_writer_fuzzer.cc" ]
|
|
deps = [ ":tint_fuzzer_common" ]
|
|
seed_corpus = fuzzer_corpus_spirv_dir
|
|
seed_corpus_deps = [ ":tint_generate_spirv_corpus" ]
|
|
}
|
|
}
|
|
|
|
if (tint_build_spv_reader && tint_build_hlsl_writer) {
|
|
fuzzer_test("tint_spv_reader_hlsl_writer_fuzzer") {
|
|
sources = [ "tint_spv_reader_hlsl_writer_fuzzer.cc" ]
|
|
deps = [ ":tint_fuzzer_common" ]
|
|
seed_corpus = fuzzer_corpus_spirv_dir
|
|
seed_corpus_deps = [ ":tint_generate_spirv_corpus" ]
|
|
}
|
|
}
|
|
|
|
if (tint_build_spv_reader && tint_build_msl_writer) {
|
|
fuzzer_test("tint_spv_reader_msl_writer_fuzzer") {
|
|
sources = [ "tint_spv_reader_msl_writer_fuzzer.cc" ]
|
|
deps = [ ":tint_fuzzer_common" ]
|
|
seed_corpus = fuzzer_corpus_spirv_dir
|
|
seed_corpus_deps = [ ":tint_generate_spirv_corpus" ]
|
|
}
|
|
}
|
|
|
|
if (tint_build_wgsl_reader && tint_build_wgsl_writer) {
|
|
fuzzer_test("tint_ast_clone_fuzzer") {
|
|
sources = [ "tint_ast_clone_fuzzer.cc" ]
|
|
deps = [ ":tint_fuzzer_common" ]
|
|
dict = "dictionary.txt"
|
|
seed_corpus = fuzzer_corpus_wgsl_dir
|
|
seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
|
|
}
|
|
}
|
|
|
|
group("fuzzers") {
|
|
testonly = true
|
|
deps = []
|
|
|
|
if (tint_build_wgsl_reader) {
|
|
deps += [ ":tint_wgsl_reader_fuzzer" ]
|
|
}
|
|
if (tint_build_wgsl_reader && tint_build_wgsl_writer) {
|
|
deps += [ ":tint_wgsl_reader_wgsl_writer_fuzzer" ]
|
|
}
|
|
if (tint_build_wgsl_reader && tint_build_spv_writer) {
|
|
deps += [
|
|
":tint_all_transforms_fuzzer",
|
|
":tint_binding_remapper_fuzzer",
|
|
":tint_robustness_fuzzer",
|
|
":tint_first_index_offset_fuzzer",
|
|
":tint_inspector_fuzzer",
|
|
":tint_renamer_fuzzer",
|
|
":tint_single_entry_point_fuzzer",
|
|
":tint_vertex_pulling_fuzzer",
|
|
":tint_wgsl_reader_spv_writer_fuzzer",
|
|
]
|
|
}
|
|
if (tint_build_wgsl_reader && tint_build_hlsl_writer) {
|
|
deps += [
|
|
":tint_wgsl_reader_hlsl_writer_fuzzer",
|
|
]
|
|
}
|
|
if (tint_build_wgsl_reader && tint_build_msl_writer) {
|
|
deps += [
|
|
":tint_wgsl_reader_msl_writer_fuzzer",
|
|
]
|
|
}
|
|
if (tint_build_spv_reader) {
|
|
deps += [ ":tint_spv_reader_fuzzer" ]
|
|
}
|
|
if (tint_build_spv_reader && tint_build_wgsl_writer) {
|
|
deps += [ ":tint_spv_reader_wgsl_writer_fuzzer" ]
|
|
}
|
|
if (tint_build_spv_reader && tint_build_spv_writer) {
|
|
deps += [ ":tint_spv_reader_spv_writer_fuzzer" ]
|
|
}
|
|
if (tint_build_spv_reader && tint_build_hlsl_writer) {
|
|
deps += [ ":tint_spv_reader_hlsl_writer_fuzzer" ]
|
|
}
|
|
if (tint_build_spv_reader && tint_build_msl_writer) {
|
|
deps += [ ":tint_spv_reader_msl_writer_fuzzer" ]
|
|
}
|
|
if (tint_build_wgsl_reader && tint_build_wgsl_writer) {
|
|
deps += [ ":tint_ast_clone_fuzzer" ]
|
|
}
|
|
}
|
|
} else {
|
|
group("fuzzers") {
|
|
}
|
|
}
|