Add checking for ICEs in fuzzers
BUG=tint:668 Change-Id: I6b0bf79873b01140b1e87ea60abeb623b031af23 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45942 Auto-Submit: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
5c9906e307
commit
0f5c26d5fd
|
@ -41,9 +41,18 @@
|
|||
} \
|
||||
} while (false)
|
||||
|
||||
[[noreturn]] void TintInternalCompilerErrorReporter(
|
||||
const tint::diag::List& diagnostics) {
|
||||
auto printer = tint::diag::Printer::create(stderr, true);
|
||||
tint::diag::Formatter{}.format(diagnostics, printer.get());
|
||||
__builtin_trap();
|
||||
}
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
std::string str(reinterpret_cast<const char*>(data), size);
|
||||
|
||||
tint::SetInternalCompilerErrorReporter(&TintInternalCompilerErrorReporter);
|
||||
|
||||
tint::Source::File file("test.wgsl", str);
|
||||
|
||||
// Parse the wgsl, create the src program
|
||||
|
|
|
@ -26,6 +26,13 @@
|
|||
namespace tint {
|
||||
namespace fuzzers {
|
||||
|
||||
[[noreturn]] void TintInternalCompilerErrorReporter(
|
||||
const tint::diag::List& diagnostics) {
|
||||
auto printer = tint::diag::Printer::create(stderr, true);
|
||||
tint::diag::Formatter{}.format(diagnostics, printer.get());
|
||||
__builtin_trap();
|
||||
}
|
||||
|
||||
CommonFuzzer::CommonFuzzer(InputFormat input, OutputFormat output)
|
||||
: input_(input),
|
||||
output_(output),
|
||||
|
@ -35,6 +42,8 @@ CommonFuzzer::CommonFuzzer(InputFormat input, OutputFormat output)
|
|||
CommonFuzzer::~CommonFuzzer() = default;
|
||||
|
||||
int CommonFuzzer::Run(const uint8_t* data, size_t size) {
|
||||
tint::SetInternalCompilerErrorReporter(&TintInternalCompilerErrorReporter);
|
||||
|
||||
Program program;
|
||||
|
||||
#if TINT_BUILD_WGSL_READER
|
||||
|
|
Loading…
Reference in New Issue