Create common utility class for fuzzing

This moves the usage of Tint in the fuzzers into a single class. This
will be expanded in the future to support emitting shaders, so fuzzing
tests, just need to indicate which reader & writer they want to use,
instead of having each test implement all of the API usage logic
directly.

BUG=tint:199

Change-Id: Id081a374014b7640a07b267e544ddeba3e6329dd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36760
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
This commit is contained in:
Ryan Harrison
2021-01-07 16:20:32 +00:00
committed by Commit Bot service account
parent 718975958b
commit 766e31d507
6 changed files with 121 additions and 20 deletions

View File

@@ -14,17 +14,9 @@
#include <vector>
#include "src/reader/spirv/parser.h"
#include "fuzzers/tint_common_fuzzer.h"
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
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) {
tint::reader::spirv::Parser parser(input);
parser.Parse();
}
return 0;
tint::fuzzers::CommonFuzzer fuzzer(tint::fuzzers::InputFormat::kSpv);
return fuzzer.Run(data, size);
}