Revert 3 fuzzing CLs, since they are preventing rolling into Chromium.
Revert "Adding fuzzing for Transforms" This reverts commit4a29008c7e
. Revert "Add fuzzers for various emission paths" This reverts commit39545b7e7c
. Revert "Create common utility class for fuzzing" This reverts commit766e31d507
. Change-Id: Ia4e4ea2a4a5f423ea5bfa8ca9659c4028b558b45 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37180 Auto-Submit: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dan sinclair <dsinclair@chromium.org> Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
795b6b5a28
commit
1d9935cf37
128
BUILD.gn
128
BUILD.gn
|
@ -1308,10 +1308,6 @@ if (build_with_chromium) {
|
||||||
source_set("tint_fuzzer_common") {
|
source_set("tint_fuzzer_common") {
|
||||||
configs += [ ":tint_common_config" ]
|
configs += [ ":tint_common_config" ]
|
||||||
public_configs = [ ":tint_public_config" ]
|
public_configs = [ ":tint_public_config" ]
|
||||||
sources = [
|
|
||||||
"fuzzers/tint_common_fuzzer.cc",
|
|
||||||
"fuzzers/tint_common_fuzzer.h",
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tint_build_wgsl_reader) {
|
if (tint_build_wgsl_reader) {
|
||||||
|
@ -1324,86 +1320,6 @@ if (build_with_chromium) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tint_build_wgsl_reader && tint_build_wgsl_writer) {
|
|
||||||
fuzzer_test("tint_wgsl_reader_wgsl_writer_fuzzer") {
|
|
||||||
sources = [ "fuzzers/tint_wgsl_reader_wgsl_writer_fuzzer.cc" ]
|
|
||||||
deps = [
|
|
||||||
":libtint_wgsl_reader_src",
|
|
||||||
":libtint_wgsl_writer_src",
|
|
||||||
":tint_fuzzer_common",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tint_build_wgsl_reader && tint_build_spv_writer) {
|
|
||||||
fuzzer_test("tint_wgsl_reader_spv_writer_fuzzer") {
|
|
||||||
sources = [ "fuzzers/tint_wgsl_reader_spv_writer_fuzzer.cc" ]
|
|
||||||
deps = [
|
|
||||||
":libtint_spv_writer_src",
|
|
||||||
":libtint_wgsl_reader_src",
|
|
||||||
":tint_fuzzer_common",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
fuzzer_test("tint_all_transforms_fuzzer") {
|
|
||||||
sources = [ "fuzzers/tint_all_transforms_fuzzer.cc" ]
|
|
||||||
deps = [
|
|
||||||
":libtint_spv_writer_src",
|
|
||||||
":libtint_wgsl_reader_src",
|
|
||||||
":tint_fuzzer_common",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
fuzzer_test("tint_bound_array_accessors_fuzzer") {
|
|
||||||
sources = [ "fuzzers/tint_bound_array_accessors_fuzzer.cc" ]
|
|
||||||
deps = [
|
|
||||||
":libtint_spv_writer_src",
|
|
||||||
":libtint_wgsl_reader_src",
|
|
||||||
":tint_fuzzer_common",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
fuzzer_test("tint_emit_vertex_point_size_fuzzer") {
|
|
||||||
sources = [ "fuzzers/tint_emit_vertex_point_size_fuzzer.cc" ]
|
|
||||||
deps = [
|
|
||||||
":libtint_spv_writer_src",
|
|
||||||
":libtint_wgsl_reader_src",
|
|
||||||
":tint_fuzzer_common",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
fuzzer_test("tint_first_index_offset_fuzzer") {
|
|
||||||
sources = [ "fuzzers/tint_first_index_offset_fuzzer.cc" ]
|
|
||||||
deps = [
|
|
||||||
":libtint_spv_writer_src",
|
|
||||||
":libtint_wgsl_reader_src",
|
|
||||||
":tint_fuzzer_common",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tint_build_wgsl_reader && tint_build_hlsl_writer) {
|
|
||||||
fuzzer_test("tint_wgsl_reader_hlsl_writer_fuzzer") {
|
|
||||||
sources = [ "fuzzers/tint_wgsl_reader_hlsl_writer_fuzzer.cc" ]
|
|
||||||
deps = [
|
|
||||||
":libtint_hlsl_writer_src",
|
|
||||||
":libtint_wgsl_reader_src",
|
|
||||||
":tint_fuzzer_common",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tint_build_wgsl_reader && tint_build_msl_writer) {
|
|
||||||
fuzzer_test("tint_wgsl_reader_msl_writer_fuzzer") {
|
|
||||||
sources = [ "fuzzers/tint_wgsl_reader_msl_writer_fuzzer.cc" ]
|
|
||||||
deps = [
|
|
||||||
":libtint_msl_writer_src",
|
|
||||||
":libtint_wgsl_reader_src",
|
|
||||||
":tint_fuzzer_common",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tint_build_spv_reader) {
|
if (tint_build_spv_reader) {
|
||||||
fuzzer_test("tint_spv_reader_fuzzer") {
|
fuzzer_test("tint_spv_reader_fuzzer") {
|
||||||
sources = [ "fuzzers/tint_spv_reader_fuzzer.cc" ]
|
sources = [ "fuzzers/tint_spv_reader_fuzzer.cc" ]
|
||||||
|
@ -1414,50 +1330,6 @@ if (build_with_chromium) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tint_build_spv_reader && tint_build_wgsl_writer) {
|
|
||||||
fuzzer_test("tint_spv_reader_wgsl_writer_fuzzer") {
|
|
||||||
sources = [ "fuzzers/tint_spv_reader_wgsl_writer_fuzzer.cc" ]
|
|
||||||
deps = [
|
|
||||||
":libtint_spv_reader_src",
|
|
||||||
":libtint_wgsl_writer_src",
|
|
||||||
":tint_fuzzer_common",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tint_build_spv_reader && tint_build_spv_writer) {
|
|
||||||
fuzzer_test("tint_spv_reader_spv_writer_fuzzer") {
|
|
||||||
sources = [ "fuzzers/tint_spv_reader_spv_writer_fuzzer.cc" ]
|
|
||||||
deps = [
|
|
||||||
":libtint_spv_reader_src",
|
|
||||||
":libtint_spv_writer_src",
|
|
||||||
":tint_fuzzer_common",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tint_build_spv_reader && tint_build_hlsl_writer) {
|
|
||||||
fuzzer_test("tint_spv_reader_hlsl_writer_fuzzer") {
|
|
||||||
sources = [ "fuzzers/tint_spv_reader_hlsl_writer_fuzzer.cc" ]
|
|
||||||
deps = [
|
|
||||||
":libtint_hlsl_writer_src",
|
|
||||||
":libtint_spv_reader_src",
|
|
||||||
":tint_fuzzer_common",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tint_build_spv_reader && tint_build_msl_writer) {
|
|
||||||
fuzzer_test("tint_spv_reader_msl_writer_fuzzer") {
|
|
||||||
sources = [ "fuzzers/tint_spv_reader_msl_writer_fuzzer.cc" ]
|
|
||||||
deps = [
|
|
||||||
":libtint_msl_writer_src",
|
|
||||||
":libtint_spv_reader_src",
|
|
||||||
":tint_fuzzer_common",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tint_build_wgsl_reader && tint_build_wgsl_writer) {
|
if (tint_build_wgsl_reader && tint_build_wgsl_writer) {
|
||||||
fuzzer_test("tint_ast_clone_fuzzer") {
|
fuzzer_test("tint_ast_clone_fuzzer") {
|
||||||
sources = [ "fuzzers/tint_ast_clone_fuzzer.cc" ]
|
sources = [ "fuzzers/tint_ast_clone_fuzzer.cc" ]
|
||||||
|
|
|
@ -13,59 +13,20 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
function(add_tint_fuzzer NAME)
|
function(add_tint_fuzzer NAME)
|
||||||
add_executable(${NAME}
|
add_executable(${NAME} ${NAME}.cc)
|
||||||
${NAME}.cc
|
|
||||||
tint_common_fuzzer.cc)
|
|
||||||
target_link_libraries(${NAME} libtint-fuzz)
|
target_link_libraries(${NAME} libtint-fuzz)
|
||||||
tint_default_compile_options(${NAME})
|
tint_default_compile_options(${NAME})
|
||||||
target_compile_options(${NAME} PRIVATE -Wno-missing-prototypes)
|
target_compile_options(${NAME} PRIVATE -Wno-missing-prototypes)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
if ({$TINT_BUILD_WGSL_READER})
|
if (${TINT_BUILD_WGSL_READER})
|
||||||
add_tint_fuzzer(tint_wgsl_reader_fuzzer)
|
add_tint_fuzzer(tint_wgsl_reader_fuzzer)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if ({$TINT_BUILD_WGSL_READER} AND ${TINT_BUILD_WGSL_WRITER})
|
|
||||||
add_tint_fuzzer(tint_wgsl_reader_wgsl_writer_fuzzer)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if ({$TINT_BUILD_WGSL_READER} AND ${TINT_BUILD_SPV_WRITER})
|
|
||||||
add_tint_fuzzer(tint_all_transforms_fuzzer)
|
|
||||||
add_tint_fuzzer(tint_bound_array_accessors_fuzzer)
|
|
||||||
add_tint_fuzzer(tint_emit_vertex_point_size_fuzzer)
|
|
||||||
add_tint_fuzzer(tint_first_index_offset_fuzzer)
|
|
||||||
add_tint_fuzzer(tint_wgsl_reader_spv_writer_fuzzer)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if ({$TINT_BUILD_WGSL_READER} AND ${TINT_BUILD_HLSL_WRITER})
|
|
||||||
add_tint_fuzzer(tint_wgsl_reader_hlsl_writer_fuzzer)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if ({$TINT_BUILD_WGSL_READER} AND ${TINT_BUILD_MSL_WRITER})
|
|
||||||
add_tint_fuzzer(tint_wgsl_reader_msl_writer_fuzzer)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (${TINT_BUILD_SPV_READER})
|
if (${TINT_BUILD_SPV_READER})
|
||||||
add_tint_fuzzer(tint_spv_reader_fuzzer)
|
add_tint_fuzzer(tint_spv_reader_fuzzer)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (${TINT_BUILD_SPV_READER} AND ${TINT_BUILD_WGSL_WRITER})
|
|
||||||
add_tint_fuzzer(tint_spv_reader_wgsl_writer_fuzzer)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (${TINT_BUILD_SPV_READER} AND ${TINT_BUILD_SPV_WRITER})
|
|
||||||
add_tint_fuzzer(tint_spv_reader_spv_writer_fuzzer)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (${TINT_BUILD_SPV_READER} AND ${TINT_BUILD_HLSL_WRITER})
|
|
||||||
add_tint_fuzzer(tint_spv_reader_hlsl_writer_fuzzer)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (${TINT_BUILD_SPV_READER} AND ${TINT_BUILD_MSL_WRITER})
|
|
||||||
add_tint_fuzzer(tint_spv_reader_msl_writer_fuzzer)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
if (${TINT_BUILD_WGSL_READER} AND ${TINT_BUILD_WGSL_WRITER})
|
if (${TINT_BUILD_WGSL_READER} AND ${TINT_BUILD_WGSL_WRITER})
|
||||||
add_tint_fuzzer(tint_ast_clone_fuzzer)
|
add_tint_fuzzer(tint_ast_clone_fuzzer)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
// 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.
|
|
||||||
|
|
||||||
#include "fuzzers/tint_common_fuzzer.h"
|
|
||||||
|
|
||||||
namespace tint {
|
|
||||||
namespace fuzzers {
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|
||||||
tint::transform::Manager transform_manager;
|
|
||||||
transform_manager.append(
|
|
||||||
std::make_unique<tint::transform::BoundArrayAccessors>());
|
|
||||||
transform_manager.append(
|
|
||||||
std::make_unique<tint::transform::EmitVertexPointSize>());
|
|
||||||
transform_manager.append(
|
|
||||||
std::make_unique<tint::transform::FirstIndexOffset>(0, 0));
|
|
||||||
|
|
||||||
tint::fuzzers::CommonFuzzer fuzzer(InputFormat::kWGSL, OutputFormat::kSpv);
|
|
||||||
fuzzer.SetTransformManager(&transform_manager);
|
|
||||||
|
|
||||||
return fuzzer.Run(data, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace fuzzers
|
|
||||||
} // namespace tint
|
|
|
@ -1,32 +0,0 @@
|
||||||
// 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.
|
|
||||||
|
|
||||||
#include "fuzzers/tint_common_fuzzer.h"
|
|
||||||
|
|
||||||
namespace tint {
|
|
||||||
namespace fuzzers {
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|
||||||
tint::transform::Manager transform_manager;
|
|
||||||
transform_manager.append(
|
|
||||||
std::make_unique<tint::transform::BoundArrayAccessors>());
|
|
||||||
|
|
||||||
tint::fuzzers::CommonFuzzer fuzzer(InputFormat::kWGSL, OutputFormat::kSpv);
|
|
||||||
fuzzer.SetTransformManager(&transform_manager);
|
|
||||||
|
|
||||||
return fuzzer.Run(data, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace fuzzers
|
|
||||||
} // namespace tint
|
|
|
@ -1,134 +0,0 @@
|
||||||
// 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.
|
|
||||||
|
|
||||||
#include "fuzzers/tint_common_fuzzer.h"
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
#include <utility>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace tint {
|
|
||||||
namespace fuzzers {
|
|
||||||
|
|
||||||
CommonFuzzer::CommonFuzzer(InputFormat input, OutputFormat output)
|
|
||||||
: input_(input), output_(output) {}
|
|
||||||
CommonFuzzer::~CommonFuzzer() = default;
|
|
||||||
|
|
||||||
int CommonFuzzer::Run(const uint8_t* data, size_t size) {
|
|
||||||
std::unique_ptr<tint::reader::Reader> parser;
|
|
||||||
#if TINT_BUILD_WGSL_READER
|
|
||||||
std::unique_ptr<tint::Source::File> file;
|
|
||||||
#endif // TINT_BUILD_WGSL_READER
|
|
||||||
|
|
||||||
switch (input_) {
|
|
||||||
case InputFormat::kWGSL:
|
|
||||||
#if TINT_BUILD_WGSL_READER
|
|
||||||
{
|
|
||||||
std::string str(reinterpret_cast<const char*>(data), size);
|
|
||||||
|
|
||||||
file = std::make_unique<tint::Source::File>("test.wgsl", str);
|
|
||||||
parser = std::make_unique<tint::reader::wgsl::Parser>(file.get());
|
|
||||||
}
|
|
||||||
#endif // TINT_BUILD_WGSL_READER
|
|
||||||
break;
|
|
||||||
case InputFormat::kSpv:
|
|
||||||
#if TINT_BUILD_SPV_READER
|
|
||||||
{
|
|
||||||
size_t sizeInU32 = size / sizeof(uint32_t);
|
|
||||||
const uint32_t* u32Data = reinterpret_cast<const uint32_t*>(data);
|
|
||||||
std::vector<uint32_t> input(u32Data, u32Data + sizeInU32);
|
|
||||||
|
|
||||||
if (input.size() != 0) {
|
|
||||||
parser = std::make_unique<tint::reader::spirv::Parser>(input);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // TINT_BUILD_WGSL_READER
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!parser) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!parser->Parse()) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (output_ == OutputFormat::kNone) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mod = parser->module();
|
|
||||||
if (!mod.IsValid()) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
tint::TypeDeterminer td(&mod);
|
|
||||||
if (!td.Determine()) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
tint::Validator v;
|
|
||||||
if (!v.Validate(&mod)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (transform_manager_) {
|
|
||||||
auto out = transform_manager_->Run(&mod);
|
|
||||||
if (out.diagnostics.contains_errors()) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
mod = std::move(out.module);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<tint::writer::Writer> writer;
|
|
||||||
|
|
||||||
switch (output_) {
|
|
||||||
case OutputFormat::kWGSL:
|
|
||||||
#if TINT_BUILD_WGSL_WRITER
|
|
||||||
writer = std::make_unique<tint::writer::wgsl::Generator>(std::move(mod));
|
|
||||||
#endif // TINT_BUILD_WGSL_WRITER
|
|
||||||
break;
|
|
||||||
case OutputFormat::kSpv:
|
|
||||||
#if TINT_BUILD_SPV_WRITER
|
|
||||||
writer = std::make_unique<tint::writer::spirv::Generator>(std::move(mod));
|
|
||||||
#endif // TINT_BUILD_SPV_WRITER
|
|
||||||
break;
|
|
||||||
case OutputFormat::kHLSL:
|
|
||||||
#if TINT_BUILD_HLSL_WRITER
|
|
||||||
writer = std::make_unique<tint::writer::hlsl::Generator>(std::move(mod));
|
|
||||||
#endif // TINT_BUILD_HLSL_WRITER
|
|
||||||
break;
|
|
||||||
case OutputFormat::kMSL:
|
|
||||||
#if TINT_BUILD_MSL_WRITER
|
|
||||||
writer = std::make_unique<tint::writer::msl::Generator>(std::move(mod));
|
|
||||||
#endif // TINT_BUILD_MSL_WRITER
|
|
||||||
break;
|
|
||||||
case OutputFormat::kNone:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (writer) {
|
|
||||||
writer->Generate();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace fuzzers
|
|
||||||
} // namespace tint
|
|
|
@ -1,45 +0,0 @@
|
||||||
// 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.
|
|
||||||
|
|
||||||
#ifndef FUZZERS_TINT_COMMON_FUZZER_H_
|
|
||||||
#define FUZZERS_TINT_COMMON_FUZZER_H_
|
|
||||||
|
|
||||||
#include "include/tint/tint.h"
|
|
||||||
|
|
||||||
namespace tint {
|
|
||||||
namespace fuzzers {
|
|
||||||
|
|
||||||
enum class InputFormat { kWGSL, kSpv, kNone };
|
|
||||||
|
|
||||||
enum class OutputFormat { kWGSL, kSpv, kHLSL, kMSL, kNone };
|
|
||||||
|
|
||||||
class CommonFuzzer {
|
|
||||||
public:
|
|
||||||
explicit CommonFuzzer(InputFormat input, OutputFormat output);
|
|
||||||
~CommonFuzzer();
|
|
||||||
|
|
||||||
void SetTransformManager(transform::Manager* tm) { transform_manager_ = tm; }
|
|
||||||
|
|
||||||
int Run(const uint8_t* data, size_t size);
|
|
||||||
|
|
||||||
private:
|
|
||||||
InputFormat input_;
|
|
||||||
OutputFormat output_;
|
|
||||||
transform::Manager* transform_manager_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace fuzzers
|
|
||||||
} // namespace tint
|
|
||||||
|
|
||||||
#endif // FUZZERS_TINT_COMMON_FUZZER_H_
|
|
|
@ -1,32 +0,0 @@
|
||||||
// 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.
|
|
||||||
|
|
||||||
#include "fuzzers/tint_common_fuzzer.h"
|
|
||||||
|
|
||||||
namespace tint {
|
|
||||||
namespace fuzzers {
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|
||||||
tint::transform::Manager transform_manager;
|
|
||||||
transform_manager.append(
|
|
||||||
std::make_unique<tint::transform::EmitVertexPointSize>());
|
|
||||||
|
|
||||||
tint::fuzzers::CommonFuzzer fuzzer(InputFormat::kWGSL, OutputFormat::kSpv);
|
|
||||||
fuzzer.SetTransformManager(&transform_manager);
|
|
||||||
|
|
||||||
return fuzzer.Run(data, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace fuzzers
|
|
||||||
} // namespace tint
|
|
|
@ -1,32 +0,0 @@
|
||||||
// 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.
|
|
||||||
|
|
||||||
#include "fuzzers/tint_common_fuzzer.h"
|
|
||||||
|
|
||||||
namespace tint {
|
|
||||||
namespace fuzzers {
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|
||||||
tint::transform::Manager transform_manager;
|
|
||||||
transform_manager.append(
|
|
||||||
std::make_unique<tint::transform::FirstIndexOffset>(0, 0));
|
|
||||||
|
|
||||||
tint::fuzzers::CommonFuzzer fuzzer(InputFormat::kWGSL, OutputFormat::kSpv);
|
|
||||||
fuzzer.SetTransformManager(&transform_manager);
|
|
||||||
|
|
||||||
return fuzzer.Run(data, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace fuzzers
|
|
||||||
} // namespace tint
|
|
|
@ -14,15 +14,17 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "fuzzers/tint_common_fuzzer.h"
|
#include "src/reader/spirv/parser.h"
|
||||||
|
|
||||||
namespace tint {
|
|
||||||
namespace fuzzers {
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||||
tint::fuzzers::CommonFuzzer fuzzer(InputFormat::kSpv, OutputFormat::kNone);
|
size_t sizeInU32 = size / sizeof(uint32_t);
|
||||||
return fuzzer.Run(data, size);
|
const uint32_t* u32Data = reinterpret_cast<const uint32_t*>(data);
|
||||||
}
|
std::vector<uint32_t> input(u32Data, u32Data + sizeInU32);
|
||||||
|
|
||||||
} // namespace fuzzers
|
if (input.size() != 0) {
|
||||||
} // namespace tint
|
tint::reader::spirv::Parser parser(input);
|
||||||
|
parser.Parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
// 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.
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "fuzzers/tint_common_fuzzer.h"
|
|
||||||
|
|
||||||
namespace tint {
|
|
||||||
namespace fuzzers {
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|
||||||
tint::fuzzers::CommonFuzzer fuzzer(InputFormat::kSpv, OutputFormat::kHLSL);
|
|
||||||
return fuzzer.Run(data, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace fuzzers
|
|
||||||
} // namespace tint
|
|
|
@ -1,28 +0,0 @@
|
||||||
// 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.
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "fuzzers/tint_common_fuzzer.h"
|
|
||||||
|
|
||||||
namespace tint {
|
|
||||||
namespace fuzzers {
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|
||||||
tint::fuzzers::CommonFuzzer fuzzer(InputFormat::kSpv, OutputFormat::kMSL);
|
|
||||||
return fuzzer.Run(data, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace fuzzers
|
|
||||||
} // namespace tint
|
|
|
@ -1,28 +0,0 @@
|
||||||
// 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.
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "fuzzers/tint_common_fuzzer.h"
|
|
||||||
|
|
||||||
namespace tint {
|
|
||||||
namespace fuzzers {
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|
||||||
tint::fuzzers::CommonFuzzer fuzzer(InputFormat::kSpv, OutputFormat::kSpv);
|
|
||||||
return fuzzer.Run(data, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace fuzzers
|
|
||||||
} // namespace tint
|
|
|
@ -1,28 +0,0 @@
|
||||||
// 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.
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "fuzzers/tint_common_fuzzer.h"
|
|
||||||
|
|
||||||
namespace tint {
|
|
||||||
namespace fuzzers {
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|
||||||
tint::fuzzers::CommonFuzzer fuzzer(InputFormat::kSpv, OutputFormat::kWGSL);
|
|
||||||
return fuzzer.Run(data, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace fuzzers
|
|
||||||
} // namespace tint
|
|
|
@ -14,15 +14,14 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "fuzzers/tint_common_fuzzer.h"
|
#include "src/reader/wgsl/parser.h"
|
||||||
|
|
||||||
namespace tint {
|
|
||||||
namespace fuzzers {
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||||
tint::fuzzers::CommonFuzzer fuzzer(InputFormat::kWGSL, OutputFormat::kNone);
|
std::string str(reinterpret_cast<const char*>(data), size);
|
||||||
return fuzzer.Run(data, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace fuzzers
|
tint::Source::File file("test.wgsl", str);
|
||||||
} // namespace tint
|
tint::reader::wgsl::Parser parser(&file);
|
||||||
|
parser.Parse();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
// 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.
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "fuzzers/tint_common_fuzzer.h"
|
|
||||||
|
|
||||||
namespace tint {
|
|
||||||
namespace fuzzers {
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|
||||||
tint::fuzzers::CommonFuzzer fuzzer(InputFormat::kWGSL, OutputFormat::kHLSL);
|
|
||||||
return fuzzer.Run(data, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace fuzzers
|
|
||||||
} // namespace tint
|
|
|
@ -1,28 +0,0 @@
|
||||||
// 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.
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "fuzzers/tint_common_fuzzer.h"
|
|
||||||
|
|
||||||
namespace tint {
|
|
||||||
namespace fuzzers {
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|
||||||
tint::fuzzers::CommonFuzzer fuzzer(InputFormat::kWGSL, OutputFormat::kMSL);
|
|
||||||
return fuzzer.Run(data, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace fuzzers
|
|
||||||
} // namespace tint
|
|
|
@ -1,28 +0,0 @@
|
||||||
// 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.
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "fuzzers/tint_common_fuzzer.h"
|
|
||||||
|
|
||||||
namespace tint {
|
|
||||||
namespace fuzzers {
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|
||||||
tint::fuzzers::CommonFuzzer fuzzer(InputFormat::kWGSL, OutputFormat::kSpv);
|
|
||||||
return fuzzer.Run(data, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace fuzzers
|
|
||||||
} // namespace tint
|
|
|
@ -1,28 +0,0 @@
|
||||||
// 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.
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "fuzzers/tint_common_fuzzer.h"
|
|
||||||
|
|
||||||
namespace tint {
|
|
||||||
namespace fuzzers {
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|
||||||
tint::fuzzers::CommonFuzzer fuzzer(InputFormat::kWGSL, OutputFormat::kWGSL);
|
|
||||||
return fuzzer.Run(data, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace fuzzers
|
|
||||||
} // namespace tint
|
|
Loading…
Reference in New Issue