fuzzers: Switch fuzzers to new generator API
Remove sanitizer transform fuzzers, as these will no longer be publicly visible. We should fuzz the generator options instead. Change-Id: If8f2c70f505bdaecd62a2f53a6586c3b84bd1c33 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57760 Auto-Submit: James Price <jrprice@google.com> Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
aa48b1ad8d
commit
54d1ee6f11
|
@ -91,11 +91,6 @@ if (build_with_chromium) {
|
|||
deps = [ ":tint_fuzzer_common" ]
|
||||
}
|
||||
|
||||
fuzzer_test("tint_spirv_transform_fuzzer") {
|
||||
sources = [ "tint_spirv_transform_fuzzer.cc" ]
|
||||
deps = [ ":tint_fuzzer_common" ]
|
||||
}
|
||||
|
||||
fuzzer_test("tint_vertex_pulling_fuzzer") {
|
||||
sources = [ "tint_vertex_pulling_fuzzer.cc" ]
|
||||
deps = [ ":tint_fuzzer_common" ]
|
||||
|
@ -108,11 +103,6 @@ if (build_with_chromium) {
|
|||
}
|
||||
|
||||
if (tint_build_wgsl_reader && tint_build_hlsl_writer) {
|
||||
fuzzer_test("tint_hlsl_transform_fuzzer") {
|
||||
sources = [ "tint_hlsl_transform_fuzzer.cc" ]
|
||||
deps = [ ":tint_fuzzer_common" ]
|
||||
}
|
||||
|
||||
fuzzer_test("tint_wgsl_reader_hlsl_writer_fuzzer") {
|
||||
sources = [ "tint_wgsl_reader_hlsl_writer_fuzzer.cc" ]
|
||||
deps = [ ":tint_fuzzer_common" ]
|
||||
|
@ -120,11 +110,6 @@ if (build_with_chromium) {
|
|||
}
|
||||
|
||||
if (tint_build_wgsl_reader && tint_build_msl_writer) {
|
||||
fuzzer_test("tint_msl_transform_fuzzer") {
|
||||
sources = [ "tint_msl_transform_fuzzer.cc" ]
|
||||
deps = [ ":tint_fuzzer_common" ]
|
||||
}
|
||||
|
||||
fuzzer_test("tint_wgsl_reader_msl_writer_fuzzer") {
|
||||
sources = [ "tint_wgsl_reader_msl_writer_fuzzer.cc" ]
|
||||
deps = [ ":tint_fuzzer_common" ]
|
||||
|
@ -192,20 +177,17 @@ if (build_with_chromium) {
|
|||
":tint_inspector_fuzzer",
|
||||
":tint_renamer_fuzzer",
|
||||
":tint_single_entry_point_fuzzer",
|
||||
":tint_spirv_transform_fuzzer",
|
||||
":tint_vertex_pulling_fuzzer",
|
||||
":tint_wgsl_reader_spv_writer_fuzzer",
|
||||
]
|
||||
}
|
||||
if (tint_build_wgsl_reader && tint_build_hlsl_writer) {
|
||||
deps += [
|
||||
":tint_hlsl_transform_fuzzer",
|
||||
":tint_wgsl_reader_hlsl_writer_fuzzer",
|
||||
]
|
||||
}
|
||||
if (tint_build_wgsl_reader && tint_build_msl_writer) {
|
||||
deps += [
|
||||
":tint_msl_transform_fuzzer",
|
||||
":tint_wgsl_reader_msl_writer_fuzzer",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -37,19 +37,16 @@ if (${TINT_BUILD_WGSL_READER} AND ${TINT_BUILD_SPV_WRITER})
|
|||
add_tint_fuzzer(tint_renamer_fuzzer)
|
||||
add_tint_fuzzer(tint_robustness_fuzzer)
|
||||
add_tint_fuzzer(tint_single_entry_point_fuzzer)
|
||||
add_tint_fuzzer(tint_spirv_transform_fuzzer)
|
||||
add_tint_fuzzer(tint_vertex_pulling_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)
|
||||
add_tint_fuzzer(tint_hlsl_transform_fuzzer)
|
||||
endif()
|
||||
|
||||
if (${TINT_BUILD_WGSL_READER} AND ${TINT_BUILD_MSL_WRITER})
|
||||
add_tint_fuzzer(tint_wgsl_reader_msl_writer_fuzzer)
|
||||
add_tint_fuzzer(tint_msl_transform_fuzzer)
|
||||
endif()
|
||||
|
||||
if (${TINT_BUILD_SPV_READER})
|
||||
|
|
|
@ -62,8 +62,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
config.manager.Add<transform::Hlsl>();
|
||||
|
||||
fuzzers::CommonFuzzer fuzzer(InputFormat::kWGSL, OutputFormat::kHLSL);
|
||||
fuzzer.SetTransformManager(&config.manager, std::move(config.inputs));
|
||||
|
||||
|
@ -79,8 +77,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
config.manager.Add<transform::Msl>();
|
||||
|
||||
fuzzers::CommonFuzzer fuzzer(InputFormat::kWGSL, OutputFormat::kMSL);
|
||||
fuzzer.SetTransformManager(&config.manager, std::move(config.inputs));
|
||||
|
||||
|
@ -95,8 +91,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
config.manager.Add<transform::Spirv>();
|
||||
|
||||
fuzzers::CommonFuzzer fuzzer(InputFormat::kWGSL, OutputFormat::kSpv);
|
||||
fuzzer.SetTransformManager(&config.manager, std::move(config.inputs));
|
||||
|
||||
|
|
|
@ -92,10 +92,11 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|||
// original source so that reformatting doesn't impact the final wgsl
|
||||
// comparison.
|
||||
std::string src_wgsl;
|
||||
tint::writer::wgsl::Options wgsl_options;
|
||||
{
|
||||
tint::writer::wgsl::Generator src_gen(&src);
|
||||
ASSERT_TRUE(src_gen.Generate());
|
||||
src_wgsl = src_gen.result();
|
||||
auto result = tint::writer::wgsl::Generate(&src, wgsl_options);
|
||||
ASSERT_TRUE(result.success);
|
||||
src_wgsl = result.wgsl;
|
||||
|
||||
// Move the src program to a temporary that'll be dropped, so that the src
|
||||
// program is released before we attempt to print the dst program. This
|
||||
|
@ -106,9 +107,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|||
}
|
||||
|
||||
// Print the dst program, check it matches the original source
|
||||
tint::writer::wgsl::Generator dst_gen(&dst);
|
||||
ASSERT_TRUE(dst_gen.Generate());
|
||||
auto dst_wgsl = dst_gen.result();
|
||||
auto result = tint::writer::wgsl::Generate(&dst, wgsl_options);
|
||||
ASSERT_TRUE(result.success);
|
||||
auto dst_wgsl = result.wgsl;
|
||||
ASSERT_EQ(src_wgsl, dst_wgsl);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -321,45 +321,57 @@ int CommonFuzzer::Run(const uint8_t* data, size_t size) {
|
|||
}
|
||||
|
||||
switch (output_) {
|
||||
case OutputFormat::kWGSL:
|
||||
case OutputFormat::kWGSL: {
|
||||
#if TINT_BUILD_WGSL_WRITER
|
||||
writer_ = std::make_unique<writer::wgsl::Generator>(&program);
|
||||
#endif // TINT_BUILD_WGSL_WRITER
|
||||
break;
|
||||
case OutputFormat::kSpv:
|
||||
#if TINT_BUILD_SPV_WRITER
|
||||
writer_ = std::make_unique<writer::spirv::Generator>(&program);
|
||||
#endif // TINT_BUILD_SPV_WRITER
|
||||
break;
|
||||
case OutputFormat::kHLSL:
|
||||
#if TINT_BUILD_HLSL_WRITER
|
||||
writer_ = std::make_unique<writer::hlsl::Generator>(&program);
|
||||
#endif // TINT_BUILD_HLSL_WRITER
|
||||
break;
|
||||
case OutputFormat::kMSL:
|
||||
#if TINT_BUILD_MSL_WRITER
|
||||
writer_ = std::make_unique<writer::msl::Generator>(&program);
|
||||
#endif // TINT_BUILD_MSL_WRITER
|
||||
break;
|
||||
case OutputFormat::kNone:
|
||||
break;
|
||||
}
|
||||
|
||||
if (writer_) {
|
||||
if (!writer_->Generate()) {
|
||||
writer::wgsl::Options options;
|
||||
auto result = writer::wgsl::Generate(&program, options);
|
||||
if (!result.success) {
|
||||
errors_ = writer_->error();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // TINT_BUILD_WGSL_WRITER
|
||||
break;
|
||||
}
|
||||
case OutputFormat::kSpv: {
|
||||
#if TINT_BUILD_SPV_WRITER
|
||||
if (output_ == OutputFormat::kSpv &&
|
||||
!SPIRVToolsValidationCheck(
|
||||
program,
|
||||
static_cast<writer::spirv::Generator*>(writer_.get())->result())) {
|
||||
writer::spirv::Options options;
|
||||
auto result = writer::spirv::Generate(&program, options);
|
||||
if (!result.success) {
|
||||
errors_ = writer_->error();
|
||||
return 0;
|
||||
}
|
||||
if (!SPIRVToolsValidationCheck(program, result.spirv)) {
|
||||
FatalError(program.Diagnostics(),
|
||||
"Fuzzing detected invalid spirv being emitted by Tint");
|
||||
}
|
||||
|
||||
#endif // TINT_BUILD_SPV_WRITER
|
||||
break;
|
||||
}
|
||||
case OutputFormat::kHLSL: {
|
||||
#if TINT_BUILD_HLSL_WRITER
|
||||
writer::hlsl::Options options;
|
||||
auto result = writer::hlsl::Generate(&program, options);
|
||||
if (!result.success) {
|
||||
errors_ = writer_->error();
|
||||
return 0;
|
||||
}
|
||||
#endif // TINT_BUILD_HLSL_WRITER
|
||||
break;
|
||||
}
|
||||
case OutputFormat::kMSL: {
|
||||
#if TINT_BUILD_MSL_WRITER
|
||||
writer::msl::Options options;
|
||||
auto result = writer::msl::Generate(&program, options);
|
||||
if (!result.success) {
|
||||
errors_ = writer_->error();
|
||||
return 0;
|
||||
}
|
||||
#endif // TINT_BUILD_MSL_WRITER
|
||||
break;
|
||||
}
|
||||
case OutputFormat::kNone:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -1,31 +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) {
|
||||
transform::Manager transform_manager;
|
||||
transform_manager.Add<transform::Hlsl>();
|
||||
|
||||
fuzzers::CommonFuzzer fuzzer(InputFormat::kWGSL, OutputFormat::kHLSL);
|
||||
fuzzer.SetTransformManager(&transform_manager, {});
|
||||
|
||||
return fuzzer.Run(data, size);
|
||||
}
|
||||
|
||||
} // namespace fuzzers
|
||||
} // namespace tint
|
|
@ -1,31 +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) {
|
||||
transform::Manager transform_manager;
|
||||
transform_manager.Add<transform::Msl>();
|
||||
|
||||
fuzzers::CommonFuzzer fuzzer(InputFormat::kWGSL, OutputFormat::kMSL);
|
||||
fuzzer.SetTransformManager(&transform_manager, {});
|
||||
|
||||
return fuzzer.Run(data, size);
|
||||
}
|
||||
|
||||
} // namespace fuzzers
|
||||
} // namespace tint
|
|
@ -1,31 +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) {
|
||||
transform::Manager transform_manager;
|
||||
transform_manager.Add<transform::Spirv>();
|
||||
|
||||
fuzzers::CommonFuzzer fuzzer(InputFormat::kWGSL, OutputFormat::kSpv);
|
||||
fuzzer.SetTransformManager(&transform_manager, {});
|
||||
|
||||
return fuzzer.Run(data, size);
|
||||
}
|
||||
|
||||
} // namespace fuzzers
|
||||
} // namespace tint
|
Loading…
Reference in New Issue