fuzzers: Don't drop writter errors on the floor

A writer shouldn't error. If the input is invalid, then this should be caught by the parser or resolver.
Fail the test if the writer errors.

Change-Id: I89da602dc96fa7be2a8efa288a90310a61745124
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58389
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Vasyl Teliman <vasniktel@gmail.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Ben Clayton 2021-07-16 21:07:25 +00:00 committed by Tint LUCI CQ
parent 86dc88725a
commit 50b6d024d6
1 changed files with 7 additions and 8 deletions

View File

@ -326,8 +326,8 @@ int CommonFuzzer::Run(const uint8_t* data, size_t size) {
auto result = writer::wgsl::Generate(&program, options);
generated_wgsl_ = std::move(result.wgsl);
if (!result.success) {
errors_ = result.error;
return 0;
FatalError(program.Diagnostics(),
"WGSL writer failed: " + result.error);
}
#endif // TINT_BUILD_WGSL_WRITER
break;
@ -338,8 +338,8 @@ int CommonFuzzer::Run(const uint8_t* data, size_t size) {
auto result = writer::spirv::Generate(&program, options);
generated_spirv_ = std::move(result.spirv);
if (!result.success) {
errors_ = result.error;
return 0;
FatalError(program.Diagnostics(),
"SPIR-V writer failed: " + result.error);
}
if (!SPIRVToolsValidationCheck(program, generated_spirv_)) {
FatalError(program.Diagnostics(),
@ -355,8 +355,8 @@ int CommonFuzzer::Run(const uint8_t* data, size_t size) {
auto result = writer::hlsl::Generate(&program, options);
generated_hlsl_ = std::move(result.hlsl);
if (!result.success) {
errors_ = result.error;
return 0;
FatalError(program.Diagnostics(),
"HLSL writer failed: " + result.error);
}
#endif // TINT_BUILD_HLSL_WRITER
break;
@ -367,8 +367,7 @@ int CommonFuzzer::Run(const uint8_t* data, size_t size) {
auto result = writer::msl::Generate(&program, options);
generated_msl_ = std::move(result.msl);
if (!result.success) {
errors_ = result.error;
return 0;
FatalError(program.Diagnostics(), "MSL writer failed: " + result.error);
}
#endif // TINT_BUILD_MSL_WRITER
break;