Fix assertion strings and tidy up memcpy call
These changes were intended for submission as part of 58386. Change-Id: I23f7ada1e8940dce6855176724ade1f2bb7687f8 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59024 Auto-Submit: Alastair Donaldson <afdx@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Alastair Donaldson <afdx@google.com>
This commit is contained in:
parent
7ec7794046
commit
8800ba091d
|
@ -205,8 +205,8 @@ int CommonFuzzer::Run(const uint8_t* data, size_t size) {
|
||||||
// sizeof(uint32_t)` uint32_t values. If `size` is not a multiple of
|
// sizeof(uint32_t)` uint32_t values. If `size` is not a multiple of
|
||||||
// sizeof(uint32_t) then not all of `data` can be copied into
|
// sizeof(uint32_t) then not all of `data` can be copied into
|
||||||
// `spirv_input`, and any trailing bytes are discarded.
|
// `spirv_input`, and any trailing bytes are discarded.
|
||||||
const size_t adjusted_size = (size / sizeof(uint32_t)) * sizeof(uint32_t);
|
std::memcpy(spirv_input.data(), data,
|
||||||
std::memcpy(spirv_input.data(), data, adjusted_size);
|
spirv_input.size() * sizeof(uint32_t));
|
||||||
if (spirv_input.empty()) {
|
if (spirv_input.empty()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,8 @@ extern "C" size_t LLVMFuzzerCustomMutator(uint8_t* data,
|
||||||
unsigned seed) {
|
unsigned seed) {
|
||||||
assert((size % 4) == 0 &&
|
assert((size % 4) == 0 &&
|
||||||
"A valid SPIR-V binary's size must be a multiple of 4, and the "
|
"A valid SPIR-V binary's size must be a multiple of 4, and the "
|
||||||
"SPIR-V Tools fuzzer should only work with valid binaries.");
|
"SPIR-V Tools fuzzer should only work with valid binaries. Check that "
|
||||||
|
"the fuzzer has been correctly configured.");
|
||||||
|
|
||||||
std::vector<uint32_t> binary(size / sizeof(uint32_t));
|
std::vector<uint32_t> binary(size / sizeof(uint32_t));
|
||||||
std::memcpy(binary.data(), data, size);
|
std::memcpy(binary.data(), data, size);
|
||||||
|
@ -175,8 +176,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
assert((size % 4) == 0 &&
|
assert((size % 4) == 0 &&
|
||||||
"A valid SPIR-V binary's size is a multiple of 4 bytes, and the "
|
"By design, the SPIR-V Tools fuzzer should only ever test using valid "
|
||||||
"SPIR-V Tools fuzzer should only work with valid binaries.");
|
"SPIR-V binaries, whose sizes should be multiples of 4 bytes. Check "
|
||||||
|
"that the fuzzer has been configured correctly, with a corpus of "
|
||||||
|
"valid SPIR-V binaries, and with only the custom mutator enabled.");
|
||||||
|
|
||||||
CommonFuzzer spv_to_wgsl(InputFormat::kSpv, OutputFormat::kWGSL);
|
CommonFuzzer spv_to_wgsl(InputFormat::kSpv, OutputFormat::kWGSL);
|
||||||
spv_to_wgsl.EnableInspector();
|
spv_to_wgsl.EnableInspector();
|
||||||
|
|
Loading…
Reference in New Issue